From 8f480d924b9cf88a399a71d485096a83bc41f794 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 8 Jul 2023 13:22:30 +0200 Subject: [PATCH] Add cvars for modsystem Add cvars to enable/disable the modsystem, also added cvars to toggle modsystem debug. --- r5dev/common/global.cpp | 11 +++++++++++ r5dev/common/global.h | 5 +++++ r5dev/pluginsystem/modsystem.cpp | 15 ++++++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/r5dev/common/global.cpp b/r5dev/common/global.cpp index 839e556d..8714ecb9 100644 --- a/r5dev/common/global.cpp +++ b/r5dev/common/global.cpp @@ -62,6 +62,11 @@ ConVar* r_visualizetraces_duration = nullptr; ConVar* stream_overlay = nullptr; ConVar* stream_overlay_mode = nullptr; +//----------------------------------------------------------------------------- +// SHARED | +ConVar* modsystem_enable = nullptr; +ConVar* modsystem_debug = nullptr; + //----------------------------------------------------------------------------- // SERVER | #ifndef CLIENT_DLL @@ -274,6 +279,12 @@ void ConVar_StaticInit(void) r_drawWorldMeshes = ConVar::StaticCreate("r_drawWorldMeshes" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes.", false, 0.f, false, 0.f, nullptr, nullptr); r_drawWorldMeshesDepthOnly = ConVar::StaticCreate("r_drawWorldMeshesDepthOnly" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes (depth only).", false, 0.f, false, 0.f, nullptr, nullptr); r_drawWorldMeshesDepthAtTheEnd = ConVar::StaticCreate("r_drawWorldMeshesDepthAtTheEnd", "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes (depth at the end).", false, 0.f, false, 0.f, nullptr, nullptr); + + //------------------------------------------------------------------------- + // SHARED | + modsystem_enable = ConVar::StaticCreate("modsystem_enable", "0", FCVAR_RELEASE, "Enable the modsystem.", false, 0.f, false, 0.f, nullptr, nullptr); + modsystem_debug = ConVar::StaticCreate("modsystem_debug" , "0", FCVAR_RELEASE, "Debug the modsystem." , false, 0.f, false, 0.f, nullptr, nullptr); + //------------------------------------------------------------------------- // SERVER | #ifndef CLIENT_DLL diff --git a/r5dev/common/global.h b/r5dev/common/global.h index 94ff5be5..a865b1b7 100644 --- a/r5dev/common/global.h +++ b/r5dev/common/global.h @@ -53,6 +53,11 @@ extern ConVar* r_visualizetraces_duration; extern ConVar* stream_overlay; extern ConVar* stream_overlay_mode; +//------------------------------------------------------------------------- +// SHARED | +extern ConVar* modsystem_enable; +extern ConVar* modsystem_debug; + //------------------------------------------------------------------------- // SERVER | #ifndef CLIENT_DLL diff --git a/r5dev/pluginsystem/modsystem.cpp b/r5dev/pluginsystem/modsystem.cpp index f86c9d4a..32359bf2 100644 --- a/r5dev/pluginsystem/modsystem.cpp +++ b/r5dev/pluginsystem/modsystem.cpp @@ -18,6 +18,9 @@ //----------------------------------------------------------------------------- void CModSystem::Init() { + if (!modsystem_enable->GetBool()) + return; + LoadModStatusList(); CreateDirectories("platform\\mods"); @@ -28,7 +31,10 @@ void CModSystem::Init() continue; fs::path basePath = it.path(); - DevMsg(eDLL_T::ENGINE, "Found mod at '%s'.\n", basePath.string().c_str()); + + if (modsystem_debug->GetBool()) + DevMsg(eDLL_T::ENGINE, "Found mod at '%s'.\n", basePath.string().c_str()); + fs::path settingsPath = basePath / "mod.vdf"; if (fs::exists(settingsPath)) @@ -141,7 +147,9 @@ CModSystem::ModInstance_t::ModInstance_t(const fs::path& basePath) : m_szName(st auto& enabledList = g_pModSystem->GetEnabledList(); if (enabledList.count(idHash) == 0) { - DevMsg(eDLL_T::ENGINE, "Mod does not exist in 'mods.vdf'. Enabling...\n"); + if (modsystem_debug->GetBool()) + DevMsg(eDLL_T::ENGINE, "Mod does not exist in 'mods.vdf'. Enabling...\n"); + SetState(eModState::ENABLED); } else @@ -149,7 +157,8 @@ CModSystem::ModInstance_t::ModInstance_t(const fs::path& basePath) : m_szName(st bool bEnable = enabledList[idHash]; SetState(bEnable ? eModState::ENABLED : eModState::DISABLED); - DevMsg(eDLL_T::ENGINE, "Mod exists in 'mods.vdf' and is %s.\n", bEnable ? "enabled" : "disabled"); + if (modsystem_debug->GetBool()) + DevMsg(eDLL_T::ENGINE, "Mod exists in 'mods.vdf' and is %s.\n", bEnable ? "enabled" : "disabled"); } if (m_iState != eModState::ENABLED)