Add cvars for modsystem

Add cvars to enable/disable the modsystem, also added cvars to toggle modsystem debug.
This commit is contained in:
Kawe Mazidjatari 2023-07-08 13:22:30 +02:00
parent f6650df951
commit 8f480d924b
3 changed files with 28 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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)