From 98af0dcbb45972d4af22ea0d26a3a2c518ea9b13 Mon Sep 17 00:00:00 2001 From: Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Sun, 15 Oct 2023 20:57:41 +0100 Subject: Move plugin communication handler init out of plugin manager init (#581) Plugin state requires this to be initialised even if `-noplugins` is passed, but if `-noplugins` is passed, it doesn't get initialised. Moving this to `dllmain` guarantees that it is initialised properly and prevents #580 --- NorthstarDLL/dllmain.cpp | 2 ++ NorthstarDLL/plugins/pluginbackend.cpp | 6 ------ NorthstarDLL/plugins/pluginbackend.h | 4 +--- NorthstarDLL/plugins/plugins.cpp | 2 -- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/NorthstarDLL/dllmain.cpp b/NorthstarDLL/dllmain.cpp index cfcc1a8c..1a80b3ed 100644 --- a/NorthstarDLL/dllmain.cpp +++ b/NorthstarDLL/dllmain.cpp @@ -5,6 +5,7 @@ #include "config/profile.h" #include "plugins/plugin_abi.h" #include "plugins/plugins.h" +#include "plugins/pluginbackend.h" #include "util/version.h" #include "squirrel/squirrel.h" #include "shared/gamepresence.h" @@ -62,6 +63,7 @@ bool InitialiseNorthstar() g_pGameStatePresence = new GameStatePresence(); g_pPluginManager = new PluginManager(); + g_pPluginCommunicationhandler = new PluginCommunicationHandler(); g_pPluginManager->LoadPlugins(); InitialiseSquirrelManagers(); diff --git a/NorthstarDLL/plugins/pluginbackend.cpp b/NorthstarDLL/plugins/pluginbackend.cpp index 091ddd2f..f9766235 100644 --- a/NorthstarDLL/plugins/pluginbackend.cpp +++ b/NorthstarDLL/plugins/pluginbackend.cpp @@ -15,12 +15,6 @@ PluginCommunicationHandler* g_pPluginCommunicationhandler; static PluginDataRequest storedRequest {PluginDataRequestType::END, (PluginRespondDataCallable) nullptr}; -void init_plugincommunicationhandler() -{ - g_pPluginCommunicationhandler = new PluginCommunicationHandler; - g_pPluginCommunicationhandler->requestQueue = {}; -} - void PluginCommunicationHandler::RunFrame() { std::lock_guard lock(requestMutex); diff --git a/NorthstarDLL/plugins/pluginbackend.h b/NorthstarDLL/plugins/pluginbackend.h index 898b3a99..bcbccbd8 100644 --- a/NorthstarDLL/plugins/pluginbackend.h +++ b/NorthstarDLL/plugins/pluginbackend.h @@ -33,12 +33,10 @@ class PluginCommunicationHandler void GeneratePresenceObjects(); public: - std::queue requestQueue; + std::queue requestQueue = {}; std::mutex requestMutex; PluginEngineData m_sEngineData {}; }; -void init_plugincommunicationhandler(); - extern PluginCommunicationHandler* g_pPluginCommunicationhandler; diff --git a/NorthstarDLL/plugins/plugins.cpp b/NorthstarDLL/plugins/plugins.cpp index 0c4c7fd6..5e28e12d 100644 --- a/NorthstarDLL/plugins/plugins.cpp +++ b/NorthstarDLL/plugins/plugins.cpp @@ -226,8 +226,6 @@ bool PluginManager::LoadPlugins() funcs.relayInviteFunc = nullptr; funcs.createObject = CreateObject; - init_plugincommunicationhandler(); - data.version = ns_version.c_str(); data.northstarModule = g_NorthstarModule; -- cgit v1.2.3