Factor irrelevant stuff out of RootConsoleMenu.

This commit is contained in:
David Anderson 2015-08-27 22:00:05 -04:00
parent ecbcc7ba16
commit e992c33f35
3 changed files with 26 additions and 24 deletions

View File

@ -40,7 +40,6 @@ RootConsoleMenu g_RootMenu;
RootConsoleMenu::RootConsoleMenu() RootConsoleMenu::RootConsoleMenu()
{ {
m_CfgExecDone = false;
} }
RootConsoleMenu::~RootConsoleMenu() RootConsoleMenu::~RootConsoleMenu()
@ -55,10 +54,6 @@ RootConsoleMenu::~RootConsoleMenu()
void RootConsoleMenu::OnSourceModStartup(bool late) void RootConsoleMenu::OnSourceModStartup(bool late)
{ {
#if SOURCE_ENGINE >= SE_ORANGEBOX
g_pCVar = icvar;
#endif
CONVAR_REGISTER(this);
AddRootConsoleCommand("version", "Display version information", this); AddRootConsoleCommand("version", "Display version information", this);
AddRootConsoleCommand("credits", "Display credits listing", this); AddRootConsoleCommand("credits", "Display credits listing", this);
} }
@ -74,20 +69,6 @@ void RootConsoleMenu::OnSourceModShutdown()
RemoveRootConsoleCommand("version", this); 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<ConVar *>(pCommand)->SetValue(cmdLineValue);
}
return true;
}
void RootConsoleMenu::ConsolePrint(const char *fmt, ...) void RootConsoleMenu::ConsolePrint(const char *fmt, ...)
{ {
char buffer[512]; char buffer[512];

View File

@ -57,7 +57,6 @@ struct ConsoleEntry
}; };
class RootConsoleMenu : class RootConsoleMenu :
public IConCommandBaseAccessor,
public SMGlobalClass, public SMGlobalClass,
public IRootConsoleCommand, public IRootConsoleCommand,
public IRootConsole public IRootConsole
@ -68,8 +67,6 @@ public:
public: public:
const char *GetInterfaceName(); const char *GetInterfaceName();
unsigned int GetInterfaceVersion(); unsigned int GetInterfaceVersion();
public: //IConCommandBaseAccessor
bool RegisterConCommandBase(ConCommandBase *pCommand);
public: //SMGlobalClass public: //SMGlobalClass
void OnSourceModStartup(bool late); void OnSourceModStartup(bool late);
void OnSourceModAllInitialized(); void OnSourceModAllInitialized();
@ -91,7 +88,6 @@ public: //IRootConsole
public: public:
void GotRootCmd(const CCommand &cmd); void GotRootCmd(const CCommand &cmd);
private: private:
bool m_CfgExecDone;
NameHashSet<ConsoleEntry *> m_Commands; NameHashSet<ConsoleEntry *> m_Commands;
List<ConsoleEntry *> m_Menu; List<ConsoleEntry *> m_Menu;
}; };

View File

@ -62,6 +62,7 @@ IGameConfig *g_pGameConf = NULL;
bool g_Loaded = false; bool g_Loaded = false;
bool sm_show_debug_spew = false; bool sm_show_debug_spew = false;
bool sm_disable_jit = false; bool sm_disable_jit = false;
SMGlobalClass *SMGlobalClass::head = nullptr;
#ifdef PLATFORM_WINDOWS #ifdef PLATFORM_WINDOWS
ConVar sm_basepath("sm_basepath", "addons\\sourcemod", 0, "SourceMod base path (set via command line)"); 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; 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<ConVar *>(pCommand)->SetValue(cmdLineValue);
return true;
}
} sConVarRegistrar;