from pathlib import Path r=Path('/home/jakub/devel/escapistsrereintroduced') o=Path('/tmp/erri-mine-zones-tests-0558') s=(r/'tests/test_engineer_mine.py').read_text() s=s.replace("'ERR_GameMode','ERR_HQUnit'", "'SCR_AIGroupUtilityComponent','ERR_GameMode','ERR_HQUnit'") s=s.replace("'m_Mode','m_Unit'", "'groupUtility','m_Mode','m_Unit'") old='struct SCR_AIGroup {bool slave=false;int players=0;Faction* faction=nullptr;bool IsSlave(){return slave;}int GetPlayerCount(bool){return players;}Faction* GetFaction(){return faction;}};' new='''// Native group movement envelope boundary, not navigation/pathfinding. struct AIWaypoint {virtual ~AIWaypoint()=default;}; struct SCR_DefendWaypoint:AIWaypoint {vector origin;float radius=30;vector GetOrigin(){return origin;}float GetCompletionRadius(){return radius;}static SCR_DefendWaypoint* Cast(AIWaypoint* p){return dynamic_cast(p);}}; struct SCR_AIGroupUtilityComponent; struct SCR_AIGroup {bool slave=false;int players=0;Faction* faction=nullptr;SCR_AIGroupUtilityComponent* utility=nullptr;AIWaypoint* waypoint=nullptr;vector center; bool IsSlave(){return slave;}int GetPlayerCount(bool){return players;}Faction* GetFaction(){return faction;}SCR_AIGroupUtilityComponent* GetGroupUtilityComponent(){return utility;}AIWaypoint* GetCurrentWaypoint(){return waypoint;}vector GetCenterOfMass(){return center;}}; struct SCR_AIGroupUtilityComponent {SCR_AIGroup* m_Owner=nullptr;float m_fMaxAutonomousDistance=100; // Matches installed SCR_AIGroupUtilityComponent.IsPositionAllowed semantics. bool IsPositionAllowed(vector pos){auto wp=m_Owner->GetCurrentWaypoint();auto defendWp=SCR_DefendWaypoint::Cast(wp);if(defendWp)return vector::Distance(defendWp->GetOrigin(),pos)GetCompletionRadius();return vector::Distance(m_Owner->GetCenterOfMass(),pos)completed==1&&!foreign.completed&&f.attempted.Count()==1); assert(f.inventory.calls==calls&&f.utility.additions==additions&&f.mine.moves==moves&&!f.trigger.calls&&!f.mode.mineIntel.seals); f.group.utility=&f.groupUtility;f.group.waypoint=nullptr;f.Drop();if(callback)callback->OnComplete();f.actor.position={0,0,0};f.controller.Tick(14000); assert(f.controller.Finished()&&own->completed==1&&!foreign.completed&&f.inventory.calls==calls&&f.utility.additions==additions&&f.mine.moves==moves&&!f.trigger.calls); } ''' assert needle in s;s=s.replace(needle,extra,1) s=s.replace('PASS: actual engineer mine preparation/deadline,', 'PASS: actual engineer native group-envelope admission and phase cancellation, preparation/deadline,') (o/'tests/test_engineer_mine.py').write_text(s)