refactor: use new template
This commit is contained in:
@@ -1,32 +0,0 @@
|
|||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <ll/api/plugin/NativePlugin.h>
|
|
||||||
|
|
||||||
#include "Plugin.h"
|
|
||||||
|
|
||||||
namespace plugin {
|
|
||||||
|
|
||||||
// The global plugin instance.
|
|
||||||
std::unique_ptr<Plugin> plugin = nullptr;
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
_declspec(dllexport) bool ll_plugin_load(ll::plugin::NativePlugin& self) {
|
|
||||||
plugin = std::make_unique<plugin::Plugin>(self);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @warning Unloading the plugin may cause a crash if the plugin has not released all of its
|
|
||||||
/// resources. If you are unsure, keep this function commented out.
|
|
||||||
// _declspec(dllexport) bool ll_plugin_unload(ll::plugin::Plugin&) {
|
|
||||||
// plugin.reset();
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
_declspec(dllexport) bool ll_plugin_enable(ll::plugin::NativePlugin&) { return plugin->enable(); }
|
|
||||||
|
|
||||||
_declspec(dllexport) bool ll_plugin_disable(ll::plugin::NativePlugin&) { return plugin->disable(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace plugin
|
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
#include "Entry.h"
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
ll::Logger logger(PLUGIN_NAME);
|
||||||
|
|
||||||
|
namespace GMLIB_LegacyRemoteCallApi {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
std::unique_ptr<std::reference_wrapper<ll::plugin::NativePlugin>>
|
||||||
|
selfPluginInstance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
|
||||||
|
auto disable(ll::plugin::NativePlugin& /*self*/) -> bool { return false; }
|
||||||
|
|
||||||
|
auto enable(ll::plugin::NativePlugin& /*self*/) -> bool { return true; }
|
||||||
|
|
||||||
|
auto load(ll::plugin::NativePlugin& self) -> bool {
|
||||||
|
selfPluginInstance = std::make_unique<std::reference_wrapper<ll::plugin::NativePlugin>>(self);
|
||||||
|
Export_Legacy_GMLib_ModAPI();
|
||||||
|
Export_Legacy_GMLib_ServerAPI();
|
||||||
|
Export_Compatibility_API();
|
||||||
|
ExportPAPI();
|
||||||
|
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||||
|
logger.info("Version: {}", LIB_VERSION.asString());
|
||||||
|
logger.info("Author: GroupMountain");
|
||||||
|
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto unload(ll::plugin::NativePlugin& self) -> bool { return false; }
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
auto getSelfPluginInstance() -> ll::plugin::NativePlugin& {
|
||||||
|
if (!selfPluginInstance) {
|
||||||
|
throw std::runtime_error("selfPluginInstance is null");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *selfPluginInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace GMLIB_LegacyRemoteCallApi
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
_declspec(dllexport) auto ll_plugin_disable(ll::plugin::NativePlugin& self) -> bool {
|
||||||
|
return GMLIB_LegacyRemoteCallApi::disable(self);
|
||||||
|
}
|
||||||
|
_declspec(dllexport) auto ll_plugin_enable(ll::plugin::NativePlugin& self) -> bool {
|
||||||
|
return GMLIB_LegacyRemoteCallApi::enable(self);
|
||||||
|
}
|
||||||
|
_declspec(dllexport) auto ll_plugin_load(ll::plugin::NativePlugin& self) -> bool {
|
||||||
|
return GMLIB_LegacyRemoteCallApi::load(self);
|
||||||
|
}
|
||||||
|
_declspec(dllexport) auto ll_plugin_unload(ll::plugin::NativePlugin& self) -> bool {
|
||||||
|
return GMLIB_LegacyRemoteCallApi::unload(self);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <ll/api/plugin/NativePlugin.h>
|
||||||
|
|
||||||
|
namespace GMLIB_LegacyRemoteCallApi {
|
||||||
|
|
||||||
|
[[nodiscard]] auto getSelfPluginInstance() -> ll::plugin::NativePlugin&;
|
||||||
|
|
||||||
|
} // namespace GMLIB_LegacyRemoteCallApi
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
#include <RemoteCallAPI.h>
|
#include <RemoteCallAPI.h>
|
||||||
|
|
||||||
#define PLUGIN_NAME "GMLIB-LRCA"
|
#define PLUGIN_NAME "GMLIB-LRCA"
|
||||||
#define LIB_VERSION SemVersion(0, 8, 4, "", "")
|
#define LIB_VERSION SemVersion(0, 9, 0, "", "")
|
||||||
|
|
||||||
extern ll::Logger logger;
|
extern ll::Logger logger;
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
#include "Plugin.h"
|
|
||||||
#include "Global.h"
|
|
||||||
|
|
||||||
ll::Logger logger(PLUGIN_NAME);
|
|
||||||
|
|
||||||
namespace plugin {
|
|
||||||
|
|
||||||
Plugin::Plugin(ll::plugin::NativePlugin& self) : mSelf(self) {
|
|
||||||
// Code for loading the plugin goes here.
|
|
||||||
Export_Legacy_GMLib_ModAPI();
|
|
||||||
Export_Legacy_GMLib_ServerAPI();
|
|
||||||
Export_Compatibility_API();
|
|
||||||
ExportPAPI();
|
|
||||||
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
|
||||||
logger.info("Version: {}", LIB_VERSION.asString());
|
|
||||||
logger.info("Author: GroupMountain");
|
|
||||||
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Plugin::enable() {
|
|
||||||
// Code for enabling the plugin goes here.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Plugin::disable() {
|
|
||||||
// Code for disabling the plugin goes here.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace plugin
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <ll/api/plugin/NativePlugin.h>
|
|
||||||
|
|
||||||
namespace plugin {
|
|
||||||
|
|
||||||
class Plugin {
|
|
||||||
public:
|
|
||||||
explicit Plugin(ll::plugin::NativePlugin& self);
|
|
||||||
|
|
||||||
Plugin(Plugin&&) = delete;
|
|
||||||
Plugin(const Plugin&) = delete;
|
|
||||||
Plugin& operator=(Plugin&&) = delete;
|
|
||||||
Plugin& operator=(const Plugin&) = delete;
|
|
||||||
|
|
||||||
~Plugin() = default;
|
|
||||||
|
|
||||||
/// @return True if the plugin is enabled successfully.
|
|
||||||
bool enable();
|
|
||||||
|
|
||||||
/// @return True if the plugin is disabled successfully.
|
|
||||||
bool disable();
|
|
||||||
|
|
||||||
private:
|
|
||||||
ll::plugin::NativePlugin& mSelf;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace plugin
|
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 2,
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "0.8.4",
|
"version": "0.9.0",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
"library"
|
"library"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.8.4/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.9.0/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.8.5"
|
"github.com/GroupMountain/GMLIB": ">=0.9.0"
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"place": [
|
"place": [
|
||||||
|
|||||||
Reference in New Issue
Block a user