Skip to content

Commit

Permalink
Move plugin communication handler init out of plugin manager init (#581)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ASpoonPlaysGames authored Oct 15, 2023
1 parent fb7b538 commit 98af0dc
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 11 deletions.
2 changes: 2 additions & 0 deletions NorthstarDLL/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -62,6 +63,7 @@ bool InitialiseNorthstar()

g_pGameStatePresence = new GameStatePresence();
g_pPluginManager = new PluginManager();
g_pPluginCommunicationhandler = new PluginCommunicationHandler();
g_pPluginManager->LoadPlugins();

InitialiseSquirrelManagers();
Expand Down
6 changes: 0 additions & 6 deletions NorthstarDLL/plugins/pluginbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex> lock(requestMutex);
Expand Down
4 changes: 1 addition & 3 deletions NorthstarDLL/plugins/pluginbackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ class PluginCommunicationHandler
void GeneratePresenceObjects();

public:
std::queue<PluginDataRequest> requestQueue;
std::queue<PluginDataRequest> requestQueue = {};
std::mutex requestMutex;

PluginEngineData m_sEngineData {};
};

void init_plugincommunicationhandler();

extern PluginCommunicationHandler* g_pPluginCommunicationhandler;
2 changes: 0 additions & 2 deletions NorthstarDLL/plugins/plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 98af0dc

Please sign in to comment.