chore: use new template

This commit is contained in:
Tsubasa6848
2024-03-23 19:54:55 +08:00
Unverified
parent 35fc8a7a4f
commit 0034f21b98
9 changed files with 81 additions and 57 deletions
+8 -34
View File
@@ -5,17 +5,12 @@ ll::Logger logger(PLUGIN_NAME);
namespace GMLIB_LegacyRemoteCallApi {
namespace {
std::unique_ptr<LRCA>& LRCA::getInstance() {
static std::unique_ptr<LRCA> instance;
return instance;
}
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 true; }
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);
bool LRCA::load() {
Export_Legacy_GMLib_ModAPI();
Export_Legacy_GMLib_ServerAPI();
Export_Compatibility_API();
@@ -28,31 +23,10 @@ auto load(ll::plugin::NativePlugin& self) -> bool {
return true;
}
auto unload(ll::plugin::NativePlugin& self) -> bool { return false; }
bool LRCA::enable() { return true; }
} // namespace
auto getSelfPluginInstance() -> ll::plugin::NativePlugin& {
if (!selfPluginInstance) {
throw std::runtime_error("selfPluginInstance is null");
}
return *selfPluginInstance;
}
bool LRCA::disable() { return true; }
} // 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);
}
}
LL_REGISTER_PLUGIN(GMLIB_LegacyRemoteCallApi::LRCA, GMLIB_LegacyRemoteCallApi::LRCA::getInstance());