From fce28287243ab9cd3140cae1bb80f10867d44b41 Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Tue, 7 Sep 2021 15:09:37 +0100
Subject: [PATCH] Moves mutes to a GLOB
---
code/game/gamemodes/blob/overmind.dm | 4 +--
code/game/gamemodes/miniantags/borer/borer.dm | 4 +--
code/game/objects/items/devices/megaphone.dm | 2 +-
code/game/verbs/ooc.dm | 4 +--
code/modules/admin/admin.dm | 13 ++++----
code/modules/admin/mute.dm | 32 +++++++++++++++++++
code/modules/admin/verbs/adminhelp.dm | 2 +-
code/modules/admin/verbs/adminpm.dm | 4 +--
code/modules/admin/verbs/deadsay.dm | 2 +-
code/modules/admin/verbs/pray.dm | 2 +-
code/modules/admin/verbs/randomverbs.dm | 12 +++----
code/modules/client/client_procs.dm | 2 +-
code/modules/client/preference/preferences.dm | 1 -
code/modules/mob/dead/observer/say.dm | 2 +-
code/modules/mob/emote.dm | 2 +-
.../mob/living/carbon/alien/larva/emote.dm | 4 +--
code/modules/mob/living/say.dm | 6 ++--
.../mob/living/simple_animal/slime/emote.dm | 4 +--
code/modules/mob/say.dm | 2 +-
paradise.dme | 1 +
20 files changed, 68 insertions(+), 37 deletions(-)
create mode 100644 code/modules/admin/mute.dm
diff --git a/code/game/gamemodes/blob/overmind.dm b/code/game/gamemodes/blob/overmind.dm
index e5da77c8196..02022121209 100644
--- a/code/game/gamemodes/blob/overmind.dm
+++ b/code/game/gamemodes/blob/overmind.dm
@@ -66,10 +66,10 @@
return
if(src.client)
- if(client.prefs.muted & MUTE_IC)
+ if(check_mute(client.ckey, MUTE_IC))
to_chat(src, "You cannot send IC messages (muted).")
return
- if(src.client.handle_spam_prevention(message,MUTE_IC))
+ if(src.client.handle_spam_prevention(message, MUTE_IC))
return
if(stat)
diff --git a/code/game/gamemodes/miniantags/borer/borer.dm b/code/game/gamemodes/miniantags/borer/borer.dm
index b2f07c7e4e6..c39babad9f6 100644
--- a/code/game/gamemodes/miniantags/borer/borer.dm
+++ b/code/game/gamemodes/miniantags/borer/borer.dm
@@ -4,10 +4,10 @@
/mob/living/captive_brain/say(message)
if(client)
- if(client.prefs.muted & MUTE_IC)
+ if(check_mute(client.ckey, MUTE_IC))
to_chat(src, "You cannot speak in IC (muted).")
return
- if(client.handle_spam_prevention(message,MUTE_IC))
+ if(client.handle_spam_prevention(message, MUTE_IC))
return
if(istype(loc,/mob/living/simple_animal/borer))
diff --git a/code/game/objects/items/devices/megaphone.dm b/code/game/objects/items/devices/megaphone.dm
index ce8c6ca7191..ced5a810bf4 100644
--- a/code/game/objects/items/devices/megaphone.dm
+++ b/code/game/objects/items/devices/megaphone.dm
@@ -13,7 +13,7 @@
var/list/insultmsg = list("FUCK EVERYONE!", "I'M A TATER!", "ALL SECURITY TO SHOOT ME ON SIGHT!", "I HAVE A BOMB!", "CAPTAIN IS A COMDOM!", "FOR THE SYNDICATE!")
/obj/item/megaphone/attack_self(mob/living/user as mob)
- if(user.client && (user.client.prefs.muted & MUTE_IC))
+ if(check_mute(user.ckey, MUTE_IC))
to_chat(src, "You cannot speak in IC (muted).")
return
if(!ishuman(user))
diff --git a/code/game/verbs/ooc.dm b/code/game/verbs/ooc.dm
index 458f06e9c19..162e1ebd26e 100644
--- a/code/game/verbs/ooc.dm
+++ b/code/game/verbs/ooc.dm
@@ -25,7 +25,7 @@ GLOBAL_VAR_INIT(admin_ooc_colour, "#b82e00")
if(!GLOB.dooc_enabled && (mob.stat == DEAD))
to_chat(usr, "OOC for dead mobs has been turned off.")
return
- if(prefs.muted & MUTE_OOC)
+ if(check_mute(ckey, MUTE_OOC))
to_chat(src, "You cannot use OOC (muted).")
return
@@ -181,7 +181,7 @@ GLOBAL_VAR_INIT(admin_ooc_colour, "#b82e00")
if(!GLOB.dooc_enabled && (mob.stat == DEAD))
to_chat(usr, "LOOC for dead mobs has been turned off.")
return
- if(prefs.muted & MUTE_OOC)
+ if(check_mute(ckey, MUTE_OOC))
to_chat(src, "You cannot use LOOC (muted).")
return
diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm
index 5995e44a40c..5e1d4036171 100644
--- a/code/modules/admin/admin.dm
+++ b/code/modules/admin/admin.dm
@@ -140,14 +140,13 @@ GLOBAL_VAR_INIT(nologevent, 0)
body += "\ Send back to Lobby | "
body += "\ Erase Flavor Text | "
body += "\ Use Random Name | "
- var/muted = M.client.prefs.muted
body += {"
Mute:
- \[IC |
- OOC |
- PRAY |
- ADMINHELP |
- DEADCHAT\]
- (toggle all)
+ \[IC |
+ OOC |
+ PRAY |
+ ADMINHELP |
+ DEADCHAT]
+ (toggle all)
"}
var/jumptoeye = ""
diff --git a/code/modules/admin/mute.dm b/code/modules/admin/mute.dm
new file mode 100644
index 00000000000..cab33a4edda
--- /dev/null
+++ b/code/modules/admin/mute.dm
@@ -0,0 +1,32 @@
+/// Associative list of people who are muted via admin mutes
+GLOBAL_LIST_EMPTY(admin_mutes_assoc)
+
+/proc/check_mute(ckey, muteflag)
+ if(isnull(GLOB.admin_mutes_assoc[ckey]))
+ return FALSE
+
+ if(GLOB.admin_mutes_assoc[ckey] & muteflag)
+ return TRUE
+ return FALSE
+
+/proc/toggle_mute(ckey, muteflag)
+ if(isnull(GLOB.admin_mutes_assoc[ckey]))
+ GLOB.admin_mutes_assoc[ckey] = 0
+
+ if(GLOB.admin_mutes_assoc[ckey] & muteflag)
+ GLOB.admin_mutes_assoc[ckey] &= ~muteflag
+ else
+ GLOB.admin_mutes_assoc[ckey] |= muteflag
+
+/proc/force_add_mute(ckey, muteflag)
+ if(isnull(GLOB.admin_mutes_assoc[ckey]))
+ GLOB.admin_mutes_assoc[ckey] = 0
+
+ GLOB.admin_mutes_assoc[ckey] |= muteflag
+
+/proc/force_remove_mute(ckey, muteflag)
+ if(isnull(GLOB.admin_mutes_assoc[ckey]))
+ GLOB.admin_mutes_assoc[ckey] = 0
+
+ GLOB.admin_mutes_assoc[ckey] &= ~muteflag
+
diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm
index e206f345c0c..3db301985ed 100644
--- a/code/modules/admin/verbs/adminhelp.dm
+++ b/code/modules/admin/verbs/adminhelp.dm
@@ -6,7 +6,7 @@ GLOBAL_LIST_INIT(adminhelp_ignored_words, list("unknown", "the", "a", "an", "of"
set name = "Adminhelp"
//handle muting and automuting
- if(prefs.muted & MUTE_ADMINHELP)
+ if(check_mute(ckey, MUTE_ADMINHELP))
to_chat(src, "Error: Admin-PM: You cannot send adminhelps (Muted).")
return
diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm
index 7186406e7fa..348d5690ecd 100644
--- a/code/modules/admin/verbs/adminpm.dm
+++ b/code/modules/admin/verbs/adminpm.dm
@@ -58,7 +58,7 @@
//takes input from cmd_admin_pm_context, cmd_admin_pm_panel or /client/Topic and sends them a PM.
//Fetching a message if needed. src is the sender and C is the target client
/client/proc/cmd_admin_pm(whom, msg, type = "PM")
- if(prefs.muted & MUTE_ADMINHELP)
+ if(check_mute(ckey, MUTE_ADMINHELP))
to_chat(src, "Error: Private-Message: You are unable to use PM-s (muted).")
return
@@ -212,7 +212,7 @@
return
/client/proc/cmd_admin_discord_pm()
- if(prefs.muted & MUTE_ADMINHELP)
+ if(check_mute(ckey, MUTE_ADMINHELP))
to_chat(src, "Error: Private-Message: You are unable to use PMs (muted).")
return
diff --git a/code/modules/admin/verbs/deadsay.dm b/code/modules/admin/verbs/deadsay.dm
index c3ab3bfe47f..410956c9d2a 100644
--- a/code/modules/admin/verbs/deadsay.dm
+++ b/code/modules/admin/verbs/deadsay.dm
@@ -9,7 +9,7 @@
if(!src.mob)
return
- if(prefs.muted & MUTE_DEADCHAT)
+ if(check_mute(ckey, MUTE_DEADCHAT))
to_chat(src, "You cannot send DSAY messages (muted).")
return
diff --git a/code/modules/admin/verbs/pray.dm b/code/modules/admin/verbs/pray.dm
index 8055c5e7a03..e22b9d50eca 100644
--- a/code/modules/admin/verbs/pray.dm
+++ b/code/modules/admin/verbs/pray.dm
@@ -7,7 +7,7 @@
return
if(usr.client)
- if(usr.client.prefs.muted & MUTE_PRAY)
+ if(check_mute(client.ckey, MUTE_PRAY))
to_chat(usr, "You cannot pray (muted).")
return
if(client.handle_spam_prevention(msg, MUTE_PRAY, OOC_COOLDOWN))
diff --git a/code/modules/admin/verbs/randomverbs.dm b/code/modules/admin/verbs/randomverbs.dm
index c1d226bf2be..b12d3de9963 100644
--- a/code/modules/admin/verbs/randomverbs.dm
+++ b/code/modules/admin/verbs/randomverbs.dm
@@ -230,19 +230,19 @@
if(automute)
muteunmute = "auto-muted"
- M.client.prefs.muted |= mute_type
+ force_add_mute(M.client.ckey, mute_type)
log_admin("SPAM AUTOMUTE: [muteunmute] [key_name(M)] from [mute_string]")
message_admins("SPAM AUTOMUTE: [muteunmute] [key_name_admin(M)] from [mute_string].", 1)
to_chat(M, "You have been [muteunmute] from [mute_string] by the SPAM AUTOMUTE system. Contact an admin.")
SSblackbox.record_feedback("tally", "admin_verb", 1, "Automute") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
return
- if(M.client.prefs.muted & mute_type)
- muteunmute = "unmuted"
- M.client.prefs.muted &= ~mute_type
- else
+ toggle_mute(M.client.ckey, mute_type)
+
+ if(check_mute(M.client.ckey, mute_type))
muteunmute = "muted"
- M.client.prefs.muted |= mute_type
+ else
+ muteunmute = "unmuted"
log_admin("[key_name(usr)] has [muteunmute] [key_name(M)] from [mute_string]")
message_admins("[key_name_admin(usr)] has [muteunmute] [key_name_admin(M)] from [mute_string].", 1)
diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm
index 8c7dc4963f6..a8f01fcc594 100644
--- a/code/modules/client/client_procs.dm
+++ b/code/modules/client/client_procs.dm
@@ -113,7 +113,7 @@
if(!holder && received_discord_pm < world.time - 6000) // Worse they can do is spam discord for 10 minutes
to_chat(usr, "You are no longer able to use this, it's been more then 10 minutes since an admin on Discord has responded to you")
return
- if(prefs.muted & MUTE_ADMINHELP)
+ if(check_mute(ckey, MUTE_ADMINHELP))
to_chat(usr, "You cannot use this as your client has been muted from sending messages to the admins on Discord")
return
cmd_admin_discord_pm()
diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm
index 112b8cdb64f..b4688cb73b4 100644
--- a/code/modules/client/preference/preferences.dm
+++ b/code/modules/client/preference/preferences.dm
@@ -71,7 +71,6 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/max_gear_slots = 0
//non-preference stuff
- var/muted = 0
var/last_ip
var/last_id
diff --git a/code/modules/mob/dead/observer/say.dm b/code/modules/mob/dead/observer/say.dm
index 9e9245d274a..a7dc2c86a9f 100644
--- a/code/modules/mob/dead/observer/say.dm
+++ b/code/modules/mob/dead/observer/say.dm
@@ -19,7 +19,7 @@
log_ghostemote(message, src)
if(src.client)
- if(src.client.prefs.muted & MUTE_DEADCHAT)
+ if(check_mute(client.ckey, MUTE_DEADCHAT))
to_chat(src, "You cannot emote in deadchat (muted).")
return
diff --git a/code/modules/mob/emote.dm b/code/modules/mob/emote.dm
index 12312a4fdff..ae6cd715cec 100644
--- a/code/modules/mob/emote.dm
+++ b/code/modules/mob/emote.dm
@@ -112,7 +112,7 @@
O.show_message(message, m_type)
/mob/proc/emote_dead(message)
- if(client.prefs.muted & MUTE_DEADCHAT)
+ if(check_mute(client.ckey, MUTE_DEADCHAT))
to_chat(src, "You cannot send deadchat emotes (muted).")
return
diff --git a/code/modules/mob/living/carbon/alien/larva/emote.dm b/code/modules/mob/living/carbon/alien/larva/emote.dm
index 9871c735725..e2c2a224831 100644
--- a/code/modules/mob/living/carbon/alien/larva/emote.dm
+++ b/code/modules/mob/living/carbon/alien/larva/emote.dm
@@ -14,10 +14,10 @@
if(silent)
return
if(src.client)
- if(client.prefs.muted & MUTE_IC)
+ if(check_mute(client.ckey, MUTE_IC))
to_chat(src, "You cannot send IC messages (muted).")
return
- if(src.client.handle_spam_prevention(message,MUTE_IC))
+ if(src.client.handle_spam_prevention(message, MUTE_IC))
return
if(stat)
return
diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm
index 43d1c402fd0..0ac3b497530 100644
--- a/code/modules/mob/living/say.dm
+++ b/code/modules/mob/living/say.dm
@@ -110,7 +110,7 @@ GLOBAL_LIST_EMPTY(channel_to_radio_key)
/mob/living/say(message, verb = "says", sanitize = TRUE, ignore_speech_problems = FALSE, ignore_atmospherics = FALSE, ignore_languages = FALSE)
if(client)
- if(client.prefs.muted & MUTE_IC)
+ if(check_mute(client.ckey, MUTE_IC))
to_chat(src, "You cannot speak in IC (Muted).")
return
@@ -297,7 +297,7 @@ GLOBAL_LIST_EMPTY(channel_to_radio_key)
/mob/living/emote(act, type, message, force) //emote code is terrible, this is so that anything that isn't already snowflaked to shit can call the parent and handle emoting sanely
if(client)
- if(client.prefs.muted & MUTE_IC)
+ if(check_mute(client.ckey, MUTE_IC))
to_chat(src, "You cannot speak in IC (Muted).")
return
@@ -352,7 +352,7 @@ GLOBAL_LIST_EMPTY(channel_to_radio_key)
/mob/living/proc/whisper_say(list/message_pieces, verb = "whispers")
if(client)
- if(client.prefs.muted & MUTE_IC)
+ if(check_mute(client.ckey, MUTE_IC))
to_chat(src, "You cannot speak in IC (Muted).")
return
diff --git a/code/modules/mob/living/simple_animal/slime/emote.dm b/code/modules/mob/living/simple_animal/slime/emote.dm
index 0eceec7a124..14ce0de54c8 100644
--- a/code/modules/mob/living/simple_animal/slime/emote.dm
+++ b/code/modules/mob/living/simple_animal/slime/emote.dm
@@ -19,10 +19,10 @@
if(silent)
return
if(src.client)
- if(client.prefs.muted & MUTE_IC)
+ if(check_mute(client.ckey, MUTE_IC))
to_chat(src, "You cannot send IC messages (muted).")
return
- if(src.client.handle_spam_prevention(message,MUTE_IC))
+ if(src.client.handle_spam_prevention(message, MUTE_IC))
return
if(stat)
return
diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm
index e199e81eb69..10d56a99dc0 100644
--- a/code/modules/mob/say.dm
+++ b/code/modules/mob/say.dm
@@ -51,7 +51,7 @@
to_chat(src, "Deadchat is globally muted.")
return
- if(client.prefs.muted & MUTE_DEADCHAT)
+ if(check_mute(client.ckey, MUTE_DEADCHAT))
to_chat(src, "You cannot talk in deadchat (muted).")
return
diff --git a/paradise.dme b/paradise.dme
index 785bd2f6158..cfe41674e94 100644
--- a/paradise.dme
+++ b/paradise.dme
@@ -1176,6 +1176,7 @@
#include "code\modules\admin\holder2.dm"
#include "code\modules\admin\IsBanned.dm"
#include "code\modules\admin\machine_upgrade.dm"
+#include "code\modules\admin\mute.dm"
#include "code\modules\admin\NewBan.dm"
#include "code\modules\admin\outfits.dm"
#include "code\modules\admin\player_panel.dm"