# HG changeset patch # User SystematicMania # Date 1393601916 18000 # Node ID c2836eb6c34a9c3556900e57eede0c3d14abe92f # Parent 32e36d3570f031585d2b79e3c59544f43b005fef Fix regressions in b2f7d97b1ea7 and update plugins for OnClientSayCommand changes (bug 5986, r=psychonic). diff -r 32e36d3570f0 -r c2836eb6c34a core/ChatTriggers.cpp --- a/core/ChatTriggers.cpp Thu Feb 27 23:46:51 2014 -0500 +++ b/core/ChatTriggers.cpp Fri Feb 28 10:38:36 2014 -0500 @@ -221,22 +221,34 @@ /* 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); - - /* Handle quoted string sets */ - bool is_quoted = false; size_t len = strlen(args); - /* The engine does not display empty say commands. - * So to prevent forwarding it, let's block it. */ - if (len == 0) +#if SOURCE_ENGINE == SE_EPISODEONE + if (m_bIsINS) { - RETURN_META(MRES_SUPERCEDE); + if (strcmp(m_Arg0Backup, "say2") == 0 && len >= 4) + { + args += 4; + len -= 4; + } + + if (len == 0) + { + RETURN_META(MRES_SUPERCEDE); + } } +#endif /* The first pair of quotes are stripped from client say commands, but not console ones. * We do not want the forwards to differ from what is displayed. * So only strip the first pair of quotes from client say commands. */ - if (client != 0 && args[0] == '"' && args[len-1] == '"') + bool is_quoted = false; + + if ( +#if SOURCE_ENGINE == SE_EPISODEONE + !m_bIsINS && +#endif + client != 0 && args[0] == '"' && args[len-1] == '"') { /* The server normally won't display empty say commands, but in this case it does. * I don't think it's desired so let's block it. */ @@ -249,7 +261,7 @@ len--; is_quoted = true; } - + /* Some? engines strip the last quote when printing the string to chat. * This results in having a double-quoted message passed to the OnClientSayCommand ("message") forward, * but losing the last quote in the OnClientSayCommand_Post ("message) forward. @@ -306,27 +318,20 @@ RETURN_META(MRES_SUPERCEDE); } -#if SOURCE_ENGINE == SE_EPISODEONE - if (m_bIsINS && strcmp(m_Arg0Backup, "say2") == 0 && strlen(args) >= 4) - { - args += 4; - } -#endif - bool is_trigger = false; bool is_silent = false; /* Check for either trigger */ - if (m_PubTriggerSize && strncmp(args, m_PubTrigger, m_PubTriggerSize) == 0) + if (m_PubTriggerSize && strncmp(m_ArgSBackup, m_PubTrigger, m_PubTriggerSize) == 0) { is_trigger = true; - args = &args[m_PubTriggerSize]; + args = &m_ArgSBackup[m_PubTriggerSize]; } - else if (m_PrivTriggerSize && strncmp(args, m_PrivTrigger, m_PrivTriggerSize) == 0) + else if (m_PrivTriggerSize && strncmp(m_ArgSBackup, m_PrivTrigger, m_PrivTriggerSize) == 0) { is_trigger = true; is_silent = true; - args = &args[m_PrivTriggerSize]; + args = &m_ArgSBackup[m_PrivTriggerSize]; } /** diff -r 32e36d3570f0 -r c2836eb6c34a plugins/basebans.sp --- a/plugins/basebans.sp Thu Feb 27 23:46:51 2014 -0500 +++ b/plugins/basebans.sp Fri Feb 28 10:38:36 2014 -0500 @@ -398,14 +398,9 @@ if(g_IsWaitingForChatReason[client]) { g_IsWaitingForChatReason[client] = false; - - decl String:message[192]; - GetCmdArgString(message, sizeof(message)); - StripQuotes(message); - - PrepareBan(client, g_BanTarget[client], g_BanTime[client], message); - - return Plugin_Handled; + PrepareBan(client, g_BanTarget[client], g_BanTime[client], sArgs); + return Plugin_Stop; } + return Plugin_Continue; -} \ No newline at end of file +} diff -r 32e36d3570f0 -r c2836eb6c34a plugins/basecomm.sp --- a/plugins/basecomm.sp Thu Feb 27 23:46:51 2014 -0500 +++ b/plugins/basecomm.sp Fri Feb 28 10:38:36 2014 -0500 @@ -98,22 +98,6 @@ { OnAdminMenuReady(topmenu); } - - // Normally, OnClientSayCommand would be aqequate and more appropirate here, but it does - // not catch attempted chat triggers, which we also want to be blocked if a player is gagged. - AddCommandListener(Command_Say, "say"); - AddCommandListener(Command_Say, "say_team"); - - new String:gameDir[64]; - GetGameFolderName(gameDir, sizeof(gameDir)); - if (StrEqual(gameDir, "insurgency", false)) - { - AddCommandListener(Command_Say, "say2"); - } - else if (StrEqual(gameDir, "nucleardawn", false)) - { - AddCommandListener(Command_Say, "say_squad"); - } } public OnAdminMenuReady(Handle:topmenu) @@ -167,14 +151,11 @@ return true; } -public Action:Command_Say(client, const String:command[], argc) +public Action:OnClientSayCommand(client, const String:command[], const String:sArgs[]) { - if (client) + if (client && g_Gagged[client]) { - if (g_Gagged[client]) - { - return Plugin_Stop; - } + return Plugin_Stop; } return Plugin_Continue; diff -r 32e36d3570f0 -r c2836eb6c34a plugins/basetriggers.sp --- a/plugins/basetriggers.sp Thu Feb 27 23:46:51 2014 -0500 +++ b/plugins/basetriggers.sp Fri Feb 28 10:38:36 2014 -0500 @@ -251,27 +251,11 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArgs[]) { - decl String:text[192]; - new startidx = 0; - - if (strcopy(text, sizeof(text), sArgs) < 1) - { - return; - } - - if (text[0] == '"') - { - startidx = 1; - } - - if ((strcmp(command, "say2", false) == 0) && strlen(sArgs) >= 4) - startidx += 4; - - if (strcmp(text[startidx], "timeleft", false) == 0) + if (strcmp(sArgs, "timeleft", false) == 0) { ShowTimeLeft(client, TIMELEFT_ALL_MAYBE); } - else if (strcmp(text[startidx], "thetime", false) == 0) + else if (strcmp(sArgs, "thetime", false) == 0) { decl String:ctime[64]; FormatTime(ctime, 64, NULL_STRING); @@ -285,11 +269,11 @@ PrintToChat(client,"[SM] %t", "Thetime", ctime); } } - else if (strcmp(text[startidx], "ff", false) == 0) + else if (strcmp(sArgs, "ff", false) == 0) { ShowFriendlyFire(client); } - else if (strcmp(text[startidx], "currentmap", false) == 0) + else if (strcmp(sArgs, "currentmap", false) == 0) { decl String:map[64]; GetCurrentMap(map, sizeof(map)); @@ -303,7 +287,7 @@ PrintToChat(client,"[SM] %t", "Current Map", map); } } - else if (strcmp(text[startidx], "nextmap", false) == 0) + else if (strcmp(sArgs, "nextmap", false) == 0) { decl String:map[32]; GetNextMap(map, sizeof(map)); @@ -331,7 +315,7 @@ } } } - else if (strcmp(text[startidx], "motd", false) == 0) + else if (strcmp(sArgs, "motd", false) == 0) { ShowMOTDPanel(client, "Message Of The Day", "motd", MOTDPANEL_TYPE_INDEX); }