Improve AI garrisons, player recovery and mission administration
This commit is contained in:
@@ -6,7 +6,11 @@ for old,new in [
|
||||
('GetGame().','GetGame()->'),
|
||||
('ChimeraAIWorld world', 'ChimeraAIWorld* world'),
|
||||
('ChimeraAIWorld.Cast', 'ChimeraAIWorld::Cast'),
|
||||
('foreach (ERR_SiteRuntime site : m_Sites)', 'for (ERR_SiteRuntime* site : m_Sites)'),
|
||||
('array<ERR_SiteRuntime> pendingGroups = {};', 'Array<ERR_SiteRuntime*> 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->'),
|
||||
@@ -22,7 +26,7 @@ run('''#include <cassert>
|
||||
template<typename T> using Array=std::vector<T>;
|
||||
enum class ERR_PrepareResult {FAILED=-1,PENDING,READY};
|
||||
struct Group {bool immediate=true; std::shared_ptr<Array<std::string>> m_aUnitPrefabSlots; int physical=0; void SetSpawnImmediately(bool b){immediate=b;} };
|
||||
struct ERR_SiteRuntime {struct Group* Group; int InitialGuardCount;};
|
||||
struct ERR_SiteRuntime {struct Group* Group; int InitialGuardCount;ERR_SiteRuntime* Responders=nullptr;};
|
||||
struct ChimeraAIWorld {
|
||||
Array<Group*> purged;
|
||||
static ChimeraAIWorld* Cast(ChimeraAIWorld* p){return p;}
|
||||
@@ -47,19 +51,21 @@ struct Owner {
|
||||
int main(){
|
||||
ChimeraAIWorld world; Game instance{&world}; game=&instance;
|
||||
auto authored=std::make_shared<Array<std::string>>(6,"soldier");
|
||||
Group empty{true,authored,0}, partial{true,authored,2}, control{true,authored,6}, unrequested{true,authored,0};
|
||||
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<Placement>(); owner.m_Sites={&a,&b,&ignored,&missing};
|
||||
owner.Stop(); owner.Stop();
|
||||
assert(owner.m_Stopped && owner.routeStops==1 && world.purged.size()==2 && owner.m_ExtractionPlacement->stops==1);
|
||||
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()==2 && control.immediate && control.m_aUnitPrefabSlots->size()==6);
|
||||
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()==2);
|
||||
assert(world.purged.size()==3);
|
||||
}
|
||||
''')
|
||||
print('PASS: pending-only cancellation retires copied instance intent, preserves physical/control actors, and stops once')
|
||||
|
||||
Reference in New Issue
Block a user