From 57d04e5a59bc6ccaa759bd596d1dedff6e49fe05 Mon Sep 17 00:00:00 2001 From: Edo Date: Mon, 15 May 2023 23:27:37 +0100 Subject: [PATCH] [Events]: User modern concurrency container (#1042) --- .gitmodules | 2 +- deps/mongoose | 2 +- src/Components/Loader.cpp | 1 + src/Components/Loader.hpp | 1 - src/Components/Modules/Bans.cpp | 1 + src/Components/Modules/Bots.cpp | 1 + src/Components/Modules/CardTitles.cpp | 1 + src/Components/Modules/Chat.cpp | 1 + src/Components/Modules/ClanTags.cpp | 2 + src/Components/Modules/Debug.cpp | 1 + src/Components/Modules/Dedicated.cpp | 1 + src/Components/Modules/Download.cpp | 1 + src/Components/Modules/Elevators.cpp | 2 + src/Components/Modules/Events.cpp | 149 ++++++--- src/Components/Modules/Events.hpp | 38 +-- src/Components/Modules/Friends.cpp | 1 + src/Components/Modules/GSC/IO.cpp | 3 + src/Components/Modules/GSC/Script.cpp | 16 +- src/Components/Modules/GSC/ScriptError.cpp | 282 +++++++++--------- src/Components/Modules/GSC/ScriptError.hpp | 6 +- .../Modules/GSC/ScriptExtension.cpp | 3 + src/Components/Modules/GSC/UserInfo.cpp | 2 + src/Components/Modules/Logger.cpp | 2 + src/Components/Modules/MapRotation.cpp | 2 + src/Components/Modules/PlayerMovement.cpp | 2 + src/Components/Modules/RCon.cpp | 1 + src/Components/Modules/Renderer.cpp | 2 + src/Components/Modules/ServerList.cpp | 1 + src/Components/Modules/StartupMessages.cpp | 2 + src/Components/Modules/UIFeeder.cpp | 2 + src/Components/Modules/Voice.cpp | 2 + src/Utils/Utils.hpp | 6 - 32 files changed, 323 insertions(+), 216 deletions(-) diff --git a/.gitmodules b/.gitmodules index 912d4f5f..95e898f6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -17,7 +17,7 @@ [submodule "deps/mongoose"] path = deps/mongoose url = https://github.com/cesanta/mongoose.git - branch = 7.8 + branch = 7.9 [submodule "deps/protobuf"] path = deps/protobuf url = https://github.com/google/protobuf.git diff --git a/deps/mongoose b/deps/mongoose index 0a265e79..4236405b 160000 --- a/deps/mongoose +++ b/deps/mongoose @@ -1 +1 @@ -Subproject commit 0a265e79a67d7bfcdca27f2ccb98ccb474677ec6 +Subproject commit 4236405b90e051310aadda818e21c811e404b4d8 diff --git a/src/Components/Loader.cpp b/src/Components/Loader.cpp index 8f9d9bf5..fc09bb18 100644 --- a/src/Components/Loader.cpp +++ b/src/Components/Loader.cpp @@ -21,6 +21,7 @@ #include "Modules/Discovery.hpp" #include "Modules/Download.hpp" #include "Modules/Elevators.hpp" +#include "Modules/Events.hpp" #include "Modules/Exception.hpp" #include "Modules/FastFiles.hpp" #include "Modules/Friends.hpp" diff --git a/src/Components/Loader.hpp b/src/Components/Loader.hpp index d4282cdc..41c14b78 100644 --- a/src/Components/Loader.hpp +++ b/src/Components/Loader.hpp @@ -73,7 +73,6 @@ namespace Components #include "Modules/AssetHandler.hpp" #include "Modules/Dedicated.hpp" -#include "Modules/Events.hpp" #include "Modules/FileSystem.hpp" #include "Modules/Localization.hpp" #include "Modules/Maps.hpp" diff --git a/src/Components/Modules/Bans.cpp b/src/Components/Modules/Bans.cpp index 69cc4e6e..eefcc2a6 100644 --- a/src/Components/Modules/Bans.cpp +++ b/src/Components/Modules/Bans.cpp @@ -1,5 +1,6 @@ #include #include "Bans.hpp" +#include "Events.hpp" namespace Components { diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index ee8c6397..099948ab 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -2,6 +2,7 @@ #include "Bots.hpp" #include "ClanTags.hpp" +#include "Events.hpp" #include "GSC/Script.hpp" diff --git a/src/Components/Modules/CardTitles.cpp b/src/Components/Modules/CardTitles.cpp index 3ff49ffb..686e3974 100644 --- a/src/Components/Modules/CardTitles.cpp +++ b/src/Components/Modules/CardTitles.cpp @@ -1,5 +1,6 @@ #include #include "CardTitles.hpp" +#include "Events.hpp" #include "ServerCommands.hpp" namespace Components diff --git a/src/Components/Modules/Chat.cpp b/src/Components/Modules/Chat.cpp index 3ace57fc..7e0b0290 100644 --- a/src/Components/Modules/Chat.cpp +++ b/src/Components/Modules/Chat.cpp @@ -1,5 +1,6 @@ #include #include "Chat.hpp" +#include "Events.hpp" #include "PlayerName.hpp" #include "TextRenderer.hpp" #include "Voice.hpp" diff --git a/src/Components/Modules/ClanTags.cpp b/src/Components/Modules/ClanTags.cpp index 8e049e3c..d75dcf6d 100644 --- a/src/Components/Modules/ClanTags.cpp +++ b/src/Components/Modules/ClanTags.cpp @@ -1,5 +1,7 @@ #include + #include "ClanTags.hpp" +#include "Events.hpp" #include "PlayerName.hpp" #include "ServerCommands.hpp" diff --git a/src/Components/Modules/Debug.cpp b/src/Components/Modules/Debug.cpp index 768bb510..bfd45bf2 100644 --- a/src/Components/Modules/Debug.cpp +++ b/src/Components/Modules/Debug.cpp @@ -1,5 +1,6 @@ #include #include "Debug.hpp" +#include "Events.hpp" #include "TextRenderer.hpp" #include "Game/Engine/ScopedCriticalSection.hpp" diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index e2e5b2e8..a758e58c 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -3,6 +3,7 @@ #include "CardTitles.hpp" #include "ClanTags.hpp" +#include "Events.hpp" #include "Party.hpp" #include "ServerCommands.hpp" diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index ae0d1c6c..41433c9c 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -3,6 +3,7 @@ #include #include "Download.hpp" +#include "Events.hpp" #include "MapRotation.hpp" #include "Party.hpp" #include "ServerInfo.hpp" diff --git a/src/Components/Modules/Elevators.cpp b/src/Components/Modules/Elevators.cpp index f6cc4464..54b618bf 100644 --- a/src/Components/Modules/Elevators.cpp +++ b/src/Components/Modules/Elevators.cpp @@ -1,5 +1,7 @@ #include + #include "Elevators.hpp" +#include "Events.hpp" namespace Components { diff --git a/src/Components/Modules/Events.cpp b/src/Components/Modules/Events.cpp index 8d889a10..41ce5ded 100644 --- a/src/Components/Modules/Events.cpp +++ b/src/Components/Modules/Events.cpp @@ -1,54 +1,79 @@ #include +#include "Events.hpp" namespace Components { - Utils::Signal Events::ClientDisconnectSignal; - Utils::Signal Events::ClientConnectSignal; - Utils::Signal Events::SteamDisconnectSignal; - Utils::Signal Events::ShutdownSystemSignal; - Utils::Signal Events::ClientInitSignal; - Utils::Signal Events::ServerInitSignal; - Utils::Signal Events::DvarInitSignal; - Utils::Signal Events::NetworkInitSignal; + Utils::Concurrency::Container Events::ClientDisconnectTasks_; + Utils::Concurrency::Container Events::ClientConnectTasks_; + Utils::Concurrency::Container Events::SteamDisconnectTasks_; + Utils::Concurrency::Container Events::ShutdownSystemTasks_; + Utils::Concurrency::Container Events::ClientInitTasks_; + Utils::Concurrency::Container Events::ServerInitTasks_; + Utils::Concurrency::Container Events::DvarInitTasks_; + Utils::Concurrency::Container Events::NetworkInitTasks_; - void Events::OnClientDisconnect(const Utils::Slot& callback) + void Events::OnClientDisconnect(const std::function& callback) { - ClientDisconnectSignal.connect(callback); + ClientDisconnectTasks_.access([&callback](ClientCallback& tasks) + { + tasks.emplace_back(callback); + }); } - void Events::OnClientConnect(const Utils::Slot& callback) + void Events::OnClientConnect(const std::function& callback) { - ClientConnectSignal.connect(callback); + ClientConnectTasks_.access([&callback](ClientConnectCallback& tasks) + { + tasks.emplace_back(callback); + }); } - void Events::OnSteamDisconnect(const Utils::Slot& callback) + void Events::OnSteamDisconnect(const std::function& callback) { - SteamDisconnectSignal.connect(callback); + SteamDisconnectTasks_.access([&callback](Callback& tasks) + { + tasks.emplace_back(callback); + }); } - void Events::OnVMShutdown(const Utils::Slot& callback) + void Events::OnVMShutdown(const std::function& callback) { - ShutdownSystemSignal.connect(callback); + ShutdownSystemTasks_.access([&callback](Callback& tasks) + { + tasks.emplace_back(callback); + }); } - void Events::OnClientInit(const Utils::Slot& callback) + void Events::OnClientInit(const std::function& callback) { - ClientInitSignal.connect(callback); + ClientInitTasks_.access([&callback](Callback& tasks) + { + tasks.emplace_back(callback); + }); } - void Events::OnSVInit(const Utils::Slot& callback) + void Events::OnSVInit(const std::function& callback) { - ServerInitSignal.connect(callback); + ServerInitTasks_.access([&callback](Callback& tasks) + { + tasks.emplace_back(callback); + }); } - void Events::OnDvarInit(const Utils::Slot& callback) + void Events::OnDvarInit(const std::function& callback) { - DvarInitSignal.connect(callback); + DvarInitTasks_.access([&callback](Callback& tasks) + { + tasks.emplace_back(callback); + }); } - void Events::OnNetworkInit(const Utils::Slot& callback) + void Events::OnNetworkInit(const std::function& callback) { - NetworkInitSignal.connect(callback); + NetworkInitTasks_.access([&callback](Callback& tasks) + { + tasks.emplace_back(callback); + }); } /* @@ -57,60 +82,112 @@ namespace Components */ void Events::ClientDisconnect_Hk(const int clientNum) { - ClientDisconnectSignal(clientNum); + ClientDisconnectTasks_.access([&clientNum](ClientCallback& tasks) + { + for (const auto& func : tasks) + { + func(clientNum); + } + }); Utils::Hook::Call(0x4AA430)(clientNum); // ClientDisconnect } void Events::SV_UserinfoChanged_Hk(Game::client_s* cl) { - ClientConnectSignal(cl); + ClientConnectTasks_.access([&cl](ClientConnectCallback& tasks) + { + for (const auto& func : tasks) + { + func(cl); + } + }); Utils::Hook::Call(0x401950)(cl); // SV_UserinfoChanged } void Events::SteamDisconnect_Hk() { - SteamDisconnectSignal(); + SteamDisconnectTasks_.access([](Callback& tasks) + { + for (const auto& func : tasks) + { + func(); + } + }); Utils::Hook::Call(0x467CC0)(); // LiveSteam_Client_SteamDisconnect } void Events::Scr_ShutdownSystem_Hk(unsigned char sys) { - ShutdownSystemSignal(); + ShutdownSystemTasks_.access([](Callback& tasks) + { + for (const auto& func : tasks) + { + func(); + } + }); Utils::Hook::Call(0x421EE0)(sys); // Scr_ShutdownSystem } void Events::CL_InitOnceForAllClients_HK() { - ClientInitSignal(); - ClientInitSignal.clear(); + ClientInitTasks_.access([](Callback& tasks) + { + for (const auto& func : tasks) + { + func(); + } + + tasks = {}; // Only called once. Clear + }); Utils::Hook::Call(0x404CA0)(); // CL_InitOnceForAllClients } void Events::SV_Init_Hk() { - ServerInitSignal(); - ServerInitSignal.clear(); + ServerInitTasks_.access([](Callback& tasks) + { + for (const auto& func : tasks) + { + func(); + } + + tasks = {}; // Only called once. Clear + }); Utils::Hook::Call(0x474320)(); // SV_InitGameMode } void Events::Com_InitDvars_Hk() { - DvarInitSignal(); - DvarInitSignal.clear(); + DvarInitTasks_.access([](Callback& tasks) + { + for (const auto& func : tasks) + { + func(); + } + + tasks = {}; // Only called once. Clear + }); Utils::Hook::Call(0x60AD10)(); // Com_InitDvars } void Events::NetworkStart() { - NetworkInitSignal(); - NetworkInitSignal.clear(); + NetworkInitTasks_.access([](Callback& tasks) + { + for (const auto& func : tasks) + { + func(); + } + + tasks = {}; // Only called once. Clear + }); } __declspec(naked) void Events::NET_OpenSocks_Hk() diff --git a/src/Components/Modules/Events.hpp b/src/Components/Modules/Events.hpp index 439ad120..1803cc96 100644 --- a/src/Components/Modules/Events.hpp +++ b/src/Components/Modules/Events.hpp @@ -5,42 +5,42 @@ namespace Components class Events : public Component { public: - typedef void(ClientCallback)(int clientNum); - typedef void(ClientConnectCallback)(Game::client_s* cl); - typedef void(Callback)(); + using Callback = std::vector>; + using ClientConnectCallback = std::vector>; + using ClientCallback = std::vector>; Events(); // Server side - static void OnClientDisconnect(const Utils::Slot& callback); + static void OnClientDisconnect(const std::function& callback); // Server side - static void OnClientConnect(const Utils::Slot& callback); + static void OnClientConnect(const std::function& callback); // Client side - static void OnSteamDisconnect(const Utils::Slot& callback); + static void OnSteamDisconnect(const std::function& callback); - static void OnVMShutdown(const Utils::Slot& callback); + static void OnVMShutdown(const std::function& callback); - static void OnClientInit(const Utils::Slot& callback); + static void OnClientInit(const std::function& callback); // Client & Server (triggered once) - static void OnSVInit(const Utils::Slot& callback); + static void OnSVInit(const std::function& callback); // Client & Server (triggered once) - static void OnDvarInit(const Utils::Slot& callback); + static void OnDvarInit(const std::function& callback); - static void OnNetworkInit(const Utils::Slot& callback); + static void OnNetworkInit(const std::function& callback); private: - static Utils::Signal ClientDisconnectSignal; - static Utils::Signal ClientConnectSignal; - static Utils::Signal SteamDisconnectSignal; - static Utils::Signal ShutdownSystemSignal; - static Utils::Signal ClientInitSignal; - static Utils::Signal ServerInitSignal; - static Utils::Signal DvarInitSignal; - static Utils::Signal NetworkInitSignal; + static Utils::Concurrency::Container ClientDisconnectTasks_; + static Utils::Concurrency::Container ClientConnectTasks_; + static Utils::Concurrency::Container SteamDisconnectTasks_; + static Utils::Concurrency::Container ShutdownSystemTasks_; + static Utils::Concurrency::Container ClientInitTasks_; + static Utils::Concurrency::Container ServerInitTasks_; + static Utils::Concurrency::Container DvarInitTasks_; + static Utils::Concurrency::Container NetworkInitTasks_; static void ClientDisconnect_Hk(int clientNum); static void SV_UserinfoChanged_Hk(Game::client_s* cl); diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index 8f884641..90cf83c7 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -5,6 +5,7 @@ #include #pragma warning(pop) +#include "Events.hpp" #include "Friends.hpp" #include "Materials.hpp" #include "Node.hpp" diff --git a/src/Components/Modules/GSC/IO.cpp b/src/Components/Modules/GSC/IO.cpp index 662bc079..be8c2a53 100644 --- a/src/Components/Modules/GSC/IO.cpp +++ b/src/Components/Modules/GSC/IO.cpp @@ -1,4 +1,7 @@ #include + +#include + #include "IO.hpp" #include "Script.hpp" diff --git a/src/Components/Modules/GSC/Script.cpp b/src/Components/Modules/GSC/Script.cpp index 0bcdd1b6..521789d0 100644 --- a/src/Components/Modules/GSC/Script.cpp +++ b/src/Components/Modules/GSC/Script.cpp @@ -166,12 +166,12 @@ namespace Components::GSC if (pName != nullptr) { const auto name = Utils::String::ToLower(*pName); - for (const auto& func : CustomScrFunctions) + for (const auto& funcs : CustomScrFunctions) { - if (Utils::Contains(&func.aliases, name)) + if (std::ranges::find(funcs.aliases, name) != funcs.aliases.end()) { - *type = func.type; - return func.actionFunc; + *type = funcs.type; + return funcs.actionFunc; } } } @@ -193,12 +193,12 @@ namespace Components::GSC if (pName != nullptr) { const auto name = Utils::String::ToLower(*pName); - for (const auto& meth : CustomScrMethods) + for (const auto& meths : CustomScrMethods) { - if (Utils::Contains(&meth.aliases, name)) + if (std::ranges::find(meths.aliases, name) != meths.aliases.end()) { - *type = meth.type; - return meth.actionFunc; + *type = meths.type; + return meths.actionFunc; } } } diff --git a/src/Components/Modules/GSC/ScriptError.cpp b/src/Components/Modules/GSC/ScriptError.cpp index 3a197a5a..fe41ab90 100644 --- a/src/Components/Modules/GSC/ScriptError.cpp +++ b/src/Components/Modules/GSC/ScriptError.cpp @@ -9,10 +9,10 @@ namespace Components::GSC { using namespace Utils::String; - int ScriptError::developer_; + int ScriptError::Developer_; - Game::scrParserGlob_t ScriptError::scrParserGlob; - Game::scrParserPub_t ScriptError::scrParserPub; + Game::scrParserGlob_t ScriptError::ScrParserGlob; + Game::scrParserPub_t ScriptError::ScrParserPub; int ScriptError::Scr_IsInOpcodeMemory(const char* pos) { @@ -27,7 +27,7 @@ namespace Components::GSC Game::OpcodeLookup* opcodeLookup; Game::SourceLookup* sourcePosLookup; - if (!developer_) + if (!Developer_) { return; } @@ -48,83 +48,83 @@ namespace Components::GSC type &= ~Game::SOURCE_TYPE_BREAKPOINT; } - assert(scrParserGlob.opcodeLookup); - assert(scrParserGlob.sourcePosLookup); + assert(ScrParserGlob.opcodeLookup); + assert(ScrParserGlob.sourcePosLookup); assert(Game::scrCompilePub->opcodePos); - auto size = sizeof(Game::OpcodeLookup) * (scrParserGlob.opcodeLookupLen + 1); - if (size > scrParserGlob.opcodeLookupMaxSize) + auto size = sizeof(Game::OpcodeLookup) * (ScrParserGlob.opcodeLookupLen + 1); + if (size > ScrParserGlob.opcodeLookupMaxSize) { - if (scrParserGlob.opcodeLookupMaxSize >= Game::MAX_OPCODE_LOOKUP_SIZE) + if (ScrParserGlob.opcodeLookupMaxSize >= Game::MAX_OPCODE_LOOKUP_SIZE) { Game::Sys_Error("MAX_OPCODE_LOOKUP_SIZE exceeded"); } - Game::Z_VirtualCommit((char*)scrParserGlob.opcodeLookup + scrParserGlob.opcodeLookupMaxSize, 0x20000); - scrParserGlob.opcodeLookupMaxSize += 0x20000; - assert(size <= scrParserGlob.opcodeLookupMaxSize); + Game::Z_VirtualCommit((char*)ScrParserGlob.opcodeLookup + ScrParserGlob.opcodeLookupMaxSize, 0x20000); + ScrParserGlob.opcodeLookupMaxSize += 0x20000; + assert(size <= ScrParserGlob.opcodeLookupMaxSize); } - size = sizeof(Game::SourceLookup) * (scrParserGlob.sourcePosLookupLen + 1); - if (size > scrParserGlob.sourcePosLookupMaxSize) + size = sizeof(Game::SourceLookup) * (ScrParserGlob.sourcePosLookupLen + 1); + if (size > ScrParserGlob.sourcePosLookupMaxSize) { - if (scrParserGlob.sourcePosLookupMaxSize >= Game::MAX_SOURCEPOS_LOOKUP_SIZE) + if (ScrParserGlob.sourcePosLookupMaxSize >= Game::MAX_SOURCEPOS_LOOKUP_SIZE) { Game::Sys_Error("MAX_SOURCEPOS_LOOKUP_SIZE exceeded"); } - Game::Z_VirtualCommit((char*)scrParserGlob.sourcePosLookup + scrParserGlob.sourcePosLookupMaxSize, 0x20000); - scrParserGlob.sourcePosLookupMaxSize += 0x20000; - assert(size <= scrParserGlob.sourcePosLookupMaxSize); + Game::Z_VirtualCommit((char*)ScrParserGlob.sourcePosLookup + ScrParserGlob.sourcePosLookupMaxSize, 0x20000); + ScrParserGlob.sourcePosLookupMaxSize += 0x20000; + assert(size <= ScrParserGlob.sourcePosLookupMaxSize); } - if (scrParserGlob.currentCodePos == Game::scrCompilePub->opcodePos) + if (ScrParserGlob.currentCodePos == Game::scrCompilePub->opcodePos) { - assert(scrParserGlob.currentSourcePosCount); - --scrParserGlob.opcodeLookupLen; - opcodeLookup = &scrParserGlob.opcodeLookup[scrParserGlob.opcodeLookupLen]; - assert(opcodeLookup->sourcePosIndex + scrParserGlob.currentSourcePosCount == scrParserGlob.sourcePosLookupLen); - assert(opcodeLookup->codePos == (char*)scrParserGlob.currentCodePos); + assert(ScrParserGlob.currentSourcePosCount); + --ScrParserGlob.opcodeLookupLen; + opcodeLookup = &ScrParserGlob.opcodeLookup[ScrParserGlob.opcodeLookupLen]; + assert(opcodeLookup->sourcePosIndex + ScrParserGlob.currentSourcePosCount == ScrParserGlob.sourcePosLookupLen); + assert(opcodeLookup->codePos == (char*)ScrParserGlob.currentCodePos); } else { - scrParserGlob.currentSourcePosCount = 0; - scrParserGlob.currentCodePos = Game::scrCompilePub->opcodePos; - opcodeLookup = &scrParserGlob.opcodeLookup[scrParserGlob.opcodeLookupLen]; - opcodeLookup->sourcePosIndex = scrParserGlob.sourcePosLookupLen; - opcodeLookup->codePos = scrParserGlob.currentCodePos; + ScrParserGlob.currentSourcePosCount = 0; + ScrParserGlob.currentCodePos = Game::scrCompilePub->opcodePos; + opcodeLookup = &ScrParserGlob.opcodeLookup[ScrParserGlob.opcodeLookupLen]; + opcodeLookup->sourcePosIndex = ScrParserGlob.sourcePosLookupLen; + opcodeLookup->codePos = ScrParserGlob.currentCodePos; } - auto sourcePosLookupIndex = scrParserGlob.currentSourcePosCount + opcodeLookup->sourcePosIndex; - sourcePosLookup = &scrParserGlob.sourcePosLookup[sourcePosLookupIndex]; + auto sourcePosLookupIndex = ScrParserGlob.currentSourcePosCount + opcodeLookup->sourcePosIndex; + sourcePosLookup = &ScrParserGlob.sourcePosLookup[sourcePosLookupIndex]; sourcePosLookup->sourcePos = sourcePos; if (sourcePos == static_cast(-1)) { - assert(scrParserGlob.delayedSourceIndex == -1); + assert(ScrParserGlob.delayedSourceIndex == -1); assert(type & Game::SOURCE_TYPE_BREAKPOINT); - scrParserGlob.delayedSourceIndex = static_cast(sourcePosLookupIndex); + ScrParserGlob.delayedSourceIndex = static_cast(sourcePosLookupIndex); } else if (sourcePos == static_cast(-2)) { - scrParserGlob.threadStartSourceIndex = static_cast(sourcePosLookupIndex); + ScrParserGlob.threadStartSourceIndex = static_cast(sourcePosLookupIndex); } - else if (scrParserGlob.delayedSourceIndex >= 0 && (type & Game::SOURCE_TYPE_BREAKPOINT)) + else if (ScrParserGlob.delayedSourceIndex >= 0 && (type & Game::SOURCE_TYPE_BREAKPOINT)) { - scrParserGlob.sourcePosLookup[scrParserGlob.delayedSourceIndex].sourcePos = sourcePos; - scrParserGlob.delayedSourceIndex = -1; + ScrParserGlob.sourcePosLookup[ScrParserGlob.delayedSourceIndex].sourcePos = sourcePos; + ScrParserGlob.delayedSourceIndex = -1; } sourcePosLookup->type |= type; - ++scrParserGlob.currentSourcePosCount; - opcodeLookup->sourcePosCount = static_cast(scrParserGlob.currentSourcePosCount); - ++scrParserGlob.opcodeLookupLen; - ++scrParserGlob.sourcePosLookupLen; + ++ScrParserGlob.currentSourcePosCount; + opcodeLookup->sourcePosCount = static_cast(ScrParserGlob.currentSourcePosCount); + ++ScrParserGlob.opcodeLookupLen; + ++ScrParserGlob.sourcePosLookupLen; } void ScriptError::RemoveOpcodePos() { - if (!developer_) + if (!Developer_) { return; } @@ -135,35 +135,35 @@ namespace Components::GSC return; } - assert(scrParserGlob.opcodeLookup); - assert(scrParserGlob.sourcePosLookup); + assert(ScrParserGlob.opcodeLookup); + assert(ScrParserGlob.sourcePosLookup); assert(Game::scrCompilePub->opcodePos); - assert(scrParserGlob.sourcePosLookupLen); + assert(ScrParserGlob.sourcePosLookupLen); - --scrParserGlob.sourcePosLookupLen; - assert(scrParserGlob.opcodeLookupLen); + --ScrParserGlob.sourcePosLookupLen; + assert(ScrParserGlob.opcodeLookupLen); - --scrParserGlob.opcodeLookupLen; - assert(scrParserGlob.currentSourcePosCount); - --scrParserGlob.currentSourcePosCount; + --ScrParserGlob.opcodeLookupLen; + assert(ScrParserGlob.currentSourcePosCount); + --ScrParserGlob.currentSourcePosCount; - auto* opcodeLookup = &scrParserGlob.opcodeLookup[scrParserGlob.opcodeLookupLen]; + auto* opcodeLookup = &ScrParserGlob.opcodeLookup[ScrParserGlob.opcodeLookupLen]; - assert(scrParserGlob.currentCodePos == Game::scrCompilePub->opcodePos); - assert(opcodeLookup->sourcePosIndex + scrParserGlob.currentSourcePosCount == scrParserGlob.sourcePosLookupLen); - assert(opcodeLookup->codePos == (char*)scrParserGlob.currentCodePos); + assert(ScrParserGlob.currentCodePos == Game::scrCompilePub->opcodePos); + assert(opcodeLookup->sourcePosIndex + ScrParserGlob.currentSourcePosCount == ScrParserGlob.sourcePosLookupLen); + assert(opcodeLookup->codePos == (char*)ScrParserGlob.currentCodePos); - if (!scrParserGlob.currentSourcePosCount) + if (!ScrParserGlob.currentSourcePosCount) { - scrParserGlob.currentCodePos = nullptr; + ScrParserGlob.currentCodePos = nullptr; } - opcodeLookup->sourcePosCount = static_cast(scrParserGlob.currentSourcePosCount); + opcodeLookup->sourcePosCount = static_cast(ScrParserGlob.currentSourcePosCount); } void ScriptError::AddThreadStartOpcodePos(unsigned int sourcePos) { - if (!developer_) + if (!Developer_) { return; } @@ -174,12 +174,12 @@ namespace Components::GSC } else { - assert(scrParserGlob.threadStartSourceIndex >= 0); - auto* sourcePosLookup = &scrParserGlob.sourcePosLookup[scrParserGlob.threadStartSourceIndex]; + assert(ScrParserGlob.threadStartSourceIndex >= 0); + auto* sourcePosLookup = &ScrParserGlob.sourcePosLookup[ScrParserGlob.threadStartSourceIndex]; sourcePosLookup->sourcePos = sourcePos; assert(!sourcePosLookup->type); sourcePosLookup->type = 8; - scrParserGlob.threadStartSourceIndex = -1; + ScrParserGlob.threadStartSourceIndex = -1; } } @@ -188,35 +188,35 @@ namespace Components::GSC const char* startLine; int col; - assert(developer_); - return Scr_GetLineNumInternal(scrParserPub.sourceBufferLookup[bufferIndex].sourceBuf, sourcePos, &startLine, &col, nullptr); + assert(Developer_); + return Scr_GetLineNumInternal(ScrParserPub.sourceBufferLookup[bufferIndex].sourceBuf, sourcePos, &startLine, &col, nullptr); } unsigned int ScriptError::Scr_GetPrevSourcePos(const char* codePos, unsigned int index) { - return scrParserGlob.sourcePosLookup[index + Scr_GetPrevSourcePosOpcodeLookup(codePos)->sourcePosIndex].sourcePos; + return ScrParserGlob.sourcePosLookup[index + Scr_GetPrevSourcePosOpcodeLookup(codePos)->sourcePosIndex].sourcePos; } Game::OpcodeLookup* ScriptError::Scr_GetPrevSourcePosOpcodeLookup(const char* codePos) { assert(Scr_IsInOpcodeMemory(codePos)); - assert(scrParserGlob.opcodeLookup); + assert(ScrParserGlob.opcodeLookup); unsigned int low = 0; - unsigned int high = scrParserGlob.opcodeLookupLen - 1; + unsigned int high = ScrParserGlob.opcodeLookupLen - 1; while (low <= high) { unsigned int middle = (high + low) >> 1; - if (codePos < scrParserGlob.opcodeLookup[middle].codePos) + if (codePos < ScrParserGlob.opcodeLookup[middle].codePos) { high = middle - 1; } else { low = middle + 1; - if (low == scrParserGlob.opcodeLookupLen || codePos < scrParserGlob.opcodeLookup[low].codePos) + if (low == ScrParserGlob.opcodeLookupLen || codePos < ScrParserGlob.opcodeLookup[low].codePos) { - return &scrParserGlob.opcodeLookup[middle]; + return &ScrParserGlob.opcodeLookup[middle]; } } } @@ -279,16 +279,16 @@ namespace Components::GSC unsigned int bufferIndex; assert(Scr_IsInOpcodeMemory(codePos)); - assert(scrParserPub.sourceBufferLookupLen > 0); + assert(ScrParserPub.sourceBufferLookupLen > 0); - for (bufferIndex = scrParserPub.sourceBufferLookupLen - 1; bufferIndex; --bufferIndex) + for (bufferIndex = ScrParserPub.sourceBufferLookupLen - 1; bufferIndex; --bufferIndex) { - if (!scrParserPub.sourceBufferLookup[bufferIndex].codePos) + if (!ScrParserPub.sourceBufferLookup[bufferIndex].codePos) { continue; } - if (scrParserPub.sourceBufferLookup[bufferIndex].codePos > codePos) + if (ScrParserPub.sourceBufferLookup[bufferIndex].codePos > codePos) { continue; } @@ -313,7 +313,7 @@ namespace Components::GSC return; } - if (!developer_) + if (!Developer_) { if (Scr_IsInOpcodeMemory(codePos - 1)) { @@ -326,7 +326,7 @@ namespace Components::GSC if (Game::scrVarPub->programBuffer && Scr_IsInOpcodeMemory(codePos)) { auto bufferIndex = Scr_GetSourceBuffer(codePos - 1); - Scr_PrintSourcePos(channel, scrParserPub.sourceBufferLookup[bufferIndex].buf, scrParserPub.sourceBufferLookup[bufferIndex].sourceBuf, Scr_GetPrevSourcePos(codePos - 1, index)); + Scr_PrintSourcePos(channel, ScrParserPub.sourceBufferLookup[bufferIndex].buf, ScrParserPub.sourceBufferLookup[bufferIndex].sourceBuf, Scr_GetPrevSourcePos(codePos - 1, index)); return; } } @@ -362,7 +362,7 @@ namespace Components::GSC assert(filename); auto lineNum = Scr_GetLineInfo(buf, sourcePos, &col, line, nullptr); - Game::Com_PrintMessage(channel, VA("(file '%s'%s, line %d)\n", filename, scrParserGlob.saveSourceBufferLookup ? " (savegame)" : "", lineNum + 1), 0); + Game::Com_PrintMessage(channel, VA("(file '%s'%s, line %d)\n", filename, ScrParserGlob.saveSourceBufferLookup ? " (savegame)" : "", lineNum + 1), 0); Game::Com_PrintMessage(channel, VA("%s\n", line), 0); for (auto i = 0; i < col; ++i) @@ -400,7 +400,7 @@ namespace Components::GSC bool abort_on_error; const char* dialogMessageSeparator; - if (!developer_) + if (!Developer_) { assert(Scr_IsInOpcodeMemory(codePos)); if (!(*Game::com_developer)->current.enabled) @@ -462,7 +462,7 @@ namespace Components::GSC Game::Com_PrintError(Game::CON_CHANNEL_PARSERSCRIPT, "\n"); Game::Com_PrintError(Game::CON_CHANNEL_PARSERSCRIPT, "******* script compile error *******\n"); - if (!developer_ || !scrParserPub.sourceBuf) + if (!Developer_ || !ScrParserPub.sourceBuf) { Game::Com_PrintError(Game::CON_CHANNEL_PARSERSCRIPT, "%s\n", text); line[0] = '\0'; @@ -472,12 +472,12 @@ namespace Components::GSC } else { - assert(scrParserPub.sourceBuf); + assert(ScrParserPub.sourceBuf); Game::Com_PrintError(Game::CON_CHANNEL_PARSERSCRIPT, "%s: ", text); - Scr_PrintSourcePos(Game::CON_CHANNEL_PARSERSCRIPT, scrParserPub.scriptfilename, scrParserPub.sourceBuf, sourcePos); - auto lineNumber = Scr_GetLineInfo(scrParserPub.sourceBuf, sourcePos, &col, line, nullptr); - Game::Com_Error(Game::ERR_SCRIPT_DROP, "\x15" "script compile error\n%s\n%s(%d):\n %s\n(see console for details)\n", text, scrParserPub.scriptfilename, lineNumber, line); + Scr_PrintSourcePos(Game::CON_CHANNEL_PARSERSCRIPT, ScrParserPub.scriptfilename, ScrParserPub.sourceBuf, sourcePos); + const auto lineNumber = Scr_GetLineInfo(ScrParserPub.sourceBuf, sourcePos, &col, line, nullptr); + Game::Com_Error(Game::ERR_SCRIPT_DROP, "\x15" "script compile error\n%s\n%s(%d):\n %s\n(see console for details)\n", text, ScrParserPub.scriptfilename, lineNumber, line); } } } @@ -504,7 +504,7 @@ namespace Components::GSC Game::Com_Printf(Game::CON_CHANNEL_PARSERSCRIPT, "************************************\n"); - Scr_GetTextSourcePos(scrParserPub.sourceBuf, codePos, line); + Scr_GetTextSourcePos(ScrParserPub.sourceBuf, codePos, line); Game::Com_Error(Game::ERR_SCRIPT_DROP, "\x15" "script compile error\n%s\n%s\n(see console for details)\n", text, line); } @@ -513,10 +513,10 @@ namespace Components::GSC { int col; - if (developer_ && codePos && codePos != Game::g_EndPos && Game::scrVarPub->programBuffer && Scr_IsInOpcodeMemory(codePos)) + if (Developer_ && codePos && codePos != Game::g_EndPos && Game::scrVarPub->programBuffer && Scr_IsInOpcodeMemory(codePos)) { auto bufferIndex = Scr_GetSourceBuffer(codePos - 1); - Scr_GetLineInfo(scrParserPub.sourceBufferLookup[bufferIndex].sourceBuf, Scr_GetPrevSourcePos(codePos - 1, 0), &col, line, nullptr); + Scr_GetLineInfo(ScrParserPub.sourceBufferLookup[bufferIndex].sourceBuf, Scr_GetPrevSourcePos(codePos - 1, 0), &col, line, nullptr); } else { @@ -526,68 +526,68 @@ namespace Components::GSC void ScriptError::Scr_InitOpcodeLookup() { - assert(!scrParserGlob.opcodeLookup); - assert(!scrParserGlob.sourcePosLookup); - assert(!scrParserPub.sourceBufferLookup); + assert(!ScrParserGlob.opcodeLookup); + assert(!ScrParserGlob.sourcePosLookup); + assert(!ScrParserPub.sourceBufferLookup); - if (!developer_) + if (!Developer_) { return; } - scrParserGlob.delayedSourceIndex = -1; - scrParserGlob.opcodeLookupMaxSize = 0; - scrParserGlob.opcodeLookupLen = 0; - scrParserGlob.opcodeLookup = static_cast(Game::Z_VirtualReserve(Game::MAX_OPCODE_LOOKUP_SIZE)); + ScrParserGlob.delayedSourceIndex = -1; + ScrParserGlob.opcodeLookupMaxSize = 0; + ScrParserGlob.opcodeLookupLen = 0; + ScrParserGlob.opcodeLookup = static_cast(Game::Z_VirtualReserve(Game::MAX_OPCODE_LOOKUP_SIZE)); - scrParserGlob.sourcePosLookupMaxSize = 0; - scrParserGlob.sourcePosLookupLen = 0; - scrParserGlob.sourcePosLookup = static_cast(Game::Z_VirtualReserve(Game::MAX_SOURCEPOS_LOOKUP_SIZE)); - scrParserGlob.currentCodePos = nullptr; - scrParserGlob.currentSourcePosCount = 0; - scrParserGlob.sourceBufferLookupMaxSize = 0; + ScrParserGlob.sourcePosLookupMaxSize = 0; + ScrParserGlob.sourcePosLookupLen = 0; + ScrParserGlob.sourcePosLookup = static_cast(Game::Z_VirtualReserve(Game::MAX_SOURCEPOS_LOOKUP_SIZE)); + ScrParserGlob.currentCodePos = nullptr; + ScrParserGlob.currentSourcePosCount = 0; + ScrParserGlob.sourceBufferLookupMaxSize = 0; - scrParserPub.sourceBufferLookupLen = 0; - scrParserPub.sourceBufferLookup = static_cast(Game::Z_VirtualReserve(Game::MAX_SOURCEBUF_LOOKUP_SIZE)); + ScrParserPub.sourceBufferLookupLen = 0; + ScrParserPub.sourceBufferLookup = static_cast(Game::Z_VirtualReserve(Game::MAX_SOURCEBUF_LOOKUP_SIZE)); } void ScriptError::Scr_ShutdownOpcodeLookup() { - if (scrParserGlob.opcodeLookup) + if (ScrParserGlob.opcodeLookup) { - Z_VirtualFree(scrParserGlob.opcodeLookup); - scrParserGlob.opcodeLookup = nullptr; + Z_VirtualFree(ScrParserGlob.opcodeLookup); + ScrParserGlob.opcodeLookup = nullptr; } - if (scrParserGlob.sourcePosLookup) + if (ScrParserGlob.sourcePosLookup) { - Z_VirtualFree(scrParserGlob.sourcePosLookup); - scrParserGlob.sourcePosLookup = nullptr; + Z_VirtualFree(ScrParserGlob.sourcePosLookup); + ScrParserGlob.sourcePosLookup = nullptr; } - if (scrParserPub.sourceBufferLookup) + if (ScrParserPub.sourceBufferLookup) { - for (unsigned int i = 0; i < scrParserPub.sourceBufferLookupLen; ++i) + for (unsigned int i = 0; i < ScrParserPub.sourceBufferLookupLen; ++i) { - Game::Engine::Hunk_FreeDebugMem(scrParserPub.sourceBufferLookup[i].buf); + Game::Engine::Hunk_FreeDebugMem(ScrParserPub.sourceBufferLookup[i].buf); } - Z_VirtualFree(scrParserPub.sourceBufferLookup); - scrParserPub.sourceBufferLookup = nullptr; + Z_VirtualFree(ScrParserPub.sourceBufferLookup); + ScrParserPub.sourceBufferLookup = nullptr; } - if (scrParserGlob.saveSourceBufferLookup) + if (ScrParserGlob.saveSourceBufferLookup) { - for (unsigned int i = 0; i < scrParserGlob.saveSourceBufferLookupLen; ++i) + for (unsigned int i = 0; i < ScrParserGlob.saveSourceBufferLookupLen; ++i) { - if (scrParserGlob.saveSourceBufferLookup[i].sourceBuf) + if (ScrParserGlob.saveSourceBufferLookup[i].sourceBuf) { - Game::Engine::Hunk_FreeDebugMem(scrParserGlob.saveSourceBufferLookup[i].buf); + Game::Engine::Hunk_FreeDebugMem(ScrParserGlob.saveSourceBufferLookup[i].buf); } } - Game::Engine::Hunk_FreeDebugMem(scrParserGlob.saveSourceBufferLookup); - scrParserGlob.saveSourceBufferLookup = nullptr; + Game::Engine::Hunk_FreeDebugMem(ScrParserGlob.saveSourceBufferLookup); + ScrParserGlob.saveSourceBufferLookup = nullptr; } } @@ -612,39 +612,39 @@ namespace Components::GSC Game::SourceBufferInfo* ScriptError::Scr_GetNewSourceBuffer() { - assert(scrParserPub.sourceBufferLookup); + assert(ScrParserPub.sourceBufferLookup); - auto size = sizeof(Game::SourceBufferInfo) * (scrParserPub.sourceBufferLookupLen + 1); - if (size > scrParserGlob.sourceBufferLookupMaxSize) + auto size = sizeof(Game::SourceBufferInfo) * (ScrParserPub.sourceBufferLookupLen + 1); + if (size > ScrParserGlob.sourceBufferLookupMaxSize) { - if (scrParserGlob.sourceBufferLookupMaxSize >= Game::MAX_SOURCEBUF_LOOKUP_SIZE) + if (ScrParserGlob.sourceBufferLookupMaxSize >= Game::MAX_SOURCEBUF_LOOKUP_SIZE) { Game::Sys_Error("MAX_SOURCEBUF_LOOKUP_SIZE exceeded"); } - Game::Z_VirtualCommit((char*)scrParserPub.sourceBufferLookup + scrParserGlob.sourceBufferLookupMaxSize, 0x20000); - scrParserGlob.sourceBufferLookupMaxSize += 0x20000; - assert(size <= scrParserGlob.sourceBufferLookupMaxSize); + Game::Z_VirtualCommit((char*)ScrParserPub.sourceBufferLookup + ScrParserGlob.sourceBufferLookupMaxSize, 0x20000); + ScrParserGlob.sourceBufferLookupMaxSize += 0x20000; + assert(size <= ScrParserGlob.sourceBufferLookupMaxSize); } - return &scrParserPub.sourceBufferLookup[scrParserPub.sourceBufferLookupLen++]; + return &ScrParserPub.sourceBufferLookup[ScrParserPub.sourceBufferLookupLen++]; } void ScriptError::Scr_AddSourceBufferInternal(const char* extFilename, const char* codePos, char* sourceBuf, int len, bool doEolFixup, bool archive) { int i; - if (!scrParserPub.sourceBufferLookup) + if (!ScrParserPub.sourceBufferLookup) { - scrParserPub.sourceBuf = nullptr; + ScrParserPub.sourceBuf = nullptr; return; } assert((len >= -1)); assert((len >= 0) || !sourceBuf); - auto strLen = std::strlen(extFilename) + 1; - auto newLen = strLen + len + 2; + const auto strLen = std::strlen(extFilename) + 1; + const auto newLen = strLen + len + 2; auto* buf = static_cast(Game::Engine::Hunk_AllocDebugMem(static_cast(newLen))); // Scr_AddSourceBufferInternal strcpy(buf, extFilename); @@ -689,7 +689,7 @@ namespace Components::GSC if (sourceBuf2) { - scrParserPub.sourceBuf = sourceBuf2; + ScrParserPub.sourceBuf = sourceBuf2; } } @@ -749,12 +749,12 @@ namespace Components::GSC { char* sourceBuf; - if (archive && scrParserGlob.saveSourceBufferLookup) + if (archive && ScrParserGlob.saveSourceBufferLookup) { - assert(scrParserGlob.saveSourceBufferLookupLen > 0); - --scrParserGlob.saveSourceBufferLookupLen; + assert(ScrParserGlob.saveSourceBufferLookupLen > 0); + --ScrParserGlob.saveSourceBufferLookupLen; - const auto* saveSourceBuffer = scrParserGlob.saveSourceBufferLookup + scrParserGlob.saveSourceBufferLookupLen; + const auto* saveSourceBuffer = ScrParserGlob.saveSourceBufferLookup + ScrParserGlob.saveSourceBufferLookupLen; const auto len = saveSourceBuffer->len; assert(len >= -1); @@ -808,7 +808,7 @@ namespace Components::GSC sprintf_s(extFilename, "%s.gsc", Game::SL_ConvertToString(static_cast(name))); - const auto* oldSourceBuf = scrParserPub.sourceBuf; + const auto* oldSourceBuf = ScrParserPub.sourceBuf; const auto* sourceBuffer = Scr_AddSourceBuffer(Game::SL_ConvertToString(static_cast(name)), extFilename, Game::TempMalloc(0), true); if (!sourceBuffer) @@ -820,8 +820,8 @@ namespace Components::GSC Game::scrAnimPub->animTreeNames = 0; Game::scrCompilePub->far_function_count = 0; - const auto* oldFilename = scrParserPub.scriptfilename; - scrParserPub.scriptfilename = extFilename; + const auto* oldFilename = ScrParserPub.scriptfilename; + ScrParserPub.scriptfilename = extFilename; Game::scrCompilePub->in_ptr = "+"; Game::scrCompilePub->in_ptr_valid = false; @@ -837,8 +837,8 @@ namespace Components::GSC Game::RemoveVariable(Game::scrCompilePub->scriptsCount, name); - scrParserPub.scriptfilename = oldFilename; - scrParserPub.sourceBuf = oldSourceBuf; + ScrParserPub.scriptfilename = oldFilename; + ScrParserPub.sourceBuf = oldSourceBuf; Game::scrAnimPub->animTreeNames = oldAnimTreeNames; @@ -848,7 +848,7 @@ namespace Components::GSC void ScriptError::Scr_Settings_Hk([[maybe_unused]] int developer, int developer_script, int abort_on_error) { assert(!abort_on_error || developer); - developer_ = (*Game::com_developer)->current.enabled; + Developer_ = (*Game::com_developer)->current.enabled; Game::scrVarPub->developer_script = developer_script != 0; Game::scrVmPub->abort_on_error = abort_on_error != 0; } diff --git a/src/Components/Modules/GSC/ScriptError.hpp b/src/Components/Modules/GSC/ScriptError.hpp index 3cc61caa..181e6752 100644 --- a/src/Components/Modules/GSC/ScriptError.hpp +++ b/src/Components/Modules/GSC/ScriptError.hpp @@ -14,10 +14,10 @@ namespace Components::GSC private: // Replacement for variables not present in currently available structs - static int developer_; + static int Developer_; - static Game::scrParserGlob_t scrParserGlob; - static Game::scrParserPub_t scrParserPub; + static Game::scrParserGlob_t ScrParserGlob; + static Game::scrParserPub_t ScrParserPub; static void AddOpcodePos(unsigned int sourcePos, int type); static void RemoveOpcodePos(); diff --git a/src/Components/Modules/GSC/ScriptExtension.cpp b/src/Components/Modules/GSC/ScriptExtension.cpp index e68220ae..a45ffd72 100644 --- a/src/Components/Modules/GSC/ScriptExtension.cpp +++ b/src/Components/Modules/GSC/ScriptExtension.cpp @@ -1,4 +1,7 @@ #include + +#include + #include "ScriptExtension.hpp" #include "Script.hpp" diff --git a/src/Components/Modules/GSC/UserInfo.cpp b/src/Components/Modules/GSC/UserInfo.cpp index aede628b..d31e5e9b 100644 --- a/src/Components/Modules/GSC/UserInfo.cpp +++ b/src/Components/Modules/GSC/UserInfo.cpp @@ -1,6 +1,8 @@ #include #include +#include + #include "Script.hpp" #include "UserInfo.hpp" diff --git a/src/Components/Modules/Logger.cpp b/src/Components/Modules/Logger.cpp index 033f377b..d575efe3 100644 --- a/src/Components/Modules/Logger.cpp +++ b/src/Components/Modules/Logger.cpp @@ -1,5 +1,7 @@ #include + #include "Console.hpp" +#include "Events.hpp" namespace Components { diff --git a/src/Components/Modules/MapRotation.cpp b/src/Components/Modules/MapRotation.cpp index 0d8f463a..e244c6b4 100644 --- a/src/Components/Modules/MapRotation.cpp +++ b/src/Components/Modules/MapRotation.cpp @@ -1,4 +1,6 @@ #include + +#include "Events.hpp" #include "MapRotation.hpp" #include "Party.hpp" diff --git a/src/Components/Modules/PlayerMovement.cpp b/src/Components/Modules/PlayerMovement.cpp index 371b9847..010fd8a7 100644 --- a/src/Components/Modules/PlayerMovement.cpp +++ b/src/Components/Modules/PlayerMovement.cpp @@ -1,4 +1,6 @@ #include + +#include "Events.hpp" #include "PlayerMovement.hpp" #include "GSC/Script.hpp" diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index d7074420..52a5cc25 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -1,6 +1,7 @@ #include #include +#include "Events.hpp" #include "RCon.hpp" #include "Party.hpp" diff --git a/src/Components/Modules/Renderer.cpp b/src/Components/Modules/Renderer.cpp index 4eed9557..086a9446 100644 --- a/src/Components/Modules/Renderer.cpp +++ b/src/Components/Modules/Renderer.cpp @@ -1,5 +1,7 @@ #include +#include "Events.hpp" + namespace Components { Utils::Signal Renderer::BackendFrameSignal; diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index d4252115..06823b2e 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -2,6 +2,7 @@ #include #include "Discovery.hpp" +#include "Events.hpp" #include "Node.hpp" #include "Party.hpp" #include "ServerList.hpp" diff --git a/src/Components/Modules/StartupMessages.cpp b/src/Components/Modules/StartupMessages.cpp index 09bae507..fba6dbba 100644 --- a/src/Components/Modules/StartupMessages.cpp +++ b/src/Components/Modules/StartupMessages.cpp @@ -1,4 +1,6 @@ #include + +#include "Events.hpp" #include "StartupMessages.hpp" namespace Components diff --git a/src/Components/Modules/UIFeeder.cpp b/src/Components/Modules/UIFeeder.cpp index e7d43c38..2db429de 100644 --- a/src/Components/Modules/UIFeeder.cpp +++ b/src/Components/Modules/UIFeeder.cpp @@ -1,4 +1,6 @@ #include + +#include "Events.hpp" #include "UIFeeder.hpp" namespace Components diff --git a/src/Components/Modules/Voice.cpp b/src/Components/Modules/Voice.cpp index c7bf5448..7d7fd1cf 100644 --- a/src/Components/Modules/Voice.cpp +++ b/src/Components/Modules/Voice.cpp @@ -1,5 +1,7 @@ #include + #include "Chat.hpp" +#include "Events.hpp" #include "Voice.hpp" namespace Components diff --git a/src/Utils/Utils.hpp b/src/Utils/Utils.hpp index 252def02..d75e1130 100644 --- a/src/Utils/Utils.hpp +++ b/src/Utils/Utils.hpp @@ -67,12 +67,6 @@ namespace Utils } } - template - bool Contains(const std::vector* haystack, T needle) - { - return std::ranges::find(*haystack, needle) != haystack->end(); - } - template using Slot = std::function; template class Signal