Allow code mods to be disabled on build, disable them by default for now.

This commit is contained in:
PJB3005
2026-05-29 00:37:13 +02:00
parent af6ca3c80c
commit b88a5e4ac3
3 changed files with 25 additions and 0 deletions
+10
View File
@@ -461,6 +461,16 @@ if(ANDROID)
list(APPEND GAME_COMPILE_DEFS TARGET_ANDROID=1)
endif ()
set(DUSK_ENABLE_CODE_MODS_DEFAULT OFF)
option(DUSK_ENABLE_CODE_MODS "Enable code mods" ${DUSK_ENABLE_CODE_MODS_DEFAULT})
if (DUSK_ENABLE_CODE_MODS)
if (NOT ANDROID AND NOT IOS AND NOT TVOS)
list(APPEND GAME_COMPILE_DEFS DUSK_CODE_MODS=1)
else ()
message(FATAL_ERROR "Code mods not supported on the target platform!")
endif ()
endif ()
# game_debug is for game code files that we know work when compiled with DEBUG=1
# Of course, if building a release build, this distinction is irrelevant
set(GAME_DEBUG_FILES
+5
View File
@@ -412,6 +412,11 @@ static bool checkDuplicateMod(const ModMetadata& metadata, const std::vector<Loa
}
bool ModLoader::tryLoadNativeMod(LoadedMod& mod) {
if (!EnableCodeMods) {
DuskLog.error("Code mods are not available in this build");
return false;
}
namespace fs = std::filesystem;
auto [dllEntry, dllFallback] = LocateDllInBundle(*mod.bundle);
+10
View File
@@ -3,8 +3,18 @@
#include <filesystem>
#include "miniz.h"
#if __APPLE__
#include <TargetConditionals.h>
#endif
namespace dusk::modding {
#if DUSK_CODE_MODS
constexpr bool EnableCodeMods = true;
#else
constexpr bool EnableCodeMods = false;
#endif
class ModBundle {
public:
virtual ~ModBundle() = default;