Reworks anon dchat mode into full anon mode (#18282)

* Reworks anon dchat mode

* Update code/modules/client/preference/preferences_toggles.dm
This commit is contained in:
AffectedArc07
2022-07-14 16:52:49 +01:00
committed by GitHub
parent 490de764de
commit 0c0b201668
16 changed files with 97 additions and 33 deletions
+1 -1
View File
@@ -47,7 +47,7 @@
#define PREFTOGGLE_2_FANCYUI 2
#define PREFTOGGLE_2_ITEMATTACK 4
#define PREFTOGGLE_2_WINDOWFLASHING 8
#define PREFTOGGLE_2_ANONDCHAT 16
#define PREFTOGGLE_2_ANON 16
#define PREFTOGGLE_2_AFKWATCH 32
#define PREFTOGGLE_2_RUNECHAT 64
#define PREFTOGGLE_2_DEATHMESSAGE 128
+34 -2
View File
@@ -354,11 +354,11 @@
var/endtime = world.time+time
var/starttime = world.time
. = 1
var/mob/living/L
if(isliving(user))
L = user
while(world.time < endtime)
sleep(1)
if(progress)
@@ -669,3 +669,35 @@ GLOBAL_LIST_INIT(do_after_once_tracker, list())
if(player.stat == CONSCIOUS)
active++
return list(total, active, dead, antag)
/**
* Safe ckey getter
*
* Should be used whenever broadcasting public information about a mob,
* as this proc will make a best effort to hide the users ckey if they request it.
* It will first check the mob for a client, then use the mobs last ckey as a directory lookup.
* If a client cant be found to check preferences on, it will just show as DC'd.
* This proc should only be used for public facing stuff, not administration related things.
*
* Arguments:
* * M - Mob to get a safe ckey of
*/
/proc/safe_get_ckey(mob/M)
var/client/C = null
if(M.client)
C = M.client
else if(M.last_known_ckey in GLOB.directory)
C = GLOB.directory[M.last_known_ckey]
// Now we see if we need to respect their privacy
var/out_ckey
if(C)
if(C.prefs.toggles2 & PREFTOGGLE_2_ANON)
out_ckey = "(Anon)"
else
out_ckey = C.ckey
else
// No client. Just mark as DC'd.
out_ckey = "(Disconnected)"
return out_ckey
+10 -5
View File
@@ -491,16 +491,19 @@ SUBSYSTEM_DEF(ticker)
//Silicon laws report
for(var/mob/living/silicon/ai/aiPlayer in GLOB.mob_list)
var/ai_ckey = safe_get_ckey(aiPlayer)
if(aiPlayer.stat != 2)
to_chat(world, "<b>[aiPlayer.name] (Played by: [aiPlayer.key])'s laws at the end of the game were:</b>")
to_chat(world, "<b>[aiPlayer.name] (Played by: [ai_ckey])'s laws at the end of the game were:</b>")
else
to_chat(world, "<b>[aiPlayer.name] (Played by: [aiPlayer.key])'s laws when it was deactivated were:</b>")
to_chat(world, "<b>[aiPlayer.name] (Played by: [ai_ckey])'s laws when it was deactivated were:</b>")
aiPlayer.show_laws(TRUE)
if(aiPlayer.connected_robots.len)
var/robolist = "<b>The AI's loyal minions were:</b> "
for(var/mob/living/silicon/robot/robo in aiPlayer.connected_robots)
robolist += "[robo.name][robo.stat?" (Deactivated) (Played by: [robo.key]), ":" (Played by: [robo.key]), "]"
var/robo_ckey = safe_get_ckey(robo)
robolist += "[robo.name][robo.stat ? " (Deactivated)" : ""] (Played by: [robo_ckey])"
to_chat(world, "[robolist]")
var/dronecount = 0
@@ -511,11 +514,13 @@ SUBSYSTEM_DEF(ticker)
dronecount++
continue
var/robo_ckey = safe_get_ckey(robo)
if(!robo.connected_ai)
if(robo.stat != 2)
to_chat(world, "<b>[robo.name] (Played by: [robo.key]) survived as an AI-less borg! Its laws were:</b>")
to_chat(world, "<b>[robo.name] (Played by: [robo_ckey]) survived as an AI-less borg! Its laws were:</b>")
else
to_chat(world, "<b>[robo.name] (Played by: [robo.key]) was unable to survive the rigors of being a cyborg without an AI. Its laws were:</b>")
to_chat(world, "<b>[robo.name] (Played by: [robo_ckey]) was unable to survive the rigors of being a cyborg without an AI. Its laws were:</b>")
if(robo) //How the hell do we lose robo between here and the world messages directly above this?
robo.laws.show_laws(world)
+27 -2
View File
@@ -87,9 +87,34 @@
/datum/mind/proc/is_original_mob(mob/M)
return original_mob_UID == M.UID()
// Do not use for admin related things as this can hide the mob's ckey
/datum/mind/proc/get_display_key()
var/clientKey = current?.client?.get_display_key()
return clientKey ? clientKey : key
// Lets try find a client so we can check their prefs
var/client/C = null
var/cannonical_key = ckey(key)
if(current?.client)
// Active client
C = current.client
else if(cannonical_key in GLOB.directory)
// Do a directory lookup on the last ckey this mind had
// If theyre online we can grab them still and check prefs
C = GLOB.directory[cannonical_key]
// Ok we found a client, be it their active or their last
// Now we see if we need to respect their privacy
var/out_ckey
if(C)
if(C.prefs.toggles2 & PREFTOGGLE_2_ANON)
out_ckey = "(Anon)"
else
out_ckey = C.ckey
else
// No client. Just mark as DC'd.
out_ckey = "(Disconnected)"
return out_ckey
/datum/mind/proc/transfer_to(mob/living/new_character)
var/datum/atom_hud/antag/hud_to_transfer = antag_hud //we need this because leave_hud() will clear this list
+2 -1
View File
@@ -36,6 +36,7 @@
var/text = "<FONT size = 2><B>The blob[(blob_mode.infected_crew.len > 1 ? "s were" : " was")]:</B></FONT>"
for(var/datum/mind/blob in blob_mode.infected_crew)
text += "<br><b>[blob.key]</b> was <b>[blob.name]</b>"
var/blob_ckey = blob.get_display_key()
text += "<br><b>[blob_ckey]</b> was <b>[blob.name]</b>"
to_chat(world, text)
return 1
+1 -1
View File
@@ -62,7 +62,7 @@ GLOBAL_LIST_INIT(possible_changeling_IDs, list("Alpha","Beta","Gamma","Delta","E
for(var/datum/mind/changeling in changelings)
var/changelingwin = TRUE
text += "<br>[changeling.key] was [changeling.name] ("
text += "<br>[changeling.get_display_key()] was [changeling.name] ("
if(changeling.current)
if(changeling.current.stat == DEAD)
text += "died"
+1 -1
View File
@@ -388,7 +388,7 @@
for(var/datum/mind/syndicate in syndicates)
text += "<br><b>[syndicate.key]</b> was <b>[syndicate.name]</b> ("
text += "<br><b>[syndicate.get_display_key()]</b> was <b>[syndicate.name]</b> ("
if(syndicate.current)
if(syndicate.current.stat == DEAD)
text += "died"
@@ -55,7 +55,7 @@
for(var/datum/mind/vampire in vampires)
var/traitorwin = TRUE
var/datum/antagonist/vampire/V = vampire.has_antag_datum(/datum/antagonist/vampire)
text += "<br>[vampire.key] was [vampire.name] ("
text += "<br>[vampire.get_display_key()] was [vampire.name] ("
if(vampire.current)
if(vampire.current.stat == DEAD)
text += "died"
@@ -110,7 +110,7 @@
var/text = "<FONT size = 2><B>The Enthralled were:</B></FONT>"
for(var/datum/mind/mind in vampire_enthralled)
text += "<br>[mind.key] was [mind.name] ("
text += "<br>[mind.get_display_key()] was [mind.name] ("
if(mind.current)
if(mind.current.stat == DEAD)
text += "died"
+1 -1
View File
@@ -202,7 +202,7 @@
for(var/datum/mind/wizard in wizards)
text += "<br><b>[wizard.key]</b> was <b>[wizard.name]</b> ("
text += "<br><b>[wizard.get_display_key()]</b> was <b>[wizard.name]</b> ("
if(wizard.current)
if(wizard.current.stat == DEAD)
text += "died"
+1 -1
View File
@@ -162,7 +162,7 @@
/client/proc/get_display_key()
var/fakekey = src?.holder?.fakekey
var/fakekey = holder?.fakekey
return fakekey ? fakekey : key
/client/proc/is_content_unlocked()
@@ -999,8 +999,8 @@
if("ghost_pda")
toggles ^= PREFTOGGLE_CHAT_GHOSTPDA
if("ghost_anonsay")
toggles2 ^= PREFTOGGLE_2_ANONDCHAT
if("anonmode")
toggles2 ^= PREFTOGGLE_2_ANON
if("save")
save_preferences(user)
@@ -373,12 +373,12 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "<b>Attack Animations:</b> <a href='?_src_=prefs;preference=ghost_att_anim'>[(toggles2 & PREFTOGGLE_2_ITEMATTACK) ? "Yes" : "No"]</a><br>"
if(unlock_content)
dat += "<b>BYOND Membership Publicity:</b> <a href='?_src_=prefs;preference=publicity'><b>[(toggles & PREFTOGGLE_MEMBER_PUBLIC) ? "Public" : "Hidden"]</b></a><br>"
dat += "<b>CKEY Anonymity:</b> <a href='?_src_=prefs;preference=anonmode'><b>[toggles2 & PREFTOGGLE_2_ANON ? "Anonymous" : "Not Anonymous"]</b></a><br>"
dat += "<b>Colourblind Mode:</b> <a href='?_src_=prefs;preference=cbmode'>[colourblind_mode]</a><br>"
dat += "<b>Custom UI settings:</b><br>"
dat += " - <b>Alpha (transparency):</b> <a href='?_src_=prefs;preference=UIalpha'><b>[UI_style_alpha]</b></a><br>"
dat += " - <b>Color:</b> <a href='?_src_=prefs;preference=UIcolor'><b>[UI_style_color]</b></a> <span style='border: 1px solid #161616; background-color: [UI_style_color];'>&nbsp;&nbsp;&nbsp;</span><br>"
dat += " - <b>UI Style:</b> <a href='?_src_=prefs;preference=ui'><b>[UI_style]</b></a><br>"
dat += "<b>Deadchat Anonymity:</b> <a href='?_src_=prefs;preference=ghost_anonsay'><b>[toggles2 & PREFTOGGLE_2_ANONDCHAT ? "Anonymous" : "Not Anonymous"]</b></a><br>"
if(user.client.donator_level > 0)
dat += "<b>Donator Publicity:</b> <a href='?_src_=prefs;preference=donor_public'><b>[(toggles & PREFTOGGLE_DONATOR_PUBLIC) ? "Public" : "Hidden"]</b></a><br>"
dat += "<b>Fancy TGUI:</b> <a href='?_src_=prefs;preference=tgui'>[(toggles2 & PREFTOGGLE_2_FANCYUI) ? "Yes" : "No"]</a><br>"
@@ -341,3 +341,11 @@
prefs.toggles2 ^= PREFTOGGLE_2_SEE_ITEM_OUTLINES
prefs.save_preferences(src)
to_chat(usr, "You will [(prefs.toggles2 & PREFTOGGLE_2_SEE_ITEM_OUTLINES) ? "now" : "no longer"] see item outlines on hover.")
/mob/verb/toggle_anonmode()
set name = "Toggle Anonymous Mode"
set category = "Preferences"
set desc = "Toggles showing your key in various parts of the game (deadchat, end round, etc)."
client.prefs.toggles2 ^= PREFTOGGLE_2_ANON
to_chat(src, "Your key will [(client.prefs.toggles2 & PREFTOGGLE_2_ANON) ? "no longer" : "now"] be shown in certain events (end round reports, deadchat, etc).</span>")
client.prefs.save_preferences(src)
@@ -179,6 +179,7 @@ GLOBAL_DATUM(error_cache, /datum/ErrorViewer/ErrorCache)
if(!istype(back_to))
back_to = error_source
var/html = buildHeader(back_to, linear)
html += "<div class='bad'><b>Be sure to censor out ckeys when copying runtimes!</b></div><br>"
html += "<div class='runtime'>[html_encode(name)]<br>[desc]</div>"
if(srcRef)
html += "<br>src: <a href='?_src_=vars;Vars=[srcUID]'>VV</a>"
@@ -653,15 +653,6 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
..()
//END TELEPORT HREF CODE
/mob/dead/observer/verb/toggle_anonsay()
set name = "Toggle Anonymous Dead-chat"
set category = "Ghost"
set desc = "Toggles showing your key in dead chat."
client.prefs.toggles2 ^= PREFTOGGLE_2_ANONDCHAT
to_chat(src, "As a ghost, your key will [(client.prefs.toggles2 & PREFTOGGLE_2_ANONDCHAT) ? "no longer" : "now"] be shown when you speak in dead chat.</span>")
client.prefs.save_preferences(src)
/mob/dead/observer/verb/toggle_ghostsee()
set name = "Toggle Ghost Vision"
set desc = "Toggles your ability to see things only ghosts can see, like other ghosts"
+5 -4
View File
@@ -531,11 +531,12 @@ GLOBAL_LIST_INIT(intents, list(INTENT_HELP,INTENT_DISARM,INTENT_GRAB,INTENT_HARM
var/mob/dead/observer/DM
if(istype(subject, /mob/dead/observer))
DM = subject
if(check_rights(R_ADMIN|R_MOD,0,M)) // What admins see
lname = "[keyname][(DM && DM.client && DM.client.prefs.toggles2 & PREFTOGGLE_2_ANONDCHAT) ? "*" : (DM ? "" : "^")] ([name])"
if(check_rights(R_ADMIN|R_MOD, FALSE, M)) // What admins see
lname = "[keyname][(DM?.client.prefs.toggles2 & PREFTOGGLE_2_ANON) ? (@"[ANON]") : (DM ? "" : "^")] ([name])"
//lname = "[keyname][(DM?.client.prefs.toggles2 & PREFTOGGLE_2_ANON) ? TRUE : (DM ? "" : "^")] ([name])"
else
if(DM && DM.client && DM.client.prefs.toggles2 & PREFTOGGLE_2_ANONDCHAT) // If the person is actually observer they have the option to be anonymous
lname = "Ghost of [name]"
if(DM?.client.prefs.toggles2 & PREFTOGGLE_2_ANON) // If the person is actually observer they have the option to be anonymous
lname = "<i>Anon</i> ([name])"
else if(DM) // Non-anons
lname = "[keyname] ([name])"
else // Everyone else (dead people who didn't ghost yet, etc.)