From 66e6a2dbf0d9ccc7af0cc549233fcd9c2c8222c3 Mon Sep 17 00:00:00 2001 From: carnie Date: Sun, 31 Mar 2013 11:26:22 +0100 Subject: [PATCH 1/2] Mobs each now have a unique tag which are not after they are deleted (unlike byond's \ref[] macro) Since tag replaces the output of the \ref[] macro, this means that menus which use hrefs with \ref[mob] will no longer be able to accidentally link to the wrong mob. The tags are of the form "mob_475" etc Admin_pms now use ckey instead of client-reference. This means that PMs will no longer accidentally get sent to the wrong people. There is no risk of players using hrefs to send adminhelps to known admin ckeys to see if they are online (as I'd already changed the PM system to not tell non-admin users whom received their message). key_name() now accepts text input (key or ckey) - it is slightly more efficient to feed it a client or mob however! This functionality is provided to allow certain admintools to become more robust when we want to talk about e.g. a griefer whom has just DCed whom no-longer has a corpse (no client/mob...just a ckey reference). key_name() now reports DCed players properly. --- code/__HELPERS/unsorted.dm | 26 ++-- code/modules/admin/admin.dm | 130 +++++++++--------- code/modules/admin/player_panel.dm | 81 +++++------ code/modules/admin/topic.dm | 2 +- code/modules/admin/verbs/adminpm.dm | 11 +- code/modules/client/client procs.dm | 13 +- code/modules/mob/living/carbon/human/life.dm | 8 -- .../modules/mob/living/silicon/decoy/decoy.dm | 1 + .../mob/living/silicon/pai/software.dm | 3 - code/modules/mob/login.dm | 4 +- code/modules/mob/mob.dm | 2 + code/modules/mob/new_player/new_player.dm | 1 + 12 files changed, 139 insertions(+), 143 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 353e0f46ead..7710d2cfec0 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -478,36 +478,46 @@ Turf and target are seperate in case you want to teleport some distance from a t var/mob/M var/client/C var/key + var/ckey if(!whom) return "*null*" if(istype(whom, /client)) C = whom M = C.mob key = C.key + ckey = C.ckey else if(ismob(whom)) M = whom C = M.client key = M.key - else if(istype(whom, /datum)) - var/datum/D = whom - return "*invalid:[D.type]*" + ckey = M.ckey + else if(istext(whom)) + key = whom + ckey = ckey(whom) + C = directory[ckey] + if(C) + M = C.mob else return "*invalid*" . = "" + if(!ckey) + include_link = 0 + if(key) - if(include_link && C) - . += "" - + if(include_link) + . += "" + if(C && C.holder && C.holder.fakekey && !include_name) . += "Administrator" else . += key + if(!C) + . += "\[DC\]" if(include_link) - if(C) . += "" - else . += " (DC)" + . += "" else . += "*no key*" diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 1055324f57d..d0fdbe4b182 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -17,62 +17,60 @@ var/global/floorIsLava = 0 set name = "Show Player Panel" set desc="Edit player (respawn, ban, heal, etc)" + if(!check_rights()) + return + if(!M) usr << "You seem to be selecting a mob that doesn't exist anymore." return - if (!istype(src,/datum/admins)) - src = usr.client.holder - if (!istype(src,/datum/admins)) - usr << "Error: you are not an admin!" - return var/body = "Options for [M.key]" body += "Options panel for [M]" if(M.client) body += " played by [M.client] " - body += "\[[M.client.holder ? M.client.holder.rank : "Player"]\]" + body += "\[[M.client.holder ? M.client.holder.rank : "Player"]\]" if(istype(M, /mob/new_player)) body += " Hasn't Entered Game " else - body += " \[Heal\] " + body += " \[Heal\] " body += "

\[ " body += "VV - " - body += "TP - " - body += "PM - " - body += "SM - " - body += "JMP\]
" + body += "TP - " + body += "PM - " + body += "SM - " + body += "JMP\]
" body += "Mob type = [M.type]

" - body += "Kick | " + body += "Kick | " body += "Warn | " - body += "Ban | " - body += "Jobban | " - body += "Appearance Ban | " - body += "Notes " + body += "Ban | " + body += "Jobban | " + body += "Appearance Ban | " + body += "Notes " if(M.client) - body += "| Prison | " + body += "| Prison | " var/muted = M.client.prefs.muted body += "
Mute: " - body += "\[IC | " - body += "OOC | " - body += "PRAY | " - body += "ADMINHELP | " - body += "DEADCHAT\]" - body += "(toggle all)" + body += "\[IC | " + body += "OOC | " + body += "PRAY | " + body += "ADMINHELP | " + body += "DEADCHAT\]" + body += "(toggle all)" body += "

