From ad7e68e04b017e24ffceb3b128527e2a4d1eec2d Mon Sep 17 00:00:00 2001 From: LordBombardir Date: Wed, 1 Jan 2025 12:34:45 +0300 Subject: [PATCH] Finally fix --- src/mod/Main.cpp | 10 +++++----- src/mod/Main.h | 2 +- xmake.lua | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/mod/Main.cpp b/src/mod/Main.cpp index 3f0651a..839a1b5 100644 --- a/src/mod/Main.cpp +++ b/src/mod/Main.cpp @@ -4,13 +4,13 @@ #include "manager/command/CommandManager.h" #include "manager/lang/LanguageManager.h" #include -#include namespace power_ranks { -static std::unique_ptr
instance; - -Main& Main::getInstance() { return *instance; } +Main& Main::getInstance() { + static Main instance; + return instance; +} bool Main::load() { getSelf().getLogger().info("The mod is loading..."); @@ -54,4 +54,4 @@ bool Main::disable() { } // namespace power_ranks -LL_REGISTER_MOD(power_ranks::Main, *power_ranks::instance); +LL_REGISTER_MOD(power_ranks::Main, power_ranks::Main::getInstance()); diff --git a/src/mod/Main.h b/src/mod/Main.h index 0370c3b..b2c5844 100644 --- a/src/mod/Main.h +++ b/src/mod/Main.h @@ -9,7 +9,7 @@ class Main { public: static Main& getInstance(); - Main(ll::mod::NativeMod& self) : mSelf(self) {} + Main() : mSelf(*ll::mod::NativeMod::current()) {} [[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; } diff --git a/xmake.lua b/xmake.lua index c04c746..1cd86bd 100644 --- a/xmake.lua +++ b/xmake.lua @@ -13,6 +13,9 @@ if not has_config("vs_runtime") then end target("PowerRanks") -- Change this to your mod name. + add_rules("@levibuildscript/linkrule") + add_rules("@levibuildscript/modpacker") + add_cxflags( "/EHa", "/utf-8", @@ -29,7 +32,6 @@ target("PowerRanks") -- Change this to your mod name. add_includedirs("src") add_packages("levilamina") add_packages("sqlitecpp") - add_shflags("/DELAYLOAD:bedrock_runtime.dll") set_exceptions("none") -- To avoid conflicts with /EHa. set_kind("shared") set_languages("c++20")