diff --git a/ai/include/Cevo/CustomAI.h b/ai/include/Cevo/CustomAI.h index 27dbc66..fa28112 100644 --- a/ai/include/Cevo/CustomAI.h +++ b/ai/include/Cevo/CustomAI.h @@ -50,8 +50,10 @@ public: virtual ~CustomAI(); // Attaches the player context handed out by the server at - // cmNewGame/cmLoadGame (TNewGameData.RO[nation]). - void bind(TPlayerContext *playerContext); + // cmNewGame/cmLoadGame (TNewGameData.RO[nation]). Virtual so an AI can + // pick up its persistent data (the original did it in its constructor, + // but here the context only arrives after construction). + virtual void bind(TPlayerContext *playerContext); // Set once per module from cmInitModule's TInitModuleData.Server; shared // by every CustomAI instance in this process, matching the original's diff --git a/ai/stdai/include/Cevo/AI.h b/ai/stdai/include/Cevo/AI.h index 6f8515e..cebcb82 100644 --- a/ai/stdai/include/Cevo/AI.h +++ b/ai/stdai/include/Cevo/AI.h @@ -66,6 +66,7 @@ class AI : public Barbarina { public: explicit AI(int nation); + void bind(TPlayerContext *playerContext) override; void setDataDefaults() override; protected: diff --git a/ai/stdai/src/AI.cpp b/ai/stdai/src/AI.cpp index 0057b3a..548ce7d 100644 --- a/ai/stdai/src/AI.cpp +++ b/ai/stdai/src/AI.cpp @@ -146,6 +146,12 @@ const std::array LeaveOutValue = computeLeaveOutValue(); AI::AI(int nation) : Barbarina(nation) {} +void AI::bind(TPlayerContext *playerContext) +{ + Barbarina::bind(playerContext); + data = static_cast(ro->Data); +} + void AI::setDataDefaults() { data->LastResearchTech = -1;