core/smn_console.cpp
changeset 2400 76b7b4575e21
parent 2397 f0ada60e6a8b
child 2439 d7b679bf335d
     1.1 --- a/core/smn_console.cpp	Fri Nov 14 03:38:59 2008 -0600
     1.2 +++ b/core/smn_console.cpp	Fri Nov 14 09:18:30 2008 -0600
     1.3 @@ -44,7 +44,11 @@
     1.4  #include <bitbuf.h>
     1.5  #include <sm_trie_tpl.h>
     1.6  
     1.7 +#if SOURCE_ENGINE == SE_LEFT4DEAD
     1.8 +#define NET_SETCONVAR	6
     1.9 +#else
    1.10  #define NET_SETCONVAR	5
    1.11 +#endif
    1.12  
    1.13  enum ConVarBounds
    1.14  {
    1.15 @@ -63,7 +67,11 @@
    1.16  
    1.17  struct ConCmdIter
    1.18  {
    1.19 +#if SOURCE_ENGINE == SE_LEFT4DEAD
    1.20 +	ICvarIteratorInternal *pLast;
    1.21 +#else
    1.22  	const ConCommandBase *pLast;
    1.23 +#endif
    1.24  };
    1.25  
    1.26  class ConsoleHelpers : 
    1.27 @@ -129,7 +137,7 @@
    1.28  			*flags = (*ppCmd)->GetFlags();
    1.29  			return true;
    1.30  		}
    1.31 -		else if ((pCmd=FindConCommandBase(name)))
    1.32 +		else if ((pCmd=FindCommandBase(name)))
    1.33  		{
    1.34  			m_CmdFlags.insert(name, pCmd);
    1.35  			TrackConCommandBase(pCmd, this);
    1.36 @@ -151,7 +159,7 @@
    1.37  			TrackConCommandBase((*ppCmd), this);
    1.38  			return true;
    1.39  		}
    1.40 -		else if ((pCmd=FindConCommandBase(name)))
    1.41 +		else if ((pCmd=FindCommandBase(name)))
    1.42  		{
    1.43  			m_CmdFlags.insert(name, pCmd);
    1.44  			pCmd->SetFlags(flags);
    1.45 @@ -167,7 +175,7 @@
    1.46  	KTrie<ConCommandBase *> m_CmdFlags;
    1.47  } s_CommandFlagsHelper;
    1.48  
    1.49 -#ifndef ORANGEBOX_BUILD
    1.50 +#if SOURCE_ENGINE >= SE_ORANGEBOX
    1.51  static void ReplicateConVar(ConVar *pConVar)
    1.52  {
    1.53  	int maxClients = g_Players.GetMaxClients();
    1.54 @@ -341,7 +349,7 @@
    1.55  
    1.56  	pConVar->SetValue(params[2]);
    1.57  
    1.58 -#ifndef ORANGEBOX_BUILD
    1.59 +#if SOURCE_ENGINE >= SE_ORANGEBOX
    1.60  	/* Should we replicate it? */
    1.61  	if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
    1.62  	{
    1.63 @@ -390,7 +398,7 @@
    1.64  	float value = sp_ctof(params[2]);
    1.65  	pConVar->SetValue(value);
    1.66  
    1.67 -#ifndef ORANGEBOX_BUILD
    1.68 +#if SOURCE_ENGINE >= SE_ORANGEBOX
    1.69  	/* Should we replicate it? */
    1.70  	if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
    1.71  	{
    1.72 @@ -441,7 +449,7 @@
    1.73  
    1.74  	pConVar->SetValue(value);
    1.75  
    1.76 -#ifndef ORANGEBOX_BUILD
    1.77 +#if SOURCE_ENGINE >= SE_ORANGEBOX
    1.78  	/* Should we replicate it? */
    1.79  	if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
    1.80  	{
    1.81 @@ -472,7 +480,7 @@
    1.82  
    1.83  	pConVar->Revert();
    1.84  	
    1.85 -#ifndef ORANGEBOX_BUILD
    1.86 +#if SOURCE_ENGINE >= SE_ORANGEBOX
    1.87  	/* Should we replicate it? */
    1.88  	if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED))
    1.89  	{
    1.90 @@ -1151,12 +1159,21 @@
    1.91  	pContext->LocalToPhysAddr(params[3], &pIsCmd);
    1.92  	pContext->LocalToPhysAddr(params[4], &pFlags);
    1.93  
    1.94 +#if SOURCE_ENGINE == SE_LEFT4DEAD
    1.95 +	ICvarIteratorInternal *cvarIter = icvar->FactoryInternalIterator();
    1.96 +	cvarIter->SetFirst();
    1.97 +	if (!cvarIter->IsValid())
    1.98 +	{
    1.99 +		return BAD_HANDLE;
   1.100 +	}
   1.101 +	pConCmd = cvarIter->Get();
   1.102 +#else
   1.103  	pConCmd = icvar->GetCommands();
   1.104 -
   1.105  	if (pConCmd == NULL)
   1.106  	{
   1.107  		return BAD_HANDLE;
   1.108  	}
   1.109 +#endif
   1.110  
   1.111  	pContext->StringToLocalUTF8(params[1], params[2], pConCmd->GetName(), NULL);
   1.112  	*pIsCmd = pConCmd->IsCommand() ? 1 : 0;
   1.113 @@ -1169,7 +1186,11 @@
   1.114  	}
   1.115  
   1.116  	pIter = new ConCmdIter;
   1.117 +#if SOURCE_ENGINE == SE_LEFT4DEAD
   1.118 +	pIter->pLast = cvarIter;
   1.119 +#else
   1.120  	pIter->pLast = pConCmd;
   1.121 +#endif
   1.122  
   1.123  	if ((hndl = g_HandleSys.CreateHandle(htConCmdIter, pIter, pContext->GetIdentity(), g_pCoreIdent, NULL))
   1.124  		== BAD_HANDLE)
   1.125 @@ -1187,6 +1208,7 @@
   1.126  	ConCmdIter *pIter;
   1.127  	cell_t *pIsCmd, *pFlags;
   1.128  	const char *desc;
   1.129 +	const ConCommandBase *pConCmd;
   1.130  	HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
   1.131  
   1.132  	if ((err = g_HandleSys.ReadHandle(params[1], htConCmdIter, &sec, (void **)&pIter)) != HandleError_None)
   1.133 @@ -1199,21 +1221,33 @@
   1.134  		return 0;
   1.135  	}
   1.136  
   1.137 -	if ((pIter->pLast = pIter->pLast->GetNext()) == NULL)
   1.138 +#if SOURCE_ENGINE == SE_LEFT4DEAD
   1.139 +	ICvarIteratorInternal *cvarIter = pIter->pLast;
   1.140 +	cvarIter->Next();
   1.141 +	if (!cvarIter->IsValid())
   1.142  	{
   1.143  		return 0;
   1.144  	}
   1.145 +	pConCmd = cvarIter->Get();
   1.146 +#else
   1.147 +	pConCmd = pIter->pLast->GetNext();
   1.148 +	if (pConCmd == NULL)
   1.149 +	{
   1.150 +		return 0;
   1.151 +	}
   1.152 +	pIter->pLast = pConCmd;
   1.153 +#endif
   1.154  
   1.155  	pContext->LocalToPhysAddr(params[4], &pIsCmd);
   1.156  	pContext->LocalToPhysAddr(params[5], &pFlags);
   1.157  
   1.158 -	pContext->StringToLocalUTF8(params[2], params[3], pIter->pLast->GetName(), NULL);
   1.159 -	*pIsCmd = pIter->pLast->IsCommand() ? 1 : 0;
   1.160 -	*pFlags = pIter->pLast->GetFlags();
   1.161 +	pContext->StringToLocalUTF8(params[2], params[3], pConCmd->GetName(), NULL);
   1.162 +	*pIsCmd = pConCmd->IsCommand() ? 1 : 0;
   1.163 +	*pFlags = pConCmd->GetFlags();
   1.164  
   1.165  	if (params[7])
   1.166  	{
   1.167 -		desc = pIter->pLast->GetHelpText();
   1.168 +		desc = pConCmd->GetHelpText();
   1.169  		pContext->StringToLocalUTF8(params[6], params[7], (desc && desc[0]) ? desc : "", NULL);
   1.170  	}
   1.171