Fixed chat trigger crash regression on ep1 (bug 5394, r=asherkin).
authorNicholas Hastings <skamonkey@gmail.com>
Thu Aug 15 10:18:27 2013 -0400 (2013-08-15)
changeset 40155f1fcac17b60
parent 4014 c20558a6734e
child 4016 ecd3735e908b
Fixed chat trigger crash regression on ep1 (bug 5394, r=asherkin).
core/ChatTriggers.cpp
core/ChatTriggers.h
     1.1 --- a/core/ChatTriggers.cpp	Wed Aug 14 23:59:31 2013 -0700
     1.2 +++ b/core/ChatTriggers.cpp	Thu Aug 15 10:18:27 2013 -0400
     1.3 @@ -256,9 +256,13 @@
     1.4  		is_quoted = true;
     1.5  	}
     1.6  
     1.7 -	const char * pCommandName = command.Arg(0);
     1.8 +	/* Save these off for post hook as the command data returned from the engine in older engine versions 
     1.9 +	 * can be NULL, despite the data still being there and valid. */
    1.10 +	m_Arg0Backup = command.Arg(0);
    1.11 +	m_ArgSBackup = command.ArgS();
    1.12 +
    1.13  #if SOURCE_ENGINE == SE_EPISODEONE
    1.14 -	if (m_bIsINS && strcmp(pCommandName, "say2") == 0 && strlen(args) >= 4)
    1.15 +	if (m_bIsINS && strcmp(m_Arg0Backup, "say2") == 0 && strlen(args) >= 4)
    1.16  	{
    1.17  		args += 4;
    1.18  	}
    1.19 @@ -298,8 +302,8 @@
    1.20  	{
    1.21  		cell_t res = Pl_Continue;
    1.22  		m_pOnClientSayCmd->PushCell(client);
    1.23 -		m_pOnClientSayCmd->PushString(pCommandName);
    1.24 -		m_pOnClientSayCmd->PushString(command.ArgS());
    1.25 +		m_pOnClientSayCmd->PushString(m_Arg0Backup);
    1.26 +		m_pOnClientSayCmd->PushString(m_ArgSBackup);
    1.27  		m_pOnClientSayCmd->Execute(&res);
    1.28  
    1.29  		if (res >= Pl_Handled)
    1.30 @@ -321,15 +325,12 @@
    1.31  
    1.32  #if SOURCE_ENGINE == SE_DOTA
    1.33  void ChatTriggers::OnSayCommand_Post(const CCommandContext &context, const CCommand &command)
    1.34 -{
    1.35  #elif SOURCE_ENGINE >= SE_ORANGEBOX
    1.36  void ChatTriggers::OnSayCommand_Post(const CCommand &command)
    1.37 -{
    1.38  #else
    1.39  void ChatTriggers::OnSayCommand_Post()
    1.40 +#endif
    1.41  {
    1.42 -	CCommand command;
    1.43 -#endif
    1.44  	int client = g_ConCmds.GetCommandClient();
    1.45  
    1.46  	if (m_bWillProcessInPost)
    1.47 @@ -354,8 +355,8 @@
    1.48  	else if (!m_bWasFloodedMessage && m_pOnClientSayCmd_Post->GetFunctionCount() != 0)
    1.49  	{	
    1.50  		m_pOnClientSayCmd_Post->PushCell(client);
    1.51 -		m_pOnClientSayCmd_Post->PushString(command.Arg(0));
    1.52 -		m_pOnClientSayCmd_Post->PushString(command.ArgS());
    1.53 +		m_pOnClientSayCmd_Post->PushString(m_Arg0Backup);
    1.54 +		m_pOnClientSayCmd_Post->PushString(m_ArgSBackup);
    1.55  		m_pOnClientSayCmd_Post->Execute(NULL);
    1.56  	}
    1.57  
     2.1 --- a/core/ChatTriggers.h	Wed Aug 14 23:59:31 2013 -0700
     2.2 +++ b/core/ChatTriggers.h	Thu Aug 15 10:18:27 2013 -0400
     2.3 @@ -91,6 +91,8 @@
     2.4  	bool m_bPluginIgnored;
     2.5  	unsigned int m_ReplyTo;
     2.6  	char m_ToExecute[300];
     2.7 +	const char *m_Arg0Backup;
     2.8 +	const char *m_ArgSBackup;
     2.9  	IForward *m_pShouldFloodBlock;
    2.10  	IForward *m_pDidFloodBlock;
    2.11  	IForward *m_pOnClientSayCmd;