diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-10-01 17:16:42 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-10-01 17:16:42 +0100 |
commit | 51df18abbc0c344b56f88e0a66b6b46d6aca375c (patch) | |
tree | 1ce680cb9134273870373134f845633e2c390bde /NorthstarDedicatedTest/squirrel.cpp | |
parent | 1ff8e068e62d095775ef2ae54d3685d89238f28c (diff) | |
download | NorthstarLauncher-51df18abbc0c344b56f88e0a66b6b46d6aca375c.tar.gz NorthstarLauncher-51df18abbc0c344b56f88e0a66b6b46d6aca375c.zip |
Revert "small modmanager refactors"
This reverts commit 1ff8e068e62d095775ef2ae54d3685d89238f28c.
Diffstat (limited to 'NorthstarDedicatedTest/squirrel.cpp')
-rw-r--r-- | NorthstarDedicatedTest/squirrel.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/NorthstarDedicatedTest/squirrel.cpp b/NorthstarDedicatedTest/squirrel.cpp index ffd9a816..85e26c45 100644 --- a/NorthstarDedicatedTest/squirrel.cpp +++ b/NorthstarDedicatedTest/squirrel.cpp @@ -85,9 +85,9 @@ sq_getfloatType ServerSq_getfloat; template<Context context> void ExecuteCodeCommand(const CCommand& args); // inits -std::unique_ptr<SquirrelManager<CLIENT>> g_ClientSquirrelManager; -std::unique_ptr<SquirrelManager<SERVER>> g_ServerSquirrelManager; -std::unique_ptr<SquirrelManager<UI>> g_UISquirrelManager; +SquirrelManager<CLIENT>* g_ClientSquirrelManager; +SquirrelManager<SERVER>* g_ServerSquirrelManager; +SquirrelManager<UI>* g_UISquirrelManager; SQInteger NSTestFunc(void* sqvm) { @@ -102,13 +102,13 @@ void InitialiseClientSquirrel(HMODULE baseAddress) HookEnabler hook; // client inits - g_ClientSquirrelManager = std::make_unique<SquirrelManager<CLIENT>>(); + g_ClientSquirrelManager = new SquirrelManager<CLIENT>(); ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x12B00, &SQPrintHook<CLIENT>, reinterpret_cast<LPVOID*>(&ClientSQPrint)); // client print function RegisterConCommand("script_client", ExecuteCodeCommand<CLIENT>, "Executes script code on the client vm", FCVAR_CLIENTDLL); // ui inits - g_UISquirrelManager = std::make_unique<SquirrelManager<UI>>(); + g_UISquirrelManager = new SquirrelManager<UI>(); ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x12BA0, &SQPrintHook<UI>, reinterpret_cast<LPVOID*>(&UISQPrint)); // ui print function RegisterConCommand("script_ui", ExecuteCodeCommand<UI>, "Executes script code on the ui vm", FCVAR_CLIENTDLL); @@ -139,7 +139,7 @@ void InitialiseClientSquirrel(HMODULE baseAddress) void InitialiseServerSquirrel(HMODULE baseAddress) { - g_ServerSquirrelManager = std::make_unique<SquirrelManager<SERVER>>(); + g_ServerSquirrelManager = new SquirrelManager<SERVER>(); g_ServerSquirrelManager->AddFuncRegistration("void", "SavePdataForEntityIndex", "int i", "idk", NSTestFunc); HookEnabler hook; @@ -278,16 +278,16 @@ template<Context context> char CallScriptInitCallbackHook(void* sqvm, const char // todo: we need to verify if RunOn is valid for current state before calling callbacks if (shouldCallCustomCallbacks) { - for (Mod mod : g_ModManager->m_loadedMods) + for (Mod* mod : g_ModManager->m_loadedMods) { - for (ModScript script : mod.Scripts) + for (ModScript* script : mod->Scripts) { - for (ModScriptCallback modCallback : script.Callbacks) + for (ModScriptCallback* modCallback : script->Callbacks) { - if (modCallback.Context == realContext && modCallback.BeforeCallback.length()) + if (modCallback->Context == realContext && modCallback->BeforeCallback.length()) { - spdlog::info("Running custom {} script callback \"{}\"", GetContextName(realContext), modCallback.BeforeCallback); - ClientCallScriptInitCallback(sqvm, modCallback.BeforeCallback.c_str()); + spdlog::info("Running custom {} script callback \"{}\"", GetContextName(realContext), modCallback->BeforeCallback); + ClientCallScriptInitCallback(sqvm, modCallback->BeforeCallback.c_str()); } } } @@ -302,16 +302,16 @@ template<Context context> char CallScriptInitCallbackHook(void* sqvm, const char // run after callbacks if (shouldCallCustomCallbacks) { - for (Mod mod : g_ModManager->m_loadedMods) + for (Mod* mod : g_ModManager->m_loadedMods) { - for (ModScript script : mod.Scripts) + for (ModScript* script : mod->Scripts) { - for (ModScriptCallback modCallback : script.Callbacks) + for (ModScriptCallback* modCallback : script->Callbacks) { - if (modCallback.Context == realContext && modCallback.AfterCallback.length()) + if (modCallback->Context == realContext && modCallback->AfterCallback.length()) { - spdlog::info("Running custom {} script callback \"{}\"", GetContextName(realContext), modCallback.AfterCallback); - ClientCallScriptInitCallback(sqvm, modCallback.AfterCallback.c_str()); + spdlog::info("Running custom {} script callback \"{}\"", GetContextName(realContext), modCallback->AfterCallback); + ClientCallScriptInitCallback(sqvm, modCallback->AfterCallback.c_str()); } } } @@ -327,16 +327,16 @@ template<Context context> char CallScriptInitCallbackHook(void* sqvm, const char // todo: we need to verify if RunOn is valid for current state before calling callbacks if (shouldCallCustomCallbacks) { - for (Mod mod : g_ModManager->m_loadedMods) + for (Mod* mod : g_ModManager->m_loadedMods) { - for (ModScript script : mod.Scripts) + for (ModScript* script : mod->Scripts) { - for (ModScriptCallback modCallback : script.Callbacks) + for (ModScriptCallback* modCallback : script->Callbacks) { - if (modCallback.Context == SERVER && modCallback.BeforeCallback.length()) + if (modCallback->Context == SERVER && modCallback->BeforeCallback.length()) { - spdlog::info("Running custom {} script callback \"{}\"", GetContextName(context), modCallback.BeforeCallback); - ServerCallScriptInitCallback(sqvm, modCallback.BeforeCallback.c_str()); + spdlog::info("Running custom {} script callback \"{}\"", GetContextName(context), modCallback->BeforeCallback); + ServerCallScriptInitCallback(sqvm, modCallback->BeforeCallback.c_str()); } } } @@ -351,16 +351,16 @@ template<Context context> char CallScriptInitCallbackHook(void* sqvm, const char // run after callbacks if (shouldCallCustomCallbacks) { - for (Mod mod : g_ModManager->m_loadedMods) + for (Mod* mod : g_ModManager->m_loadedMods) { - for (ModScript script : mod.Scripts) + for (ModScript* script : mod->Scripts) { - for (ModScriptCallback modCallback : script.Callbacks) + for (ModScriptCallback* modCallback : script->Callbacks) { - if (modCallback.Context == SERVER && modCallback.AfterCallback.length()) + if (modCallback->Context == SERVER && modCallback->AfterCallback.length()) { - spdlog::info("Running custom {} script callback \"{}\"", GetContextName(context), modCallback.AfterCallback); - ServerCallScriptInitCallback(sqvm, modCallback.AfterCallback.c_str()); + spdlog::info("Running custom {} script callback \"{}\"", GetContextName(context), modCallback->AfterCallback); + ServerCallScriptInitCallback(sqvm, modCallback->AfterCallback.c_str()); } } } |