From 5fc854ab4f8363c67c600971f12cdc9cccb60c69 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Thu, 15 Aug 2013 10:18:27 -0400 Subject: [PATCH] Fixed chat trigger crash regression on ep1 (bug 5394, r=asherkin). --HG-- extra : rebase_source : 39f0eff210b785b266422157c48b538921e16cc8 --- core/ChatTriggers.cpp | 21 +++++++++++---------- core/ChatTriggers.h | 2 ++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/ChatTriggers.cpp b/core/ChatTriggers.cpp index 367b4786..fba3d264 100644 --- a/core/ChatTriggers.cpp +++ b/core/ChatTriggers.cpp @@ -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,15 +325,12 @@ void ChatTriggers::OnSayCommand_Pre() #if SOURCE_ENGINE == SE_DOTA void ChatTriggers::OnSayCommand_Post(const CCommandContext &context, const CCommand &command) -{ #elif 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) @@ -354,8 +355,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); } diff --git a/core/ChatTriggers.h b/core/ChatTriggers.h index b80f9158..f2247ea9 100644 --- a/core/ChatTriggers.h +++ b/core/ChatTriggers.h @@ -91,6 +91,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;