Files
EscapistsReintroduced/docs/evidence/mounted-interception-2026-10-02/convoy/tests-fixes.py
T
jakub 6a667d8deb Capture current mission, AI, map and administration development
Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
2026-10-13 22:52:53 +02:00

25 lines
3.2 KiB
Python

from pathlib import Path
P=Path('/tmp/erri-mounted-intercept-convoy-1247/tests');p=P/'test_convoy_lifecycle.py';s=p.read_text().replace("'ERR_ConvoyCombatState','ERR_ConvoyInterceptOrder']:", "'ERR_ConvoyCombatState','ERR_ConvoyInterceptOrder','ERR_ConvoyReceipt']:")
s=s.replace("code=re.sub(r'\\b(bool|int|float|", "code=code.replace('int attributed;', 'int attributed=0;')\ncode=re.sub(r'\\b(bool|int|float|")
s=s.replace("'claimed','m_Mode']", "'claimed','m_Mode','hq']")
s=s.replace("service=service.replace('Forces().','Forces()->')", "service=service.replace('ERR_HQ.Cast(m_Mode->Command())','m_Mode->Command()').replace('unit->Index.ToString()', 'std::to_string(unit->Index)')\nservice=service.replace('Forces().','Forces()->')")
s=s.replace('struct ERR_ForceRecord{int Id=7,Kind=3;', 'struct ERR_ForceRecord{SCR_AIGroup* Group=nullptr;std::string SourceId="original-vehicle-0";int Id=7,Kind=3;')
s=s.replace('struct Command{int unregistrations=0;', 'struct Command{int token=400001;int LogisticsToken(SCR_AIGroup*){return token;}int unregistrations=0;')
s=s.replace('struct ERR_GameMode{struct Ledger', 'using ERR_HQ=Command*;struct ERR_ConvoyReceipt;\nstruct ERR_GameMode{struct Ledger')
s=s.replace('Case(){agent.actor=&driver;', 'Case(){mode.ledger.record.Group=&group;agent.actor=&driver;')
s=s.replace('for(int bad=0;bad<13;bad++)', 'for(int bad=0;bad<14;bad++)').replace('if(bad==12)f.service.current=false;', 'if(bad==12)f.service.current=false;\n if(bad==13)f.mode.command.token=0;')
s=s.replace('int main(){', '''int main(){
{InterceptCase f;f.unit.Tick(&f.mode,&f.route,0);float deadline=f.unit.LegDeadline;auto original=f.unit.Waypoint;assert(f.Reserve());f.service.ReleaseIntercept(&f.task,&f.order,2000);assert(f.unit.Waypoint==original&&f.unit.LegDeadline==deadline);}
{InterceptCase f;f.unit.Tick(&f.mode,&f.route,0);float deadline=f.unit.LegDeadline;assert(f.Reserve());f.unit.Tick(&f.mode,&f.route,121000);assert(f.unit.LegDeadline==deadline);}
{InterceptCase f;assert(f.Reserve());assert(f.Apply());f.service.ReleaseIntercept(&f.task,&f.order,5000);assert(f.unit.LegDeadline==605000&&!f.unit.Waypoint);}
''',1);p.write_text(s)
p=P/'test_convoy_column.py';s=p.read_text().replace("s=s.replace('m_State[index].', 'm_State[index]->')", "s=s.replace('m_State[index].', 'm_State[index]->').replace('m_State[leader].', 'm_State[leader]->')")
s=s.replace("s=s.replace('float largestGap; bool supplyHold;', 'float largestGap=0; bool supplyHold=false;')", "s=s.replace('float largestGap; bool supplyHold; bool interceptLive;', 'float largestGap=0; bool supplyHold=false; bool interceptLive=false;')")
s=s.replace('struct ERR_ConvoyColumnVehicle{bool Holding=false;', 'struct ERR_ConvoyColumnVehicle{bool InterceptDetached=false,Holding=false;')
s=s.replace('int main(){', '''int main(){
{ERR_ConvoyVehicle a,b,c;b.Index=1;c.Index=2;a.InterceptActive=true;b.Released=c.Released=true;
ERR_ConvoyColumnVehicle sa,sb,sc;ERR_SupplyConvoyTask task;task.Vehicles={&a,&b,&c};Column column{nullptr,&task,{&sa,&sb,&sc}};
a.RouteIndex=0;a.entity.position={-200};assert(column.Tick(0));assert(sa.InterceptDetached&&a.RouteIndex==0&&!a.Waypoint);
column.m_RouteIndex=1;a.InterceptActive=false;assert(column.Tick(1000));assert(a.RouteIndex==0&&a.Waypoint&&column.m_RouteIndex==0);}
''',1);p.write_text(s)