From: Mario Date: Sat, 15 Jul 2017 15:52:28 +0000 (+1000) Subject: Port muted to ClientState and don't call formatmessage if there was no sender (potent... X-Git-Tag: xonotic-v0.8.5~2637 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=355d07ff3736126409b1b612504dbdfc92b7e28c;p=xonotic%2Fxonotic-data.pk3dir.git Port muted to ClientState and don't call formatmessage if there was no sender (potentially fixes a crash if Say is used without a source and includes special replacements) --- diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index c63d26190..eebb7d969 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -34,6 +34,7 @@ CLASS(Client, Object) ATTRIB(Client, playerid, int, this.playerid); ATTRIB(Client, parm_idlesince, int, this.parm_idlesince); + ATTRIB(Client, muted, int, this.muted); METHOD(Client, m_unwind, bool(Client this)); diff --git a/qcsrc/server/command/banning.qc b/qcsrc/server/command/banning.qc index 8a35bec29..446c69de4 100644 --- a/qcsrc/server/command/banning.qc +++ b/qcsrc/server/command/banning.qc @@ -131,7 +131,7 @@ void BanCommand_mute(float request, float argc, string command) // TODO: Add a if (accepted > 0) { - client.muted = true; + CS(client).muted = true; return; } else @@ -212,7 +212,7 @@ void BanCommand_unmute(float request, float argc) if (accepted > 0) { - client.muted = false; + CS(client).muted = false; return; } else diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index 0ca9cb849..70e972da8 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -744,7 +744,8 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc if (!teamsay && !privatesay && substring(msgin, 0, 1) == " ") msgin = substring(msgin, 1, -1); // work around DP say bug (say_team does not have this!) - msgin = formatmessage(source, msgin); + if(source) + msgin = formatmessage(source, msgin); string colorstr; if (!IS_PLAYER(source)) @@ -944,7 +945,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc sourcemsgstr = strcat(privatemsgprefix, substring(sourcemsgstr, privatemsgprefixlen, -1)); int ret; - if(source.muted) + if(source && CS(source).muted) { // always fake the message ret = -1; diff --git a/qcsrc/server/player.qh b/qcsrc/server/player.qh index b9a5fa928..1834bb865 100644 --- a/qcsrc/server/player.qh +++ b/qcsrc/server/player.qh @@ -73,6 +73,4 @@ void MoveToTeam(entity client, float team_colour, float type); void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force); -/** to be used by `prvm_edictset server playernumber muted 1` */ -.float muted; int Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol);