Fix regressions in b2f7d97b1ea7 and update plugins for OnClientSayCommand changes (bug 5986, r=psychonic).
Fix regressions in b2f7d97b1ea7 and update plugins for OnClientSayCommand changes (
bug 5986, r=psychonic).
1.1 --- a/core/ChatTriggers.cpp Thu Feb 27 23:46:51 2014 -0500
1.2 +++ b/core/ChatTriggers.cpp Fri Feb 28 10:38:36 2014 -0500
1.3 @@ -221,22 +221,34 @@
1.4 /* Save these off for post hook as the command data returned from the engine in older engine versions
1.5 * can be NULL, despite the data still being there and valid. */
1.6 m_Arg0Backup = command.Arg(0);
1.7 -
1.8 - /* Handle quoted string sets */
1.9 - bool is_quoted = false;
1.10 size_t len = strlen(args);
1.11
1.12 - /* The engine does not display empty say commands.
1.13 - * So to prevent forwarding it, let's block it. */
1.14 - if (len == 0)
1.15 +#if SOURCE_ENGINE == SE_EPISODEONE
1.16 + if (m_bIsINS)
1.17 {
1.18 - RETURN_META(MRES_SUPERCEDE);
1.19 + if (strcmp(m_Arg0Backup, "say2") == 0 && len >= 4)
1.20 + {
1.21 + args += 4;
1.22 + len -= 4;
1.23 + }
1.24 +
1.25 + if (len == 0)
1.26 + {
1.27 + RETURN_META(MRES_SUPERCEDE);
1.28 + }
1.29 }
1.30 +#endif
1.31
1.32 /* The first pair of quotes are stripped from client say commands, but not console ones.
1.33 * We do not want the forwards to differ from what is displayed.
1.34 * So only strip the first pair of quotes from client say commands. */
1.35 - if (client != 0 && args[0] == '"' && args[len-1] == '"')
1.36 + bool is_quoted = false;
1.37 +
1.38 + if (
1.39 +#if SOURCE_ENGINE == SE_EPISODEONE
1.40 + !m_bIsINS &&
1.41 +#endif
1.42 + client != 0 && args[0] == '"' && args[len-1] == '"')
1.43 {
1.44 /* The server normally won't display empty say commands, but in this case it does.
1.45 * I don't think it's desired so let's block it. */
1.46 @@ -249,7 +261,7 @@
1.47 len--;
1.48 is_quoted = true;
1.49 }
1.50 -
1.51 +
1.52 /* Some? engines strip the last quote when printing the string to chat.
1.53 * This results in having a double-quoted message passed to the OnClientSayCommand ("message") forward,
1.54 * but losing the last quote in the OnClientSayCommand_Post ("message) forward.
1.55 @@ -306,27 +318,20 @@
1.56 RETURN_META(MRES_SUPERCEDE);
1.57 }
1.58
1.59 -#if SOURCE_ENGINE == SE_EPISODEONE
1.60 - if (m_bIsINS && strcmp(m_Arg0Backup, "say2") == 0 && strlen(args) >= 4)
1.61 - {
1.62 - args += 4;
1.63 - }
1.64 -#endif
1.65 -
1.66 bool is_trigger = false;
1.67 bool is_silent = false;
1.68
1.69 /* Check for either trigger */
1.70 - if (m_PubTriggerSize && strncmp(args, m_PubTrigger, m_PubTriggerSize) == 0)
1.71 + if (m_PubTriggerSize && strncmp(m_ArgSBackup, m_PubTrigger, m_PubTriggerSize) == 0)
1.72 {
1.73 is_trigger = true;
1.74 - args = &args[m_PubTriggerSize];
1.75 + args = &m_ArgSBackup[m_PubTriggerSize];
1.76 }
1.77 - else if (m_PrivTriggerSize && strncmp(args, m_PrivTrigger, m_PrivTriggerSize) == 0)
1.78 + else if (m_PrivTriggerSize && strncmp(m_ArgSBackup, m_PrivTrigger, m_PrivTriggerSize) == 0)
1.79 {
1.80 is_trigger = true;
1.81 is_silent = true;
1.82 - args = &args[m_PrivTriggerSize];
1.83 + args = &m_ArgSBackup[m_PrivTriggerSize];
1.84 }
1.85
1.86 /**
2.1 --- a/plugins/basebans.sp Thu Feb 27 23:46:51 2014 -0500
2.2 +++ b/plugins/basebans.sp Fri Feb 28 10:38:36 2014 -0500
2.3 @@ -398,14 +398,9 @@
2.4 if(g_IsWaitingForChatReason[client])
2.5 {
2.6 g_IsWaitingForChatReason[client] = false;
2.7 -
2.8 - decl String:message[192];
2.9 - GetCmdArgString(message, sizeof(message));
2.10 - StripQuotes(message);
2.11 -
2.12 - PrepareBan(client, g_BanTarget[client], g_BanTime[client], message);
2.13 -
2.14 - return Plugin_Handled;
2.15 + PrepareBan(client, g_BanTarget[client], g_BanTime[client], sArgs);
2.16 + return Plugin_Stop;
2.17 }
2.18 +
2.19 return Plugin_Continue;
2.20 -}
2.21 \ No newline at end of file
2.22 +}
3.1 --- a/plugins/basecomm.sp Thu Feb 27 23:46:51 2014 -0500
3.2 +++ b/plugins/basecomm.sp Fri Feb 28 10:38:36 2014 -0500
3.3 @@ -98,22 +98,6 @@
3.4 {
3.5 OnAdminMenuReady(topmenu);
3.6 }
3.7 -
3.8 - // Normally, OnClientSayCommand would be aqequate and more appropirate here, but it does
3.9 - // not catch attempted chat triggers, which we also want to be blocked if a player is gagged.
3.10 - AddCommandListener(Command_Say, "say");
3.11 - AddCommandListener(Command_Say, "say_team");
3.12 -
3.13 - new String:gameDir[64];
3.14 - GetGameFolderName(gameDir, sizeof(gameDir));
3.15 - if (StrEqual(gameDir, "insurgency", false))
3.16 - {
3.17 - AddCommandListener(Command_Say, "say2");
3.18 - }
3.19 - else if (StrEqual(gameDir, "nucleardawn", false))
3.20 - {
3.21 - AddCommandListener(Command_Say, "say_squad");
3.22 - }
3.23 }
3.24
3.25 public OnAdminMenuReady(Handle:topmenu)
3.26 @@ -167,14 +151,11 @@
3.27 return true;
3.28 }
3.29
3.30 -public Action:Command_Say(client, const String:command[], argc)
3.31 +public Action:OnClientSayCommand(client, const String:command[], const String:sArgs[])
3.32 {
3.33 - if (client)
3.34 + if (client && g_Gagged[client])
3.35 {
3.36 - if (g_Gagged[client])
3.37 - {
3.38 - return Plugin_Stop;
3.39 - }
3.40 + return Plugin_Stop;
3.41 }
3.42
3.43 return Plugin_Continue;
4.1 --- a/plugins/basetriggers.sp Thu Feb 27 23:46:51 2014 -0500
4.2 +++ b/plugins/basetriggers.sp Fri Feb 28 10:38:36 2014 -0500
4.3 @@ -251,27 +251,11 @@
4.4
4.5 public OnClientSayCommand_Post(client, const String:command[], const String:sArgs[])
4.6 {
4.7 - decl String:text[192];
4.8 - new startidx = 0;
4.9 -
4.10 - if (strcopy(text, sizeof(text), sArgs) < 1)
4.11 - {
4.12 - return;
4.13 - }
4.14 -
4.15 - if (text[0] == '"')
4.16 - {
4.17 - startidx = 1;
4.18 - }
4.19 -
4.20 - if ((strcmp(command, "say2", false) == 0) && strlen(sArgs) >= 4)
4.21 - startidx += 4;
4.22 -
4.23 - if (strcmp(text[startidx], "timeleft", false) == 0)
4.24 + if (strcmp(sArgs, "timeleft", false) == 0)
4.25 {
4.26 ShowTimeLeft(client, TIMELEFT_ALL_MAYBE);
4.27 }
4.28 - else if (strcmp(text[startidx], "thetime", false) == 0)
4.29 + else if (strcmp(sArgs, "thetime", false) == 0)
4.30 {
4.31 decl String:ctime[64];
4.32 FormatTime(ctime, 64, NULL_STRING);
4.33 @@ -285,11 +269,11 @@
4.34 PrintToChat(client,"[SM] %t", "Thetime", ctime);
4.35 }
4.36 }
4.37 - else if (strcmp(text[startidx], "ff", false) == 0)
4.38 + else if (strcmp(sArgs, "ff", false) == 0)
4.39 {
4.40 ShowFriendlyFire(client);
4.41 }
4.42 - else if (strcmp(text[startidx], "currentmap", false) == 0)
4.43 + else if (strcmp(sArgs, "currentmap", false) == 0)
4.44 {
4.45 decl String:map[64];
4.46 GetCurrentMap(map, sizeof(map));
4.47 @@ -303,7 +287,7 @@
4.48 PrintToChat(client,"[SM] %t", "Current Map", map);
4.49 }
4.50 }
4.51 - else if (strcmp(text[startidx], "nextmap", false) == 0)
4.52 + else if (strcmp(sArgs, "nextmap", false) == 0)
4.53 {
4.54 decl String:map[32];
4.55 GetNextMap(map, sizeof(map));
4.56 @@ -331,7 +315,7 @@
4.57 }
4.58 }
4.59 }
4.60 - else if (strcmp(text[startidx], "motd", false) == 0)
4.61 + else if (strcmp(sArgs, "motd", false) == 0)
4.62 {
4.63 ShowMOTDPanel(client, "Message Of The Day", "motd", MOTDPANEL_TYPE_INDEX);
4.64 }