From 211b09001aecdc5e1b13016cda39f54ba7aa20e4 Mon Sep 17 00:00:00 2001 From: mekolat Date: Thu, 5 May 2016 18:18:38 -0400 Subject: add MUTE params --- src/map/clif.cpp | 24 ++++++++++++++++++++++++ src/map/map.hpp | 8 ++++++++ src/map/pc.cpp | 34 ++++++++++++++++++++++++++++++++++ src/mmo/clif.t.hpp | 4 ++++ 4 files changed, 70 insertions(+) (limited to 'src') diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 81ae02f..bd7f4ef 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -3844,6 +3844,12 @@ RecvResult clif_parse_GlobalMessage(Session *s, dumb_ptr sd) if (is_atcommand(s, sd, mbuf, GmLevel())) return rv; + if (sd->mute.global) + { + clif_displaymessage(s, "Your message could not be sent: you are muted."_s); + return rv; + } + /* Don't send chat that results in an automatic ban. */ if (tmw_CheckChatSpam(sd, mbuf)) { @@ -4188,11 +4194,20 @@ RecvResult clif_parse_Wis(Session *s, dumb_ptr sd) return rv; } + if (magic_message(sd, mbuf)) + return rv; + if (is_atcommand(s, sd, mbuf, GmLevel())) { return rv; } + if (sd->mute.whisper) + { + clif_displaymessage(s, "Your message could not be sent: you are muted."_s); + return rv; + } + /* Don't send chat that results in an automatic ban. */ if (tmw_CheckChatSpam(sd, mbuf)) { @@ -4974,9 +4989,18 @@ RecvResult clif_parse_PartyMessage(Session *s, dumb_ptr sd) return rv; } + if (magic_message(sd, mbuf)) + return rv; + if (is_atcommand(s, sd, mbuf, GmLevel())) return rv; + if (sd->mute.party) + { + clif_displaymessage(s, "Your message could not be sent: you are muted."_s); + return rv; + } + /* Don't send chat that results in an automatic ban. */ if (tmw_CheckChatSpam(sd, mbuf)) { diff --git a/src/map/map.hpp b/src/map/map.hpp index 7732af9..897787e 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -290,6 +290,14 @@ struct map_session_data : block_list, SessionData int chat_total_repeats; RString chat_lastmsg; + struct + { + unsigned global:1; + unsigned party:1; + unsigned whisper:1; + unsigned guild:1; + } mute; + tick_t flood_rates[0x220]; tick_t packet_flood_reset_due; int packet_flood_in; diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 05f61ea..f854ccd 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -827,6 +827,12 @@ int pc_authok(AccountId id, int login_id2, ClientVersion client_version, sd->chat_repeat_reset_due = tick_t(); sd->chat_lastmsg = RString(); + // Initialize mute vars + sd->mute.global = 0; + sd->mute.party = 0; + sd->mute.whisper = 0; + sd->mute.guild = 0; + for (tick_t& t : sd->flood_rates) t = tick_t(); sd->packet_flood_reset_due = tick_t(); @@ -3547,6 +3553,18 @@ int pc_readparam(dumb_ptr bl, SP type) if (sd) val = bool(sd->status.option & Opt0::HIDE); break; + case SP::MUTE_GLOBAL: + val = sd ? sd->mute.global : 0; + break; + case SP::MUTE_PARTY: + val = sd ? sd->mute.party : 0; + break; + case SP::MUTE_WHISPER: + val = sd ? sd->mute.whisper : 0; + break; + case SP::MUTE_GUILD: + val = sd ? sd->mute.guild : 0; + break; } return val; @@ -3770,6 +3788,22 @@ int pc_setparam(dumb_ptr bl, SP type, int val) sd->status.option &= ~Opt0::HIDE; clif_changeoption(sd); break; + case SP::MUTE_GLOBAL: + nullpo_retz(sd); + sd->mute.global = (val == 1); + break; + case SP::MUTE_PARTY: + nullpo_retz(sd); + sd->mute.party = (val == 1); + break; + case SP::MUTE_WHISPER: + nullpo_retz(sd); + sd->mute.whisper = (val == 1); + break; + case SP::MUTE_GUILD: + nullpo_retz(sd); + sd->mute.guild = (val == 1); + break; } return 0; diff --git a/src/mmo/clif.t.hpp b/src/mmo/clif.t.hpp index c23842e..5f07ebd 100644 --- a/src/mmo/clif.t.hpp +++ b/src/mmo/clif.t.hpp @@ -476,6 +476,10 @@ enum class SP : uint16_t CHAR_ID = 1079, INVISIBLE = 1080, HIDDEN = 1081, + MUTE_GLOBAL = 1082, + MUTE_WHISPER = 1083, + MUTE_PARTY = 1084, + MUTE_GUILD = 1085, }; constexpr -- cgit v1.2.3-70-g09d2