Split checkpoint guards between VirtualHQ and local defence; record Workshop 0.0.151
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-11-10 13:33:00 +01:00
parent 4b737c825f
commit 9889bd6404
23 changed files with 1557 additions and 78 deletions
+15 -1
View File
@@ -91,7 +91,7 @@ struct Recon{SCR_AIGroup owned=nullptr;bool Owns(SCR_AIGroup group){return group
struct BodyService:GroupService{void RegisterGroup(SCR_AIGroup g,Sampler& s){assert(s.Bound()&&s.group==g);GroupService::RegisterGroup(g);}};
struct Reporting{int initializations=0;void Initialize(int id,float now){assert(id>0&&now==10);initializations++;}};
struct Unit{Reporting AmmoReporting;string HomeId,ForceSourceId;bool ReservedForSupport=false;bool HomeGuard=false;float NextStatus=0;Sampler StatusSampler;int Id=0;SCR_AIGroup Group=nullptr;struct Utility* Utility=nullptr;float NextReport=0;};using ERR_HQUnit=Unit*;
struct Roadblocks{SCR_AIGroup owned=nullptr;bool Contains(SCR_AIGroup g){return g&&g==owned;}};
struct Roadblocks{SCR_AIGroup owned=nullptr,local=nullptr;bool Contains(SCR_AIGroup g){return g&&g==owned;}bool LocalOnly(SCR_AIGroup g){return g&&g==local;}};
struct HQ{void BindSpecialSkills(SCR_AIGroup){}void AuditGroup(ERR_HQUnit){}Mode* m_Mode;GroupService m_Equipment;BodyService m_Bodies;int m_NextId=0;Array<ERR_HQUnit> m_Units;Mortars* m_Mortars=nullptr;Scouts* m_Scouts=nullptr;Recon* m_Recon=nullptr;Recon* m_PlaneRecon=nullptr;Airfield* m_Airfield=nullptr;Scouts* m_Hunters=nullptr;Scouts* m_Towns=nullptr;Roadblocks* m_Roadblocks=nullptr;
'''+hqbind+hqregister+r'''
};
@@ -153,6 +153,20 @@ int main(){
assert(hq.m_Equipment.ids.back()==1&&hq.m_Equipment.fits.back());
int checkpointUnits=hq.m_Units.Count(),checkpointFits=hq.m_Equipment.ids.Count();
hq.RegisterGroup(&checkpoint);assert(hq.m_Units.Count()==checkpointUnits&&hq.m_Equipment.ids.Count()==checkpointFits);
// The parallel local pair keeps equipment/skills but never enters HQ,
// receives a radio allocation, reserves an HQ ID, or binds an HQ body roster.
Group localCheckpoint;posts.local=&localCheckpoint;
int beforeLocalUnits=hq.m_Units.Count(),beforeLocalId=hq.m_NextId,beforeLocalBodies=hq.m_Bodies.registrations;
int beforeLocalEquipment=hq.m_Equipment.registrations;
for(int repeat=0;repeat<5;repeat++){
hq.RegisterGroup(&localCheckpoint);
assert(hq.m_Units.Count()==beforeLocalUnits&&hq.m_NextId==beforeLocalId);
assert(hq.m_Bodies.registrations==beforeLocalBodies);
assert(hq.m_Equipment.ids.back()==0&&!hq.m_Equipment.fits.back());
}
assert(hq.m_Equipment.registrations==beforeLocalEquipment+1);
assert(!posts.Contains(&localCheckpoint)&&posts.LocalOnly(&localCheckpoint));
assert(posts.Contains(&checkpoint)&&!posts.LocalOnly(&checkpoint));
Group ordinaryAgain;hq.RegisterGroup(&ordinaryAgain);assert(hq.m_Equipment.ids.back()==8); // ordinary fitting remains distributed
Group town;Scouts towns;towns.owned=&town;hq.m_Towns=&towns;hq.RegisterGroup(&town);
assert(hq.m_Equipment.ids.back()==1&&hq.m_Equipment.fits.back()&&!hq.m_Units.back()->ReservedForSupport&&!hq.m_Units.back()->HomeGuard);