From 802fd2ca121f7f2f794072d77be70e8ed96ebd5e Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Sun, 26 Dec 2021 16:51:33 +0100 Subject: [PATCH] RMG-Core: add a version of CoreInit() for plugins --- Source/RMG-Core/Core.cpp | 24 ++++++++++++++++++++++++ Source/RMG-Core/Core.hpp | 15 +++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Source/RMG-Core/Core.cpp b/Source/RMG-Core/Core.cpp index ce089e97..015b159b 100644 --- a/Source/RMG-Core/Core.cpp +++ b/Source/RMG-Core/Core.cpp @@ -139,6 +139,30 @@ bool CoreInit(void) return true; } +bool CoreInit(m64p_dynlib_handle handle) +{ + std::string error; + bool ret = false; + + ret = m64p::Core.Hook(handle); + if (!ret) + { + error = m64p::Core.GetLastError(); + CoreSetError(error); + return false; + } + + ret = m64p::Config.Hook(handle); + if (!ret) + { + error = m64p::Config.GetLastError(); + CoreSetError(error); + return false; + } + + return true; +} + void CoreShutdown(void) { CorePluginsShutdown(); diff --git a/Source/RMG-Core/Core.hpp b/Source/RMG-Core/Core.hpp index bda68e6f..254e08ea 100644 --- a/Source/RMG-Core/Core.hpp +++ b/Source/RMG-Core/Core.hpp @@ -22,11 +22,26 @@ #include "Error.hpp" #include "Video.hpp" #include "Key.hpp" +#ifdef CORE_PLUGIN +#include "m64p/api/m64p_common.h" +#include "m64p/api/m64p_custom.h" +#include "m64p/api/m64p_types.h" +#include "m64p/api/m64p_config.h" +#include "m64p/api/m64p_plugin.h" +#include "m64p/api/version.h" +#endif // CORE_PLUGIN + // initializes the core library, // returns false when failed bool CoreInit(void); +#ifdef CORE_PLUGIN +// initializes the core library for plugins, +// returns false when failed +bool CoreInit(m64p_dynlib_handle handle); +#endif // CORE_PLUGIN + // shuts down the core library void CoreShutdown(void);