core/ConCmdManager.cpp
changeset 2546 32c1d07b2038
parent 2400 76b7b4575e21
child 3004 e3ac0dc6d9a4
     1.1 --- a/core/ConCmdManager.cpp	Sun Feb 01 02:03:03 2009 -0500
     1.2 +++ b/core/ConCmdManager.cpp	Sun Feb 01 02:13:17 2009 -0500
     1.3 @@ -229,46 +229,67 @@
     1.4  ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int args, ResultType type)
     1.5  {
     1.6  	ConCmdInfo *pInfo;
     1.7 -	if (sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
     1.8 +
     1.9 +	if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
    1.10  	{
    1.11 -		cell_t result = type;
    1.12 -		cell_t tempres = result;
    1.13 -		List<CmdHook *>::iterator iter;
    1.14 -		CmdHook *pHook;
    1.15 -		for (iter=pInfo->conhooks.begin();
    1.16 -			 iter!=pInfo->conhooks.end();
    1.17 -			 iter++)
    1.18 +		List<ConCmdInfo *>::iterator iter;
    1.19 +
    1.20 +		pInfo = NULL;
    1.21 +		iter = m_CmdList.begin();
    1.22 +		while (iter != m_CmdList.end())
    1.23  		{
    1.24 -			pHook = (*iter);
    1.25 -			if (!pHook->pf->IsRunnable())
    1.26 -			{
    1.27 -				continue;
    1.28 -			}
    1.29 -			if (pHook->pAdmin && !CheckAccess(client, cmd, pHook->pAdmin))
    1.30 +			if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0)
    1.31  			{
    1.32 -				if (result < Pl_Handled)
    1.33 -				{
    1.34 -					result = Pl_Handled;
    1.35 -				}
    1.36 -				continue;
    1.37 +				pInfo = (*iter);
    1.38 +				break;
    1.39  			}
    1.40 -			pHook->pf->PushCell(client);
    1.41 -			pHook->pf->PushCell(args);
    1.42 -			if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
    1.43 +			iter++;
    1.44 +		}
    1.45 +
    1.46 +		if (pInfo == NULL)
    1.47 +		{
    1.48 +			return type;
    1.49 +		}
    1.50 +	}
    1.51 +
    1.52 +	cell_t result = type;
    1.53 +	cell_t tempres = result;
    1.54 +	List<CmdHook *>::iterator iter;
    1.55 +	CmdHook *pHook;
    1.56 +	for (iter=pInfo->conhooks.begin();
    1.57 +		 iter!=pInfo->conhooks.end();
    1.58 +		 iter++)
    1.59 +	{
    1.60 +		pHook = (*iter);
    1.61 +		if (!pHook->pf->IsRunnable())
    1.62 +		{
    1.63 +			continue;
    1.64 +		}
    1.65 +		if (pHook->pAdmin && !CheckAccess(client, cmd, pHook->pAdmin))
    1.66 +		{
    1.67 +			if (result < Pl_Handled)
    1.68  			{
    1.69 -				if (tempres > result)
    1.70 -				{
    1.71 -					result = tempres;
    1.72 -				}
    1.73 -				if (result == Pl_Stop)
    1.74 -				{
    1.75 -					break;
    1.76 -				}
    1.77 +				result = Pl_Handled;
    1.78 +			}
    1.79 +			continue;
    1.80 +		}
    1.81 +		pHook->pf->PushCell(client);
    1.82 +		pHook->pf->PushCell(args);
    1.83 +		if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
    1.84 +		{
    1.85 +			if (tempres > result)
    1.86 +			{
    1.87 +				result = tempres;
    1.88 +			}
    1.89 +			if (result == Pl_Stop)
    1.90 +			{
    1.91 +				break;
    1.92  			}
    1.93  		}
    1.94 -		type = (ResultType)result;
    1.95  	}
    1.96  
    1.97 +	type = (ResultType)result;
    1.98 +
    1.99  	return type;
   1.100  }
   1.101