From 1e2ed620f7610b49b87c01a779084d282095b8b1 Mon Sep 17 00:00:00 2001 From: Mircea TheHonestCTO Date: Sat, 30 Aug 2025 07:27:07 +0200 Subject: [PATCH] thread local refactoring --- AI/Nullkiller2/AIGateway.cpp | 3 +++ AI/Nullkiller2/AIGateway.h | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/AI/Nullkiller2/AIGateway.cpp b/AI/Nullkiller2/AIGateway.cpp index af274d47f..86bbd1370 100644 --- a/AI/Nullkiller2/AIGateway.cpp +++ b/AI/Nullkiller2/AIGateway.cpp @@ -39,6 +39,9 @@ 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() diff --git a/AI/Nullkiller2/AIGateway.h b/AI/Nullkiller2/AIGateway.h index 1cb4d561f..8ab79dcf5 100644 --- a/AI/Nullkiller2/AIGateway.h +++ b/AI/Nullkiller2/AIGateway.h @@ -28,9 +28,8 @@ VCMI_LIB_NAMESPACE_END namespace NK2AI { -// one thread may be turn of AI and another will be handling a side effect for AI2 -inline thread_local CCallback * ccTl = nullptr; -inline thread_local AIGateway * aiGwTl = nullptr; +extern thread_local CCallback * ccTl; +extern thread_local AIGateway * aiGwTl; // helper RAII to manage global ai/cb ptrs struct SetGlobalState