Use the signed i64 profile encoding identified in PR #13. Make attached backups selectable in LocalMP after the daily quota, and debit backups only after the engine confirms the selected slot entered play. Record the stock daily allowance once per room and slot. Settle owned backups using the confirmed spawn facts and keep repeat settlement from charging the same battle again. Verified server and launcher types, MSVC compilation, three client builds for patch and Quirrel checks, and a temporary 2.61.0.58 build. In-game acceptance is pending. Co-authored-by: duduyagame <[email protected]>
45 lines
1.6 KiB
Plaintext
45 lines
1.6 KiB
Plaintext
function getWtoBackupSourceForRequest(requestData) {
|
|
let getSource = require("%scripts/respawn/respawnState.nut")?.getWtoBackupSource
|
|
return getSource == null ? null : getSource(requestData.idInCountry, getAircraftByName(requestData.name))
|
|
}
|
|
|
|
function getWtoBackupToken(requestData, source) {
|
|
if (source == null)
|
|
return ""
|
|
if (source == "vehicle")
|
|
return "vehicle"
|
|
let uid = requestData.spareUid
|
|
if (source == "daily")
|
|
return uid == DAILY_FREE_SPARE_UID ? uid : null
|
|
if (source == "item" && uid != "" && uid != DAILY_FREE_SPARE_UID) {
|
|
let unit = getAircraftByName(requestData.name)
|
|
if (getUniversalSparesForUnit(unit).findvalue(@(item) item.uids.contains(uid)) != null)
|
|
return uid
|
|
}
|
|
return null
|
|
}
|
|
|
|
function openRespawnSpareWndIfNeeded(requestData) {
|
|
let wtoSource = this.getWtoBackupSourceForRequest(requestData)
|
|
if (wtoSource == "") {
|
|
showInfoMsgBox(loc("crew_not_available"), "crew_not_available")
|
|
return true
|
|
}
|
|
if (wtoSource == "vehicle") {
|
|
this.universalSpareUidForRespawn = ""
|
|
requestData.spareUid = ""
|
|
return false
|
|
}
|
|
if ((wtoSource == null && requestData.spareUid != "")
|
|
|| (wtoSource != null && this.getWtoBackupToken(requestData, wtoSource) != null))
|
|
return false
|
|
|
|
let crew = this.getCurCrew()
|
|
if (crew == null)
|
|
return false
|
|
|
|
let unit = getAircraftByName(requestData.name)
|
|
let canUseOnlyDailySpares = wtoSource == "daily" || (wtoSource == null && canUseOnlyDailyFreeSpares(crew.idInCountry))
|
|
if (wtoSource == null && !canUseOnlyDailySpares && !isRespawnWithUniversalSpare(crew, unit))
|
|
return false
|