Files
EscapistsReintroduced/tests/test_native_infantry_setup.py
T
jakub a951a96edc Fix faction ammunition resupply and settings recovery
Wait for both convoy cargo phases and use actual magazine stock. Resolve empty primary weapon ammunition from muzzle metadata and recover cleanly from failed initial settings saves.

Update native fixtures, scoped cleanup guards, packaging evidence and validation documentation. Make reviewed fixture tests checkout-relative. All repository checks pass against the isolated staged tree; native resupply completion and multiplayer qualification remain outstanding.
2026-09-30 14:34:46 +02:00

36 lines
2.6 KiB
Python

"""Execute the actual infantry fixture setup branch; native scene boundaries adapted."""
import os,sys
from pathlib import Path
REPO=Path(os.environ.get('ERR_REPO', Path(__file__).resolve().parents[1]))
sys.path.insert(0,str(REPO/'tests'))
from policy_harness import body,run
p=Path(os.environ.get('ERR_SMOKE_SOURCE',REPO/'addons/core/Scripts/Game/ERR/40_Chat/ERR_NativeSmoke.c'))
s=body(p,'if (m_ERRTestInfantryTransfer)\n\t\t\t{')
s=s.replace('DamageManagerComponent.Cast(m_ERRSmokePlayer.FindComponent(DamageManagerComponent)).EnableDamageHandling(false);','damage.EnableDamageHandling(false);')
s=s.replace('OnStop().Insert(m_ERRInfantryTransfer.Stop);','OnStop().Insert(m_ERRInfantryTransfer);')
run(r'''
#include <cassert>
int phase=1;
struct ERR_NativeInfantryTransferProbe {static inline int created=0;ERR_NativeInfantryTransferProbe(void*){assert(phase==2);created++;}};
struct Damage {bool enabled=true;void EnableDamageHandling(bool b){enabled=b;}};
struct Invoker {int callbacks=0;void Insert(ERR_NativeInfantryTransferProbe* p){assert(p);callbacks++;}};
struct Mode {bool m_ERRTestInfantryTransfer=true,authorized=true;int m_ERRSmokePlayer=1,m_ERRSmokeStep=0,unlocks=0,failures=0;
Damage damage;Invoker stop;ERR_NativeInfantryTransferProbe*m_ERRInfantryTransfer=nullptr;
bool UnlockPrison(int p){assert(p==m_ERRSmokePlayer);unlocks++;if(!authorized)return false;phase=2;return true;}
bool ERR_Check(bool value,const char*){if(!value)failures++;return value;}Invoker&OnStop(){return stop;}
void Setup(){METHOD}
~Mode(){delete m_ERRInfantryTransfer;}
};
int main(){
{Mode m;phase=1;ERR_NativeInfantryTransferProbe::created=0;m.Setup();assert(m.unlocks==1&&phase==2&&!m.damage.enabled&&m.failures==0&&m.m_ERRSmokeStep==108&&m.stop.callbacks==1&&ERR_NativeInfantryTransferProbe::created==1);}
{Mode m;phase=1;ERR_NativeInfantryTransferProbe::created=0;m.authorized=false;m.Setup();assert(m.unlocks==1&&phase==1&&m.failures==1&&m.m_ERRSmokeStep==0&&m.stop.callbacks==0&&ERR_NativeInfantryTransferProbe::created==0);}
{Mode m;phase=1;m.m_ERRTestInfantryTransfer=false;m.Setup();assert(m.unlocks==0&&m.damage.enabled&&m.m_ERRSmokeStep==0&&m.stop.callbacks==0);}
}
'''.replace('METHOD',s))
assert 'Transition(' not in s and 'SetOrigin(' not in s
mode=REPO/'addons/core/Scripts/Game/ERR/00_Core/ERR_GameMode.c'
tick=body(mode,'protected void ServerTick(')
assert 'if (m_Command && m_Phase >= ERR_Phase.RADIO_SEARCH) m_Command.Tick(now);' in tick
assert 'if (m_Phase >= ERR_Phase.RADIO_SEARCH) TickForces(now);' in tick
print('PASS: actual inventory-fixture setup uses ordinary prison unlock before constructing its convoy-waiting probe; failed unlock cannot run fixture')