core/ChatTriggers.cpp
changeset 2400 76b7b4575e21
parent 2289 44045ead61cd
child 2617 253d6b4f15ab
     1.1 --- a/core/ChatTriggers.cpp	Fri Nov 14 03:38:59 2008 -0600
     1.2 +++ b/core/ChatTriggers.cpp	Fri Nov 14 09:18:30 2008 -0600
     1.3 @@ -41,7 +41,7 @@
     1.4   * While the OB build only runs on MM:S 1.6.0+ (SH 5+), the older one 
     1.5   * can technically be compiled against any MM:S version after 1.4.2.
     1.6   */
     1.7 -#if defined ORANGEBOX_BUILD
     1.8 +#if SOURCE_ENGINE >= SE_ORANGEBOX
     1.9  extern bool __SourceHook_FHRemoveConCommandDispatch(void *, bool, class fastdelegate::FastDelegate1<const CCommand &, void>);
    1.10  extern int __SourceHook_FHAddConCommandDispatch(void *, ISourceHook::AddHookMode, bool, class fastdelegate::FastDelegate1<const CCommand &, void>);
    1.11  #else
    1.12 @@ -53,7 +53,7 @@
    1.13  #elif SH_IMPL_VERSION == 3
    1.14  extern bool __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
    1.15  #endif //SH_IMPL_VERSION
    1.16 -#endif //ORANGEBOX_BUILD
    1.17 +#endif //SE_ORANGEBOX
    1.18  
    1.19  ChatTriggers g_ChatTriggers;
    1.20  bool g_bSupressSilentFails = false;
    1.21 @@ -118,31 +118,8 @@
    1.22  
    1.23  void ChatTriggers::OnSourceModGameInitialized()
    1.24  {
    1.25 -	unsigned int total = 2;
    1.26 -	ConCommandBase *pCmd = icvar->GetCommands();
    1.27 -	const char *name;
    1.28 -	while (pCmd)
    1.29 -	{
    1.30 -		if (pCmd->IsCommand())
    1.31 -		{
    1.32 -			name = pCmd->GetName();
    1.33 -			if (!m_pSayCmd && strcmp(name, "say") == 0)
    1.34 -			{
    1.35 -				m_pSayCmd = (ConCommand *)pCmd;
    1.36 -				if (--total == 0)
    1.37 -				{
    1.38 -					break;
    1.39 -				}
    1.40 -			} else if (!m_pSayTeamCmd && strcmp(name, "say_team") == 0) {
    1.41 -				m_pSayTeamCmd = (ConCommand *)pCmd;
    1.42 -				if (--total == 0)
    1.43 -				{
    1.44 -					break;
    1.45 -				}
    1.46 -			}
    1.47 -		}
    1.48 -		pCmd = const_cast<ConCommandBase *>(pCmd->GetNext());
    1.49 -	}
    1.50 +	m_pSayCmd = FindCommand("say");
    1.51 +	m_pSayTeamCmd = FindCommand("say_team");
    1.52  
    1.53  	if (m_pSayCmd)
    1.54  	{
    1.55 @@ -173,7 +150,7 @@
    1.56  	g_Forwards.ReleaseForward(m_pDidFloodBlock);
    1.57  }
    1.58  
    1.59 -#if defined ORANGEBOX_BUILD
    1.60 +#if SOURCE_ENGINE >= SE_ORANGEBOX
    1.61  void ChatTriggers::OnSayCommand_Pre(const CCommand &command)
    1.62  {
    1.63  #else
    1.64 @@ -267,7 +244,7 @@
    1.65  	/**
    1.66  	 * Test if this is actually a command!
    1.67  	 */
    1.68 -	if (!PreProcessTrigger(engine->PEntityOfEntIndex(client), args, is_quoted))
    1.69 +	if (!PreProcessTrigger(PEntityOfEntIndex(client), args, is_quoted))
    1.70  	{
    1.71  		CPlayer *pPlayer;
    1.72  		if (is_silent 
    1.73 @@ -299,7 +276,7 @@
    1.74  	RETURN_META(MRES_IGNORED);
    1.75  }
    1.76  
    1.77 -#if defined ORANGEBOX_BUILD
    1.78 +#if SOURCE_ENGINE >= SE_ORANGEBOX
    1.79  void ChatTriggers::OnSayCommand_Post(const CCommand &command)
    1.80  #else
    1.81  void ChatTriggers::OnSayCommand_Post()
    1.82 @@ -315,7 +292,7 @@
    1.83  		/* Execute the cached command */
    1.84  		int client = g_ConCmds.GetCommandClient();
    1.85  		unsigned int old = SetReplyTo(SM_REPLY_CHAT);
    1.86 -		serverpluginhelpers->ClientCommand(engine->PEntityOfEntIndex(client), m_ToExecute);
    1.87 +		serverpluginhelpers->ClientCommand(PEntityOfEntIndex(client), m_ToExecute);
    1.88  		SetReplyTo(old);
    1.89  	}
    1.90  }