diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2023-09-10 23:54:22 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2023-09-10 23:54:22 +0200 |
commit | 13df46ba41efe2d94e3dbec240ff0889ac054eb7 (patch) | |
tree | f76ba0d5e109973429caef5e2001f99c3fdd7a85 /src | |
parent | ac01bde6b9673b80dd225be3edebbe2255d9ebd2 (diff) | |
download | SouthRPC-13df46ba41efe2d94e3dbec240ff0889ac054eb7.tar.gz SouthRPC-13df46ba41efe2d94e3dbec240ff0889ac054eb7.zip |
MSVC
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/ns_plugin.h | 6 | ||||
-rw-r--r-- | src/plugin.cpp | 22 | ||||
-rw-r--r-- | src/plugin.h | 1 |
4 files changed, 28 insertions, 2 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a7c651..a55c541 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -find_package(spdlog REQUIRED) find_package(json-c REQUIRED) plugin_manifest(SouthRPC name "SouthRPC") diff --git a/src/ns_plugin.h b/src/ns_plugin.h index f1567a4..73c805e 100644 --- a/src/ns_plugin.h +++ b/src/ns_plugin.h @@ -1,7 +1,10 @@ #ifndef NS_PLUGIN_H #define NS_PLUGIN_H +#define WIN32_LEAN_AND_MEAN + // Needed to bootstrap plugin abi +#include <windows.h> #include <windef.h> #include <mutex> #include <optional> @@ -21,5 +24,8 @@ typedef void (*ConCommandConstructorType)(ConCommand* newCommand, const char* name, FnCommandCallback_t callback, const char* helpString, int flags, void* parent); typedef void (*ConVarMallocType)(void* pConVarMaloc, int a2, int a3); typedef void (*ConVarRegisterType)(ConVar* pConVar, const char* pszName, const char* pszDefaultValue, int nFlags, const char* pszHelpString, bool bMin, float fMin, bool bMax, float fMax, void* pCallback); +extern "C" { + typedef void* (*extern_CreateObjectFunc)(ObjectType type); +} #endif diff --git a/src/plugin.cpp b/src/plugin.cpp index a1098da..d13ffc6 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -21,4 +21,24 @@ void Plugin::LoadEngineData(void* data) this->engine_data = static_cast<EngineData*>(data); spdlog::info("Engine data loaded"); -}
\ No newline at end of file + + this->RegisterConCommand("south_test", [](const CCommand& command){ spdlog::info("Gaming"); }, "", 0); +} + +void Plugin::RegisterConCommand(const char* name, FnCommandCallback_t callback, const char* helpString, int flags) +{ + if (!this->engine_data) + { + return; + } + + spdlog::info("Registering ConCommand {}", name); + + extern_CreateObjectFunc createObject = static_cast<extern_CreateObjectFunc>(this->funcs->createObject); + + spdlog::info("Creating Object"); + void* command = createObject(ObjectType::CONCOMMANDS); + + spdlog::info("Constructing Command"); + this->engine_data->ConCommandConstructor((ConCommand*)command, name, callback, helpString, flags, nullptr); +} diff --git a/src/plugin.h b/src/plugin.h index e22798b..2af5f30 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -27,6 +27,7 @@ class Plugin { ~Plugin(); void LoadEngineData(void* data); + void RegisterConCommand(const char* name, FnCommandCallback_t callback, const char* helpString, int flags); }; #endif
\ No newline at end of file |