From: z411 Date: Thu, 27 Aug 2020 17:46:38 +0000 (-0400) Subject: Chat sounds fix X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=832ea8fadd0b0ede2475cdef518238abb510cc65;p=xonotic%2Fxonotic-data.pk3dir.git Chat sounds fix --- diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index fde395d7d..f1e3f0040 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -3155,6 +3155,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc FOREACH_CLIENT(!(IS_PLAYER(it) || it.caplayer) && IS_REAL_CLIENT(it) && it != source && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), { sprint(it, msgstr); }); + play_chatsound(source, msgin); event_log_msg = sprintf(":chat_spec:%d:%s", source.playerid, strreplace("\n", " ", msgin)); } else @@ -3167,6 +3168,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), { sprint(it, msgstr); }); + play_chatsound(source, msgin); event_log_msg = sprintf(":chat:%d:%s", source.playerid, strreplace("\n", " ", msgin)); } } @@ -3175,16 +3177,23 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc GameLogEcho(event_log_msg); } - var .float flood_sound = floodcontrol_chatsound; - if(autocvar_g_chat_sounds && sourcemsgstr != "" && ret > 0) { - bprintf("%d < %d", source.(flood_sound), time - autocvar_g_chat_sounds_flood); + + return ret; +} + +void play_chatsound(entity source, string msgin) +{ + if(autocvar_g_chat_sounds) { + var .float flood_sound = floodcontrol_chatsound; + + //bprintf("%d < %d", source.(flood_sound), time - autocvar_g_chat_sounds_flood); if (source.(flood_sound) < time - autocvar_g_chat_sounds_flood) { string rawmsg; rawmsg = strreplace("\n", " ", msgin); - bprintf("msg is %s and list is %s\n", rawmsg, autocvar_g_chat_sounds_list); + //bprintf("msg is %s and list is %s\n", rawmsg, autocvar_g_chat_sounds_list); if (findinlist_abbrev(rawmsg, autocvar_g_chat_sounds_list)) { bprintf("IN LIST!!!\n"); play2all(strcat("sound/chat/", rawmsg, ".ogg")); @@ -3193,10 +3202,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc } } } - - return ret; } - // hack to copy the button fields from the client entity to the Client State void PM_UpdateButtons(entity this, entity store) { diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 448508017..81f054be0 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -29,6 +29,7 @@ .string playerskin; void ClientState_attach(entity this); +void play_chatsound(entity source, string msgin); IntrusiveList g_players; STATIC_INIT(g_players) { g_players = IL_NEW(); }