core/sm_srvcmds.cpp
changeset 1541 e46ad208b9b4
parent 1330 ab94316bb52b
child 1542 a7fb7373989a
     1.1 --- a/core/sm_srvcmds.cpp	Sat Oct 13 22:13:43 2007 +0000
     1.2 +++ b/core/sm_srvcmds.cpp	Sun Oct 14 00:04:21 2007 +0000
     1.3 @@ -57,11 +57,18 @@
     1.4  	m_Menu.clear();
     1.5  }
     1.6  
     1.7 -extern void _IntExt_OnHostnameChanged(ConVar *pConVar, char const *oldValue);
     1.8 +#if defined ORANGEBOX_BUILD
     1.9 +	extern void _IntExt_OnHostnameChanged(IConVar *var, const char *pOldValue, float flOldValue);
    1.10 +#else
    1.11 +	extern void _IntExt_OnHostnameChanged(ConVar *pConVar, char const *oldValue);
    1.12 +#endif
    1.13  
    1.14  void RootConsoleMenu::OnSourceModStartup(bool late)
    1.15  {
    1.16 -	ConCommandBaseMgr::OneTimeInit(this);
    1.17 +#if defined ORANGEBOX_BUILD
    1.18 +	ICvar *g_pCVar = icvar;
    1.19 +#endif
    1.20 +	CONVAR_REGISTER(this);
    1.21  	AddRootConsoleCommand("version", "Display version information", this);
    1.22  	AddRootConsoleCommand("credits", "Display credits listing", this);
    1.23  
    1.24 @@ -201,28 +208,28 @@
    1.25  
    1.26  extern void _IntExt_EnableYams();
    1.27  
    1.28 -void RootConsoleMenu::GotRootCmd()
    1.29 +void RootConsoleMenu::GotRootCmd(const CCommand &cmd)
    1.30  {
    1.31 -	unsigned int argnum = GetArgumentCount();
    1.32 +	unsigned int argnum = cmd.ArgC();
    1.33  
    1.34  	if (argnum >= 2)
    1.35  	{
    1.36 -		const char *cmd = GetArgument(1);
    1.37 -		if (strcmp(cmd, "text") == 0)
    1.38 +		const char *cmdname = cmd.Arg(1);
    1.39 +		if (strcmp(cmdname, "text") == 0)
    1.40  		{
    1.41  			_IntExt_EnableYams();
    1.42  			return;
    1.43 -		} else if (strcmp(cmd, "internal") == 0) {
    1.44 +		} else if (strcmp(cmdname, "internal") == 0) {
    1.45  			if (argnum >= 3)
    1.46  			{
    1.47 -				const char *arg = GetArgument(2);
    1.48 +				const char *arg = cmd.Arg(2);
    1.49  				if (strcmp(arg, "1") == 0)
    1.50  				{
    1.51  					SM_ConfigsExecuted_Global();
    1.52  				} else if (strcmp(arg, "2") == 0) {
    1.53  					if (argnum >= 4)
    1.54  					{
    1.55 -						SM_ConfigsExecuted_Plugin(atoi(GetArgument(3)));
    1.56 +						SM_ConfigsExecuted_Plugin(atoi(cmd.Arg(3)));
    1.57  					}
    1.58  				}
    1.59  			}
    1.60 @@ -230,9 +237,9 @@
    1.61  		}
    1.62  
    1.63  		IRootConsoleCommand *pHandler;
    1.64 -		if (sm_trie_retrieve(m_pCommands, cmd, (void **)&pHandler))
    1.65 +		if (sm_trie_retrieve(m_pCommands, cmdname, (void **)&pHandler))
    1.66  		{
    1.67 -			pHandler->OnRootConsoleCommand(cmd, argnum);
    1.68 +			pHandler->OnRootConsoleCommand(cmdname, cmd);
    1.69  			return;
    1.70  		}
    1.71  	}
    1.72 @@ -249,24 +256,9 @@
    1.73  	}
    1.74  }
    1.75  
    1.76 -const char *RootConsoleMenu::GetArgument(unsigned int argno)
    1.77 -{
    1.78 -	return engine->Cmd_Argv(argno);
    1.79 -}
    1.80 -
    1.81 -const char *RootConsoleMenu::GetArguments()
    1.82 +void RootConsoleMenu::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
    1.83  {
    1.84 -	return engine->Cmd_Args();
    1.85 -}
    1.86 -
    1.87 -unsigned int RootConsoleMenu::GetArgumentCount()
    1.88 -{
    1.89 -	return engine->Cmd_Argc();
    1.90 -}
    1.91 -
    1.92 -void RootConsoleMenu::OnRootConsoleCommand(const char *cmd, unsigned int argcount)
    1.93 -{
    1.94 -	if (strcmp(cmd, "credits") == 0)
    1.95 +	if (strcmp(cmdname, "credits") == 0)
    1.96  	{
    1.97  		ConsolePrint(" SourceMod was developed by AlliedModders, LLC.");
    1.98  		ConsolePrint(" Development would not have been possible without the following people:");
    1.99 @@ -277,7 +269,7 @@
   1.100  		ConsolePrint(" Special thanks to Viper of GameConnect");
   1.101  		ConsolePrint(" Special thanks to Mani of Mani-Admin-Plugin");
   1.102  		ConsolePrint(" http://www.sourcemod.net/");
   1.103 -	} else if (strcmp(cmd, "version") == 0) {
   1.104 +	} else if (strcmp(cmdname, "version") == 0) {
   1.105  		ConsolePrint(" SourceMod Version Information:");
   1.106  		ConsolePrint("    SourceMod Version: %s", SVN_FULL_VERSION);
   1.107  		ConsolePrint("    JIT Version: %s, %s", g_pVM->GetVMName(), g_pVM->GetVersionString());
   1.108 @@ -288,18 +280,24 @@
   1.109  
   1.110  CON_COMMAND(sm, "SourceMod Menu")
   1.111  {
   1.112 -	g_RootMenu.GotRootCmd();
   1.113 +#if !defined ORANGEBOX_BUILD
   1.114 +	CCommand args;
   1.115 +#endif
   1.116 +	g_RootMenu.GotRootCmd(args);
   1.117  }
   1.118  
   1.119  CON_COMMAND(sm_dump_handles, "Dumps Handle usage to a file for finding Handle leaks")
   1.120  {
   1.121 -	if (engine->Cmd_Argc() < 2)
   1.122 +#if !defined ORANGEBOX_BUILD
   1.123 +	CCommand args;
   1.124 +#endif
   1.125 +	if (args.ArgC() < 2)
   1.126  	{
   1.127  		g_RootMenu.ConsolePrint("Usage: sm_dump_handles <file>");
   1.128  		return;
   1.129  	}
   1.130  
   1.131 -	const char *arg = engine->Cmd_Argv(1);
   1.132 +	const char *arg = args.Arg(1);
   1.133  	FILE *fp = fopen(arg, "wt");
   1.134  	if (!fp)
   1.135  	{