diff options
author | Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> | 2023-12-27 00:32:01 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-27 01:32:01 +0100 |
commit | f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287 (patch) | |
tree | 90f2c6a4885dbd181799e2325cf33588697674e1 /primedev/plugins/pluginbackend.cpp | |
parent | bb8ed59f6891b1196c5f5bbe7346cd171c8215fa (diff) | |
download | NorthstarLauncher-1.21.2-rc3.tar.gz NorthstarLauncher-1.21.2-rc3.zip |
Folder restructuring from primedev (#624)v1.21.2-rc3v1.21.2
Copies of over the primedev folder structure for easier cherry-picking of further changes
Co-authored-by: F1F7Y <filip.bartos07@proton.me>
Diffstat (limited to 'primedev/plugins/pluginbackend.cpp')
-rw-r--r-- | primedev/plugins/pluginbackend.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/primedev/plugins/pluginbackend.cpp b/primedev/plugins/pluginbackend.cpp new file mode 100644 index 00000000..850394ac --- /dev/null +++ b/primedev/plugins/pluginbackend.cpp @@ -0,0 +1,50 @@ +#include "pluginbackend.h" +#include "plugin_abi.h" +#include "server/serverpresence.h" +#include "masterserver/masterserver.h" +#include "squirrel/squirrel.h" +#include "plugins.h" + +#include "core/convar/concommand.h" + +#include <filesystem> + +#define EXPORT extern "C" __declspec(dllexport) + +AUTOHOOK_INIT() + +PluginCommunicationHandler* g_pPluginCommunicationhandler; + +static PluginDataRequest storedRequest {PluginDataRequestType::END, (PluginRespondDataCallable) nullptr}; + +void PluginCommunicationHandler::RunFrame() +{ + std::lock_guard<std::mutex> lock(requestMutex); + if (!requestQueue.empty()) + { + storedRequest = requestQueue.front(); + switch (storedRequest.type) + { + default: + spdlog::error("{} was called with invalid request type '{}'", __FUNCTION__, static_cast<int>(storedRequest.type)); + } + requestQueue.pop(); + } +} + +void PluginCommunicationHandler::PushRequest(PluginDataRequestType type, PluginRespondDataCallable func) +{ + std::lock_guard<std::mutex> lock(requestMutex); + requestQueue.push(PluginDataRequest {type, func}); +} + +void InformPluginsDLLLoad(fs::path dllPath, void* address) +{ + std::string dllName = dllPath.filename().string(); + + void* data = NULL; + if (strncmp(dllName.c_str(), "engine.dll", 10) == 0) + data = &g_pPluginCommunicationhandler->m_sEngineData; + + g_pPluginManager->InformDLLLoad(dllName.c_str(), data, address); +} |