Explorar o código

remove thread_local AIGateway * aiGwTl

Mircea TheHonestCTO hai 3 meses
pai
achega
e2c80f03a1
Modificáronse 2 ficheiros con 2 adicións e 8 borrados
  1. 1 3
      AI/Nullkiller2/AIGateway.cpp
  2. 1 5
      AI/Nullkiller2/AIGateway.h

+ 1 - 3
AI/Nullkiller2/AIGateway.cpp

@@ -39,9 +39,7 @@
 namespace NK2AI
 {
 
-// one thread may be turn of AI and another will be handling a side effect for AI2
 thread_local CCallback * ccTl = nullptr;
-thread_local AIGateway * aiGwTl = nullptr;
 #define NET_EVENT_HANDLER SET_GLOBAL_STATE(this)
 
 AIGateway::AIGateway()
@@ -1313,7 +1311,7 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
 void AIGateway::buildStructure(const CGTownInstance * t, BuildingID building)
 {
 	auto name = t->getTown()->buildings.at(building)->getNameTranslated();
-	logAi->debug("Player %d will build %s in town of %s at %s", aiGwTl->playerID, name, t->getNameTranslated(), t->anchorPos().toString());
+	logAi->debug("Player %d will build %s in town of %s at %s", playerID, name, t->getNameTranslated(), t->anchorPos().toString());
 	cc->buildBuilding(t, building); //just do this;
 }
 

+ 1 - 5
AI/Nullkiller2/AIGateway.h

@@ -29,19 +29,16 @@ namespace NK2AI
 {
 
 extern thread_local CCallback * ccTl;
-extern thread_local AIGateway * aiGwTl;
 
 // helper RAII to manage global ai/cb ptrs
 struct SetGlobalState
 {
-	AIGateway * previousAiGw;
 	CCallback * previousCc;
 	bool wasAlreadySet;
 
 	SetGlobalState(AIGateway * aiGw, CCallback * cc)
-		: previousAiGw(aiGwTl), previousCc(ccTl), wasAlreadySet(aiGwTl != nullptr)
+		: previousCc(ccTl), wasAlreadySet(ccTl != nullptr)
 	{
-		aiGwTl = aiGw;
 		ccTl = cc;
 // #if NK2AI_TRACE_LEVEL >= 2
 // 		if(wasAlreadySet)
@@ -58,7 +55,6 @@ struct SetGlobalState
 	~SetGlobalState()
 	{
 		// Restore previous values instead of always setting to nullptr
-		aiGwTl = previousAiGw;
 		ccTl = previousCc;
 // #if NK2AI_TRACE_LEVEL >= 2
 // 		logAi->trace("SetGlobalState destroyed");