fix(battle): match native modification inversion and bullet belt filtering on spawn

Align battle/pass-spawn-modifications-blk with the native UnitModifications
construction rules verified on 2.61.0.37 and 2.61.0.58:

- Filter effects.bulletMod belts against the spawn request's selected
  bullets0..N so unlocked belts (whose last wpcost.blk entry is usually
  *_stealth) do not overwrite single-belt aircraft guns with non-tracer
  stealth belts.
- Resolve invertEnableLogic (unit BLK overriding config/modifications.blk)
  so spaded vehicles move inverted performance modifications to disabledMods
  instead of applying stock penalties (and arcade double-inversion) in
  LocalMP battles.
- Include unequipped modifications in disabledMods only when they define
  disableModEffects (e.g. stock fire extinguisher / repair kit), keeping
  unequipped normal modifications out of disabledMods.

Verified with full Quirrel bytecode check-gui on 2.61.0.37 and 2.61.0.58
(49 GUI patches across 37 .nut files). In-game acceptance pending on an
isolated 2.61.0.58 client copy.
This commit is contained in:
N0VAN0M4LY committed 2026-12-03 00:29:51 +08:00
1 parent e8122d7c6b
commit dce9b59765
1 file changed
+56 -6
@@ -18,18 +18,68 @@
requestData.weapon = wtoExtraSlot.forceWeapon
let wtoSlotMods = wtoExtraSlot?.modifications ?? []
let wtoUnit = getAircraftByName(wtoUnitName) ?? this.getCurSlotUnit()
let wtoGlobalModsBlk = require("blkGetters").get_modifications_blk()?.modifications
let wtoUnitModsBlk = wtoUnitName != ""
? require("%scripts/unit/unitParams.nut").getFullUnitBlk(wtoUnitName)?.modifications
: null
// Only the bulletMod belts chosen in this spawn request may enter enabledMods; sending every
// unlocked belt lets the last belt in wpcost.blk (usually stealth) overwrite single-belt guns.
let wtoSelectedBullets = {}
for (local wtoBi = 0; wtoBi < BULLETS_SETS_QUANTITY; wtoBi++) {
let wtoBulName = requestData?[$"bullets{wtoBi}"] ?? ""
if (wtoBulName != "")
wtoSelectedBullets[wtoBulName] <- true
}
let wtoModNames = []
let wtoSeenMods = {}
foreach (wtoMod in (wtoUnit?.getModifications() ?? [])) {
let wtoName = wtoMod?.name ?? ""
if (wtoName != "" && !(wtoName in wtoSeenMods)) {
wtoSeenMods[wtoName] <- true
wtoModNames.append(wtoName)
}
}
if (wtoUnitModsBlk != null) {
for (local wtoMi = 0; wtoMi < wtoUnitModsBlk.blockCount(); wtoMi++) {
let wtoName = wtoUnitModsBlk.getBlock(wtoMi).getBlockName()
if (wtoName != "" && !(wtoName in wtoSeenMods)) {
wtoSeenMods[wtoName] <- true
wtoModNames.append(wtoName)
}
}
}
let wtoEnabledMods = []
let wtoDisabledMods = []
foreach (wtoMod in (wtoUnit?.getModifications() ?? [])) {
let wtoModName = wtoMod?.name ?? ""
if (wtoModName == "")
continue
foreach (wtoModName in wtoModNames) {
let wtoIsEnabled = wtoExtraSlot == null
? wtoChardRes.shopIsModificationEnabled(wtoUnitName, wtoModName)
: (wtoExtraSlot?.allModifications == true || wtoSlotMods.contains(wtoModName))
if (wtoIsEnabled)
let wtoGlobalModBlk = wtoGlobalModsBlk?.getBlockByName(wtoModName)
let wtoUnitModBlk = wtoUnitModsBlk?.getBlockByName(wtoModName)
let wtoHasBulletMod = (wtoUnitModBlk?.getBlockByName("effects")?.paramExists("bulletMod") ?? false)
|| (wtoGlobalModBlk?.getBlockByName("effects")?.paramExists("bulletMod") ?? false)
if (wtoHasBulletMod) {
if (wtoIsEnabled && (wtoModName in wtoSelectedBullets))
wtoEnabledMods.append(wtoModName)
continue
}
// Match UnitModifications::initFromSave / initFromLists: invertEnableLogic mods encode stock
// penalties in effects{} and must move to disabledMods once enabled; normal unequipped mods
// only enter disabledMods when they define disableModEffects{}.
local wtoInvert = wtoGlobalModBlk?.getBool("invertEnableLogic", false) ?? false
if (wtoUnitModBlk != null)
wtoInvert = wtoUnitModBlk.getBool("invertEnableLogic", wtoInvert)
let wtoHasDisableEffects = wtoUnitModBlk?.getBlockByName("disableModEffects") != null
|| wtoGlobalModBlk?.getBlockByName("disableModEffects") != null
if (wtoInvert) {
if (wtoIsEnabled)
wtoDisabledMods.append(wtoModName)
else
wtoEnabledMods.append(wtoModName)
}
else if (wtoIsEnabled)
wtoEnabledMods.append(wtoModName)
else if (wtoExtraSlot == null && wtoChardRes.shopIsModificationPurchased(wtoUnitName, wtoModName))
else if (wtoHasDisableEffects)
wtoDisabledMods.append(wtoModName)
}
let wtoBlk = DataBlock()