" - body += "Jump to | " - body += "Get | " - body += "Send To" + body += "Jump to | " + body += "Get | " + body += "Send To" body += "

" - body += "Traitor panel | " - body += "Narrate to | " - body += "Subtle message" + body += "Traitor panel | " + body += "Narrate to | " + body += "Subtle message" if (M.client) if(!istype(M, /mob/new_player)) @@ -84,66 +82,66 @@ var/global/floorIsLava = 0 if(ismonkey(M)) body += "Monkeyized | " else - body += "Monkeyize | " + body += "Monkeyize | " //Corgi if(iscorgi(M)) body += "Corgized | " else - body += "Corgize | " + body += "Corgize | " //AI / Cyborg if(isAI(M)) body += "Is an AI " else if(ishuman(M)) - body += "Make AI | " - body += "Make Robot | " - body += "Make Alien | " - body += "Make Blob Fragment | " - body += "Make Slime " + body += "Make AI | " + body += "Make Robot | " + body += "Make Alien | " + body += "Make Blob Fragment | " + body += "Make Slime " //Simple Animals if(isanimal(M)) - body += "Re-Animalize | " + body += "Re-Animalize | " else - body += "Animalize | " + body += "Animalize | " body += "

" body += "Rudimentary transformation:
These transformations only create a new mob type and copy stuff over. They do not take into account MMIs and similar mob-specific things. The buttons in 'Transformations' are preferred, when possible.

" - body += "Observer | " - body += "\[ Alien: Drone, " - body += "Hunter, " - body += "Queen, " - body += "Sentinel, " - body += "Larva \] " - body += "Human " - body += "\[ slime: Baby, " - body += "Adult \] " - body += "Monkey | " - body += "Cyborg | " - body += "Cat | " - body += "Runtime | " - body += "Corgi | " - body += "Ian | " - body += "Crab | " - body += "Coffee | " - //body += "Parrot | " - //body += "Poly | " - body += "\[ Construct: Armoured , " - body += "Builder , " - body += "Wraith \] " - body += "Shade" + body += "Observer | " + body += "\[ Alien: Drone, " + body += "Hunter, " + body += "Queen, " + body += "Sentinel, " + body += "Larva \] " + body += "Human " + body += "\[ slime: Baby, " + body += "Adult \] " + body += "Monkey | " + body += "Cyborg | " + body += "Cat | " + body += "Runtime | " + body += "Corgi | " + body += "Ian | " + body += "Crab | " + body += "Coffee | " + //body += "Parrot | " + //body += "Poly | " + body += "\[ Construct: Armoured , " + body += "Builder , " + body += "Wraith \] " + body += "Shade" body += "
" if (M.client) body += "

" body += "Other actions:" body += "
" - body += "Forcesay | " - body += "Thunderdome 1 | " - body += "Thunderdome 2 | " - body += "Thunderdome Admin | " - body += "Thunderdome Observer | " + body += "Forcesay | " + body += "Thunderdome 1 | " + body += "Thunderdome 2 | " + body += "Thunderdome Admin | " + body += "Thunderdome Observer | " body += "
" body += "" diff --git a/code/modules/admin/player_panel.dm b/code/modules/admin/player_panel.dm index cc389291a3c..1fbd7a6dc39 100644 --- a/code/modules/admin/player_panel.dm +++ b/code/modules/admin/player_panel.dm @@ -1,5 +1,5 @@ /datum/admins/proc/player_panel_new()//The new one - if (!usr.client.holder) + if(!check_rights()) return var/dat = "Player Panel" @@ -65,6 +65,7 @@ clearAll(); var span = document.getElementById(id); + var ckey = key.toLowerCase().replace(/\[^a-z@0-9\]+/g,""); body = "
"; @@ -74,15 +75,15 @@ body += ""; - body += "PP - " - body += "N - " + body += "PP - " + body += "N - " body += "VV - " - body += "TP - " - body += "PM - " - body += "SM - " - body += "JMP
" + body += "TP - " + body += "PM - " + body += "SM - " + body += "JMP
" if(antagonist > 0) - body += "Antagonist"; + body += "Antagonist"; body += "
"; @@ -193,7 +194,7 @@ Player panel
- Hover over a line to see more information - Check antagonists + Hover over a line to see more information - Check antagonists

