"""Run actual ownership cancellation/Stop bodies with shared-array fixtures.""" from policy_harness import ROOT, body, run p=ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_SiteService.c' s='\n'.join(body(p, sig) for sig in ('void CancelInitialGuardRequests(', 'void Stop(')) for old,new in [ ('GetGame().','GetGame()->'), ('ChimeraAIWorld world', 'ChimeraAIWorld* world'), ('ChimeraAIWorld.Cast', 'ChimeraAIWorld::Cast'), ('array pendingGroups = {};', 'Array pendingGroups;'), ('foreach (ERR_SiteRuntime owner : m_Sites)', 'for (ERR_SiteRuntime* owner : m_Sites)'), ('foreach (ERR_SiteRuntime site : pendingGroups)', 'for (ERR_SiteRuntime* site : pendingGroups)'), ('pendingGroups.Insert', 'pendingGroups.push_back'), ('owner.Responders', 'owner->Responders'), ('site.Group', 'site->Group'), ('site.InitialGuardCount', 'site->InitialGuardCount'), ('site->Group.', 'site->Group->'), ('new array()', 'std::make_shared>()'), ('world.Purge', 'world->Purge'), ('m_ExtractionPlacement.', 'm_ExtractionPlacement->'), ('ERR_PrepareResult.', 'ERR_PrepareResult::'), ]: s=s.replace(old,new) run('''#include #include #include #include template using Array=std::vector; enum class ERR_PrepareResult {FAILED=-1,PENDING,READY}; struct Group {bool immediate=true; std::shared_ptr> m_aUnitPrefabSlots; int physical=0; void SetSpawnImmediately(bool b){immediate=b;} }; struct ERR_SiteRuntime {struct Group* Group; int InitialGuardCount;ERR_SiteRuntime* Responders=nullptr;}; struct ChimeraAIWorld { Array purged; static ChimeraAIWorld* Cast(ChimeraAIWorld* p){return p;} void PurgeSpawnRequestsForGroup(Group* group){ assert(!group->immediate && group->m_aUnitPrefabSlots->empty()); purged.push_back(group); } }; struct Game {ChimeraAIWorld* world; ChimeraAIWorld* GetAIWorld(){return world;}}; Game* game; Game* GetGame(){return game;} struct Placement { int stops=0; void Stop(){stops++;} }; struct Owner { std::shared_ptr m_ExtractionPlacement; Array m_Sites; bool m_Stopped=false; ERR_PrepareResult m_State=ERR_PrepareResult::PENDING; int routeStops=0; void StopPatrols(){routeStops++;} ''' + s + ''' }; int main(){ ChimeraAIWorld world; Game instance{&world}; game=&instance; auto authored=std::make_shared>(6,"soldier"); Group empty{true,authored,0}, partial{true,authored,2}, control{true,authored,6}, unrequested{true,authored,0}, mobile{true,authored,1}; ERR_SiteRuntime a{&empty,6},b{&partial,6},c{&control,6},ignored{&unrequested,0},missing{nullptr,6}; ERR_SiteRuntime responders{&mobile,2};a.Responders=&responders; Owner owner; owner.m_ExtractionPlacement=std::make_shared(); owner.m_Sites={&a,&b,&ignored,&missing}; owner.Stop(); owner.Stop(); assert(owner.m_Stopped && owner.routeStops==1 && world.purged.size()==3 && owner.m_ExtractionPlacement->stops==1); assert(empty.m_aUnitPrefabSlots->empty() && partial.m_aUnitPrefabSlots->empty()); assert(authored->size()==6 && control.m_aUnitPrefabSlots==authored && unrequested.m_aUnitPrefabSlots==authored); assert(!mobile.immediate && mobile.m_aUnitPrefabSlots->empty() && mobile.physical==1); assert(empty.physical==0 && partial.physical==2 && control.physical==6); assert(control.immediate && unrequested.immediate); Owner ready; ready.m_State=ERR_PrepareResult::READY; ready.m_Sites={&c}; ready.Stop(); assert(world.purged.size()==3 && control.immediate && control.m_aUnitPrefabSlots->size()==6); game=nullptr; Owner deletedGame; deletedGame.m_Sites={&c}; deletedGame.Stop(); assert(world.purged.size()==3); } ''') print('PASS: pending-only cancellation retires copied instance intent, preserves physical/control actors, and stops once')