Fixed chat trigger crash regression on ep1 (bug 5394, r=asherkin).

This commit is contained in:
Nicholas Hastings 2013-08-15 10:21:04 -04:00
parent c79d547492
commit 5ca5ecee85
2 changed files with 13 additions and 9 deletions

View File

@ -256,9 +256,13 @@ void ChatTriggers::OnSayCommand_Pre()
is_quoted = true;
}
const char * pCommandName = command.Arg(0);
/* Save these off for post hook as the command data returned from the engine in older engine versions
* can be NULL, despite the data still being there and valid. */
m_Arg0Backup = command.Arg(0);
m_ArgSBackup = command.ArgS();
#if SOURCE_ENGINE == SE_EPISODEONE
if (m_bIsINS && strcmp(pCommandName, "say2") == 0 && strlen(args) >= 4)
if (m_bIsINS && strcmp(m_Arg0Backup, "say2") == 0 && strlen(args) >= 4)
{
args += 4;
}
@ -298,8 +302,8 @@ void ChatTriggers::OnSayCommand_Pre()
{
cell_t res = Pl_Continue;
m_pOnClientSayCmd->PushCell(client);
m_pOnClientSayCmd->PushString(pCommandName);
m_pOnClientSayCmd->PushString(command.ArgS());
m_pOnClientSayCmd->PushString(m_Arg0Backup);
m_pOnClientSayCmd->PushString(m_ArgSBackup);
m_pOnClientSayCmd->Execute(&res);
if (res >= Pl_Handled)
@ -321,12 +325,10 @@ void ChatTriggers::OnSayCommand_Pre()
#if SOURCE_ENGINE >= SE_ORANGEBOX
void ChatTriggers::OnSayCommand_Post(const CCommand &command)
{
#else
void ChatTriggers::OnSayCommand_Post()
{
CCommand command;
#endif
{
int client = g_ConCmds.GetCommandClient();
if (m_bWillProcessInPost)
@ -347,8 +349,8 @@ void ChatTriggers::OnSayCommand_Post()
else if (!m_bWasFloodedMessage && m_pOnClientSayCmd_Post->GetFunctionCount() != 0)
{
m_pOnClientSayCmd_Post->PushCell(client);
m_pOnClientSayCmd_Post->PushString(command.Arg(0));
m_pOnClientSayCmd_Post->PushString(command.ArgS());
m_pOnClientSayCmd_Post->PushString(m_Arg0Backup);
m_pOnClientSayCmd_Post->PushString(m_ArgSBackup);
m_pOnClientSayCmd_Post->Execute(NULL);
}

View File

@ -88,6 +88,8 @@ private:
bool m_bPluginIgnored;
unsigned int m_ReplyTo;
char m_ToExecute[300];
const char *m_Arg0Backup;
const char *m_ArgSBackup;
IForward *m_pShouldFloodBlock;
IForward *m_pDidFloodBlock;
IForward *m_pOnClientSayCmd;