From 9d309303385263f70aa961bbc003eba29b54c479 Mon Sep 17 00:00:00 2001 From: KasparoVy Date: Tue, 31 Jan 2017 02:23:32 -0500 Subject: [PATCH] Makes Ghost Anonsay Persistent by Turning it into its own Preference By turning it into its own preference. The verb stays in the ghost tab, except it now operates by checking client preferences. Needs ALTER TABLE `player` ADD `ghost_anonsay` TINYINT(1) NOT NULL DEFAULT '0' AFTER `lastchangelog`; to add it to the SQL --- SQL/paradise_schema.sql | 1 + SQL/paradise_schema_prefixed.sql | 1 + code/modules/client/preference/preferences.dm | 6 ++++++ code/modules/client/preference/preferences_mysql.dm | 8 ++++++-- code/modules/mob/dead/observer/observer.dm | 12 ++++-------- code/modules/mob/mob_helpers.dm | 4 ++-- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index ed0845ed33f..7a2f396d89d 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -275,6 +275,7 @@ CREATE TABLE `player` ( `show_ghostitem_attack` smallint(4) DEFAULT '1', `lastchangelog` varchar(32) NOT NULL DEFAULT '0', `windowflashing` smallint(4) DEFAULT '1', + `ghost_anonsay` tinyint(1) DEFAULT '0', `exp` mediumtext, PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql index 216082157d4..7c4f0388a4c 100644 --- a/SQL/paradise_schema_prefixed.sql +++ b/SQL/paradise_schema_prefixed.sql @@ -274,6 +274,7 @@ CREATE TABLE `SS13_player` ( `show_ghostitem_attack` smallint(4) DEFAULT '1', `lastchangelog` varchar(32) NOT NULL DEFAULT '0', `windowflashing` smallint(4) DEFAULT '1', + `ghost_anonsay` tinyint(1) DEFAULT '0', `exp` mediumtext, PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index c9b3127094b..629c48d7c6d 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -95,6 +95,8 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts var/UI_style_alpha = 255 var/windowflashing = TRUE + //ghostly preferences + var/ghost_anonsay = 0 //character preferences var/real_name //our character's name @@ -444,6 +446,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "Ghost ears: [(toggles & CHAT_GHOSTEARS) ? "Nearest Creatures" : "All Speech"]
" dat += "Ghost sight: [(toggles & CHAT_GHOSTSIGHT) ? "Nearest Creatures" : "All Emotes"]
" dat += "Ghost radio: [(toggles & CHAT_GHOSTRADIO) ? "Nearest Speakers" : "All Chatter"]
" + dat += "Deadchat anonymity: [ghost_anonsay ? "Anonymous" : "Not Anonymous"]
" dat += "" dat += "

Special Role Settings

" @@ -1994,6 +1997,9 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("ghost_radio") toggles ^= CHAT_GHOSTRADIO + if("ghost_anonsay") + ghost_anonsay = !ghost_anonsay + if("save") save_preferences(user) save_character(user) diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index 8f1b11b5ca6..7791159c821 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -15,7 +15,8 @@ show_ghostitem_attack, lastchangelog, exp, - windowflashing + windowflashing, + ghost_anonsay FROM [format_table_name("player")] WHERE ckey='[C.ckey]'"} ) @@ -44,6 +45,7 @@ lastchangelog = query.item[13] exp = query.item[14] windowflashing = text2num(query.item[15]) + ghost_anonsay = text2num(query.item[16]) //Sanitize ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor)) @@ -60,6 +62,7 @@ lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog)) exp = sanitize_text(exp, initial(exp)) windowflashing = sanitize_integer(windowflashing, 0, 1, initial(windowflashing)) + ghost_anonsay = sanitize_integer(ghost_anonsay, 0, 1, initial(ghost_anonsay)) return 1 /datum/preferences/proc/save_preferences(client/C) @@ -84,7 +87,8 @@ volume='[volume]', nanoui_fancy='[nanoui_fancy]', show_ghostitem_attack='[show_ghostitem_attack]', - lastchangelog='[lastchangelog]' + lastchangelog='[lastchangelog]', + ghost_anonsay='[ghost_anonsay]' WHERE ckey='[C.ckey]'"} ) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index db6ef63ad22..75ff52b6478 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -22,7 +22,6 @@ var/list/image/ghost_darkness_images = list() //this is a list of images for thi //Note that this is not a reliable way to determine if admins started as observers, since they change mobs a lot. universal_speak = 1 var/atom/movable/following = null - var/anonsay = 0 var/image/ghostimage = null //this mobs ghost image, for deleting and stuff var/ghostvision = 1 //is the ghost able to see things humans can't? var/seedarkness = 1 @@ -596,15 +595,12 @@ 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 name = "Toggle Anonymous Chat" set desc = "Toggles showing your key in dead chat." - - src.anonsay = !src.anonsay - if(anonsay) - to_chat(src, "Your key won't be shown when you speak in dead chat.") - else - to_chat(src, "Your key will be publicly visible again.") + client.prefs.ghost_anonsay = !client.prefs.ghost_anonsay + to_chat(src, "As a ghost, your key will [(client.prefs.ghost_anonsay) ? "no longer" : "now"] be shown when you speak in dead chat.") + client.prefs.save_preferences(src) /mob/dead/observer/verb/toggle_ghostsee() set name = "Toggle Ghost Vision" diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 483b765b65e..e36dc9ce494 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -423,9 +423,9 @@ var/list/intents = list(I_HELP,I_DISARM,I_GRAB,I_HARM) if(istype(subject, /mob/dead/observer)) DM = subject if(check_rights(R_ADMIN|R_MOD,0,M)) // What admins see - lname = "[keyname][(DM && DM.anonsay) ? "*" : (DM ? "" : "^")] ([name])" + lname = "[keyname][(DM && DM.client && DM.client.prefs.ghost_anonsay) ? "*" : (DM ? "" : "^")] ([name])" else - if(DM && DM.anonsay) // If the person is actually observer they have the option to be anonymous + if(DM && DM.client && DM.client.prefs.ghost_anonsay) // If the person is actually observer they have the option to be anonymous lname = "Ghost of [name]" else if(DM) // Non-anons lname = "[keyname] ([name])"