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

--HG--
extra : rebase_source : 39f0eff210b785b266422157c48b538921e16cc8
This commit is contained in:
Nicholas Hastings 2013-08-15 10:18:27 -04:00
parent caa3343dea
commit 5fc854ab4f
2 changed files with 13 additions and 10 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,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);
}

View File

@ -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;