diff --git a/core/sm_srvcmds.cpp b/core/sm_srvcmds.cpp index ec733df5..091a94e8 100644 --- a/core/sm_srvcmds.cpp +++ b/core/sm_srvcmds.cpp @@ -40,7 +40,6 @@ RootConsoleMenu g_RootMenu; RootConsoleMenu::RootConsoleMenu() { - m_CfgExecDone = false; } RootConsoleMenu::~RootConsoleMenu() @@ -55,10 +54,6 @@ RootConsoleMenu::~RootConsoleMenu() void RootConsoleMenu::OnSourceModStartup(bool late) { -#if SOURCE_ENGINE >= SE_ORANGEBOX - g_pCVar = icvar; -#endif - CONVAR_REGISTER(this); AddRootConsoleCommand("version", "Display version information", this); AddRootConsoleCommand("credits", "Display credits listing", this); } @@ -74,20 +69,6 @@ void RootConsoleMenu::OnSourceModShutdown() RemoveRootConsoleCommand("version", this); } -bool RootConsoleMenu::RegisterConCommandBase(ConCommandBase *pCommand) -{ - META_REGCVAR(pCommand); - - /* Override values of convars created by SourceMod convar manager if specified on command line */ - const char *cmdLineValue = icvar->GetCommandLineValue(pCommand->GetName()); - if (cmdLineValue && !pCommand->IsCommand()) - { - static_cast(pCommand)->SetValue(cmdLineValue); - } - - return true; -} - void RootConsoleMenu::ConsolePrint(const char *fmt, ...) { char buffer[512]; diff --git a/core/sm_srvcmds.h b/core/sm_srvcmds.h index 5655fd5e..b8d3ac0d 100644 --- a/core/sm_srvcmds.h +++ b/core/sm_srvcmds.h @@ -57,7 +57,6 @@ struct ConsoleEntry }; class RootConsoleMenu : - public IConCommandBaseAccessor, public SMGlobalClass, public IRootConsoleCommand, public IRootConsole @@ -68,8 +67,6 @@ public: public: const char *GetInterfaceName(); unsigned int GetInterfaceVersion(); -public: //IConCommandBaseAccessor - bool RegisterConCommandBase(ConCommandBase *pCommand); public: //SMGlobalClass void OnSourceModStartup(bool late); void OnSourceModAllInitialized(); @@ -91,7 +88,6 @@ public: //IRootConsole public: void GotRootCmd(const CCommand &cmd); private: - bool m_CfgExecDone; NameHashSet m_Commands; List m_Menu; }; diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index 0a8d19fc..3c737197 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -62,6 +62,7 @@ IGameConfig *g_pGameConf = NULL; bool g_Loaded = false; bool sm_show_debug_spew = false; bool sm_disable_jit = false; +SMGlobalClass *SMGlobalClass::head = nullptr; #ifdef PLATFORM_WINDOWS ConVar sm_basepath("sm_basepath", "addons\\sourcemod", 0, "SourceMod base path (set via command line)"); @@ -751,5 +752,29 @@ bool SourceModBase::IsMapRunning() return g_OnMapStarted; } -SMGlobalClass *SMGlobalClass::head = NULL; +class ConVarRegistrar : + public IConCommandBaseAccessor, + public SMGlobalClass +{ +public: + void OnSourceModStartup(bool late) override + { +#if SOURCE_ENGINE >= SE_ORANGEBOX + g_pCVar = icvar; +#endif + CONVAR_REGISTER(this); + } + bool RegisterConCommandBase(ConCommandBase *pCommand) override + { + META_REGCVAR(pCommand); + + // Override values of convars created by SourceMod convar manager if + // specified on command line. + const char *cmdLineValue = icvar->GetCommandLineValue(pCommand->GetName()); + if (cmdLineValue && !pCommand->IsCommand()) + static_cast(pCommand)->SetValue(cmdLineValue); + + return true; + } +} sConVarRegistrar;