@@ -319,7 +320,7 @@ //The old one /datum/admins/proc/player_panel_old() - if (!usr.client.holder) + if(!check_rights()) return var/dat = "Player Menu" dat += "" @@ -360,16 +361,16 @@ dat += {" - - + + "} switch(is_special_character(M)) if(0) - dat += {""} + dat += {""} if(1) - dat += {""} + dat += {""} if(2) - dat += {""} + dat += {""} dat += "
NameReal NameAssigned JobKeyOptionsPMTraitor?
[(M.client ? "[M.client]" : "No client")]XPMXPMTraitor?Traitor?Traitor?Traitor?Traitor?Traitor?
" @@ -384,23 +385,23 @@ dat += "Round Duration: [round(world.time / 36000)]:[add_zero(world.time / 600 % 60, 2)]:[world.time / 100 % 6][world.time / 100 % 10]
" dat += "Emergency shuttle
" if (!emergency_shuttle.online) - dat += "Call Shuttle
" + dat += "Call Shuttle
" else var/timeleft = emergency_shuttle.timeleft() switch(emergency_shuttle.location) if(0) - dat += "ETA: [(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]
" - dat += "Send Back
" + dat += "ETA: [(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]
" + dat += "Send Back
" if(1) - dat += "ETA: [(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]
" - dat += "[ticker.delay_end ? "End Round Normally" : "Delay Round End"]
" + dat += "ETA: [(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]
" + dat += "[ticker.delay_end ? "End Round Normally" : "Delay Round End"]
" if(ticker.mode.syndicates.len) dat += "
" for(var/datum/mind/N in ticker.mode.syndicates) var/mob/M = N.current if(M) - dat += "" - dat += "" + dat += "" + dat += "" else dat += "" dat += "
Syndicates
[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]PM
[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]PM
Nuclear Operative not found!

" @@ -410,7 +411,7 @@ while(!istype(disk_loc, /turf)) if(istype(disk_loc, /mob)) var/mob/M = disk_loc - dat += "carried by [M.real_name] " + dat += "carried by [M.real_name] " if(istype(disk_loc, /obj)) var/obj/O = disk_loc dat += "in \a [O.name] " @@ -425,19 +426,19 @@ if(!M) dat += "" else - dat += "" - dat += "" + dat += "" + dat += "" for(var/datum/mind/N in ticker.mode.revolutionaries) var/mob/M = N.current if(M) - dat += "" - dat += "" + dat += "" + dat += "" dat += "
Nuclear Disk(s)
Head Revolutionary not found!
[M.real_name] (Leader)[M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]PM
[M.real_name] (Leader)[M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]PM
[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]PM
[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]PM
" for(var/datum/mind/N in ticker.mode.get_living_heads()) var/mob/M = N.current if(M) - dat += "" - dat += "" + dat += "" + dat += "" var/turf/mob_loc = get_turf_loc(M) dat += "" else @@ -449,9 +450,9 @@ for(var/datum/mind/changeling in ticker.mode.changelings) var/mob/M = changeling.current if(M) - dat += "" - dat += "" - dat += "" + dat += "" + dat += "" + dat += "" else dat += "" dat += "
Target(s)Location
[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]PM
[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]PM[mob_loc.loc]
[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]PMShow Objective
[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]PMShow Objective
Changeling not found!
" @@ -461,9 +462,9 @@ for(var/datum/mind/wizard in ticker.mode.wizards) var/mob/M = wizard.current if(M) - dat += "[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]" - dat += "PM" - dat += "Show Objective" + dat += "[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]" + dat += "PM" + dat += "Show Objective" else dat += "Wizard not found!" dat += "" @@ -473,8 +474,8 @@ for(var/datum/mind/N in ticker.mode.cult) var/mob/M = N.current if(M) - dat += "[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]" - dat += "PM" + dat += "[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]" + dat += "PM" dat += "" if(ticker.mode.traitors.len > 0) @@ -482,9 +483,9 @@ for(var/datum/mind/traitor in ticker.mode.traitors) var/mob/M = traitor.current if(M) - dat += "[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]" - dat += "PM" - dat += "Show Objective" + dat += "[M.real_name][M.client ? "" : " (logged out)"][M.stat == 2 ? " (DEAD)" : ""]" + dat += "PM" + dat += "Show Objective" else dat += "Traitor not found!" dat += "" diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 8462b271f1a..c78537d420e 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -1343,7 +1343,7 @@ src.owner << "Name = [M.name]; Real_name = [M.real_name]; Mind_name = [M.mind?"[M.mind.name]":""]; Key = [M.key];" src.owner << "Location = [location_description];" src.owner << "[special_role_description]" - src.owner << "(PM) (PP) (VV) (SM) (JMP) (CA)" + src.owner << "(PM) (PP) (VV) (SM) (JMP) (CA)" else if(href_list["adminspawncookie"]) if(!check_rights(R_ADMIN|R_FUN)) return diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm index 56f0156dce2..2445db29315 100644 --- a/code/modules/admin/verbs/adminpm.dm +++ b/code/modules/admin/verbs/adminpm.dm @@ -35,12 +35,17 @@ //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(var/client/C, var/msg) +/client/proc/cmd_admin_pm(whom, msg) if(prefs.muted & MUTE_ADMINHELP) src << "Error: Admin-PM: You are unable to use admin PM-s (muted)." return - - if(!istype(C,/client)) + + var/client/C + if(istext(whom)) + C = directory[whom] + else if(istype(whom,/client)) + C = whom + if(!C) if(holder) src << "Error: Admin-PM: Client not found." else adminhelp(msg) //admin we are replying to left. adminhelp instead return diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index e462eeb5b4b..171c31fabb9 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -29,20 +29,9 @@ return next_allowed_topic_time = world.time + TOPIC_SPAM_DELAY - //search the href for script injection - if( findtext(href,"?) (VV) (PM) (JMP)") - */ //Apparently, the person who wrote this code designed it so that //blinded get reset each cycle and then get activated later in the //code. Very ugly. I dont care. Moving this stuff here so its easy diff --git a/code/modules/mob/living/silicon/decoy/decoy.dm b/code/modules/mob/living/silicon/decoy/decoy.dm index acabb07d59d..5db44b05608 100644 --- a/code/modules/mob/living/silicon/decoy/decoy.dm +++ b/code/modules/mob/living/silicon/decoy/decoy.dm @@ -6,6 +6,7 @@ canmove = 0 /mob/living/silicon/decoy/New() + ..() src.icon = 'icons/mob/AI.dmi' src.icon_state = "ai" src.anchored = 1 diff --git a/code/modules/mob/living/silicon/pai/software.dm b/code/modules/mob/living/silicon/pai/software.dm index 6c7956c086f..dc3bd9d0f60 100644 --- a/code/modules/mob/living/silicon/pai/software.dm +++ b/code/modules/mob/living/silicon/pai/software.dm @@ -116,9 +116,6 @@ /mob/living/silicon/pai/Topic(href, href_list) ..() - - if(href_list["priv_msg"]) // Admin-PMs were triggering the interface popup. Hopefully this will stop it. - return var/soft = href_list["software"] var/sub = href_list["sub"] if(soft) diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm index 1c3498802d1..0bd910cb5c3 100644 --- a/code/modules/mob/login.dm +++ b/code/modules/mob/login.dm @@ -17,10 +17,10 @@ spawn() alert("You have logged in already with another key this round, please log out of this one NOW or risk being banned!") if(matches) if(M.client) - message_admins("Notice: [key_name_admin(src)] has the same [matches] as [key_name_admin(M)].", 1) + message_admins("Notice: [key_name_admin(src)] has the same [matches] as [key_name_admin(M)].", 1) log_access("Notice: [key_name(src)] has the same [matches] as [key_name(M)].") else - message_admins("Notice: [key_name_admin(src)] has the same [matches] as [key_name_admin(M)] (no longer logged in). ", 1) + message_admins("Notice: [key_name_admin(src)] has the same [matches] as [key_name_admin(M)] (no longer logged in). ", 1) log_access("Notice: [key_name(src)] has the same [matches] as [key_name(M)] (no longer logged in).") /mob/Login() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index faa3d0ea514..b4c7d46ec4d 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -5,7 +5,9 @@ ghostize() ..() +var/next_mob_id = 0 /mob/New() + tag = "mob_[next_mob_id++]" mob_list += src if(stat == DEAD) dead_mob_list += src diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index f7abec2be59..ea13dccbb0e 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -15,6 +15,7 @@ anchored = 1 // don't get pushed around New() + tag = "mob_[next_mob_id++]" mob_list += src verb/new_player_panel() From 8c489f662b50fc4a561a51729e97a8525bc6d5a0 Mon Sep 17 00:00:00 2001 From: carnie Date: Sun, 31 Mar 2013 23:06:56 +0100 Subject: [PATCH 2/2] Muting now uses uses a ckey in its href rather than a mob reference. You can now mute admins. --- code/modules/admin/admin.dm | 16 +++---- code/modules/admin/player_notes.dm | 8 ++-- code/modules/admin/player_panel.dm | 22 ++-------- code/modules/admin/topic.dm | 16 +------ code/modules/admin/verbs/randomverbs.dm | 58 ++++++++++++++----------- code/modules/client/client procs.dm | 2 +- 6 files changed, 50 insertions(+), 72 deletions(-) diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index d0fdbe4b182..617454e911f 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -38,7 +38,7 @@ var/global/floorIsLava = 0 body += "

\[ " body += "VV - " body += "TP - " - body += "PM - " + body += "PM - " body += "SM - " body += "JMP\]
" @@ -49,18 +49,18 @@ var/global/floorIsLava = 0 body += "Ban | " body += "Jobban | " body += "Appearance Ban | " - body += "Notes " + body += "Notes " if(M.client) body += "| Prison | " var/muted = M.client.prefs.muted body += "
Mute: " - body += "\[IC | " - body += "OOC | " - body += "PRAY | " - body += "ADMINHELP | " - body += "DEADCHAT\]" - body += "(toggle all)" + body += "\[IC | " + body += "OOC | " + body += "PRAY | " + body += "ADMINHELP | " + body += "DEADCHAT\]" + body += "(toggle all)" body += "

" body += "Jump to | " diff --git a/code/modules/admin/player_notes.dm b/code/modules/admin/player_notes.dm index 70de3b1c125..66b409d439b 100644 --- a/code/modules/admin/player_notes.dm +++ b/code/modules/admin/player_notes.dm @@ -12,19 +12,19 @@ datum/admins/proc/notes_gethtml(var/ckey) var/savefile/notesfile = new(NOTESFILE) if(!notesfile) return "Error: Cannot access [NOTESFILE]" if(ckey) - . = "Notes for [ckey]: \[+\] \[-\]
" + . = "Notes for [ckey]: \[+\] \[-\]
" notesfile.cd = "/[ckey]" var/index = 1 while( !notesfile.eof ) var/note notesfile >> note - . += "[note] \[-\]
" + . += "[note] \[-\]
" index++ else - . = "All Notes: \[+\] \[-\]
" + . = "All Notes: \[+\] \[-\]
" notesfile.cd = "/" for(var/dir in notesfile.dir) - . += "[dir]
" + . += "[dir]
" return diff --git a/code/modules/admin/player_panel.dm b/code/modules/admin/player_panel.dm index 1fbd7a6dc39..933632719d5 100644 --- a/code/modules/admin/player_panel.dm +++ b/code/modules/admin/player_panel.dm @@ -76,7 +76,7 @@ body += ""; body += "PP - " - body += "N - " + body += "N - " body += "VV - " body += "TP - " body += "PM - " @@ -266,23 +266,9 @@ else if(isobserver(M)) M_job = "Ghost" - M_job = replacetext(M_job, "'", "") - M_job = replacetext(M_job, "\"", "") - M_job = replacetext(M_job, "\\", "") - - var/M_name = M.name - M_name = replacetext(M_name, "'", "") - M_name = replacetext(M_name, "\"", "") - M_name = replacetext(M_name, "\\", "") - var/M_rname = M.real_name - M_rname = replacetext(M_rname, "'", "") - M_rname = replacetext(M_rname, "\"", "") - M_rname = replacetext(M_rname, "\\", "") - - var/M_key = M.key - M_key = replacetext(M_key, "'", "") - M_key = replacetext(M_key, "\"", "") - M_key = replacetext(M_key, "\\", "") + var/M_name = html_encode(M.name) + var/M_rname = html_encode(M.real_name) + var/M_key = html_encode(M.key) //output for each mob dat += {" diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index c78537d420e..038c47c7545 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -828,11 +828,6 @@ //Player Notes else if(href_list["notes"]) var/ckey = href_list["ckey"] - if(!ckey) - var/mob/M = locate(href_list["mob"]) - if(ismob(M)) - ckey = M.ckey - switch(href_list["notes"]) if("show") notes_show(ckey) @@ -933,16 +928,7 @@ else if(href_list["mute"]) if(!check_rights(R_ADMIN)) return - - var/mob/M = locate(href_list["mute"]) - if(!ismob(M)) return - if(!M.client) return - - var/mute_type = href_list["mute_type"] - if(istext(mute_type)) mute_type = text2num(mute_type) - if(!isnum(mute_type)) return - - cmd_admin_mute(M, mute_type) + cmd_admin_mute(href_list["mute"], text2num(href_list["mute_type"])) else if(href_list["c_mode"]) if(!check_rights(R_ADMIN)) return diff --git a/code/modules/admin/verbs/randomverbs.dm b/code/modules/admin/verbs/randomverbs.dm index 0903627d067..117872d34df 100644 --- a/code/modules/admin/verbs/randomverbs.dm +++ b/code/modules/admin/verbs/randomverbs.dm @@ -120,25 +120,12 @@ feedback_add_details("admin_verb","GOD") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! -proc/cmd_admin_mute(mob/M as mob, mute_type, automute = 0) - if(automute) - if(!config.automute_on) return - else - if(!usr || !usr.client) - return - if(!usr.client.holder) - usr << "Error: cmd_admin_mute: You don't have permission to do this." - return - if(!M.client) - usr << "Error: cmd_admin_mute: This mob doesn't have a client tied to it." - if(M.client.holder) - usr << "Error: cmd_admin_mute: You cannot mute an admin." - if(!M.client) return - if(M.client.holder) return +proc/cmd_admin_mute(whom, mute_type, automute = 0) + if(!whom) + return var/muteunmute var/mute_string - switch(mute_type) if(MUTE_IC) mute_string = "IC (say and emote)" if(MUTE_OOC) mute_string = "OOC" @@ -147,26 +134,45 @@ proc/cmd_admin_mute(mob/M as mob, mute_type, automute = 0) if(MUTE_DEADCHAT) mute_string = "deadchat and DSAY" if(MUTE_ALL) mute_string = "everything" else return + + var/client/C + if(istype(whom, /client)) + C = whom + else if(istext(whom)) + C = directory[whom] + else + return + + var/datum/preferences/P + if(C) P = C.prefs + else P = preferences_datums[whom] + if(!P) return + + if(automute) + if(!config.automute_on) return + else + if(!check_rights()) + return if(automute) muteunmute = "auto-muted" - M.client.prefs.muted |= 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) - M << "You have been [muteunmute] from [mute_string] by the SPAM AUTOMUTE system. Contact an admin." + P.muted |= mute_type + log_admin("SPAM AUTOMUTE: [muteunmute] [key_name(whom)] from [mute_string]") + message_admins("SPAM AUTOMUTE: [muteunmute] [key_name_admin(whom)] from [mute_string].", 1) + if(C) C << "You have been [muteunmute] from [mute_string] by the SPAM AUTOMUTE system. Contact an admin." feedback_add_details("admin_verb","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) + if(P.muted & mute_type) muteunmute = "unmuted" - M.client.prefs.muted &= ~mute_type + P.muted &= ~mute_type else muteunmute = "muted" - M.client.prefs.muted |= mute_type + P.muted |= mute_type - 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) - M << "You have been [muteunmute] from [mute_string]." + log_admin("[key_name(usr)] has [muteunmute] [key_name(whom)] from [mute_string]") + message_admins("[key_name_admin(usr)] has [muteunmute] [key_name_admin(whom)] from [mute_string].", 1) + if(C) C << "You have been [muteunmute] from [mute_string]." feedback_add_details("admin_verb","MUTE") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 171c31fabb9..5d3b65f9047 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -51,7 +51,7 @@ src.last_message_count++ if(src.last_message_count >= SPAM_TRIGGER_AUTOMUTE) src << "\red You have exceeded the spam filter limit for identical messages. An auto-mute was applied." - cmd_admin_mute(src.mob, mute_type, 1) + cmd_admin_mute(src, mute_type, 1) return 1 if(src.last_message_count >= SPAM_TRIGGER_WARNING) src << "\red You are nearing the spam filter limit for identical messages."