Merged listen_ooc, seeprayers, STFU_ghosts, STFU_radio, deadchat, sound_adminhelp, ghostears, ghostsight, canplaysound, midis, no_ambi and lobby_music into client.prefs.toggles as bitflags.

Toggling these preferences in-game will update your savefile. Meaning that your preferences will persist between rounds.

Added some savefile_version updating stuff. It's pretty crude. If you're changing any of the savefile stuff just ask and I can change it/help.

Removed some unused client vars

Ghosts no longer hear ambience. Simplified ambience code.

Simplified lobby music code. It will no longer cause a massive queue of events (which would eventually balloon in memory use)

Moved ooccolor and sound_adminhelp back to prefs. It's easier and allowed me to remove the setupclient() stuff completely.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5143 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
elly1989@rocketmail.com
2012-11-21 05:58:04 +00:00
parent ba4e25b97d
commit 2e68af07c1
26 changed files with 202 additions and 254 deletions
@@ -53,7 +53,7 @@
for(var/mob/M in dead_mob_list)
if (!M.client || istype(M, /mob/new_player))
continue //skip monkeys, leavers, and new_players
if(M.stat == 2 && M.client.ghost_sight && !(M in viewers(src,null)))
if(M.stat == DEAD && (M.client.prefs.toggles & CHAT_GHOSTSIGHT) && !(M in viewers(src,null)))
M.show_message(message)
@@ -576,9 +576,9 @@
// Maybe some people are okay with that.
for(var/mob/M in dead_mob_list)
if (!M.client || istype(M, /mob/new_player))
if(!M.client || istype(M, /mob/new_player))
continue //skip monkeys, leavers and new players
if(M.stat == 2 && M.client.ghost_sight && !(M in viewers(src,null)))
if(M.stat == DEAD && (M.client.prefs.toggles & CHAT_GHOSTSIGHT) && !(M in viewers(src,null)))
M.show_message(message)
+1 -1
View File
@@ -276,7 +276,7 @@ var/list/department_radio_keys = list(
continue //skip monkeys and leavers
if (istype(M, /mob/new_player))
continue
if(M.stat == 2 && M.client.ghost_ears)
if(M.stat == DEAD && (M.client.prefs & CHAT_GHOSTEARS))
listening|=M
var/turf/T = get_turf(src)
+6 -14
View File
@@ -402,29 +402,21 @@ var/list/slot_equipment_priority = list( \
prefs.save_preferences()
winset(src, "rpane.changelog", "background-color=none;font-style=;")
/client/var/ghost_ears = 0
/client/verb/toggle_ghost_ears()
set name = "Ghost ears"
set category = "OOC"
set desc = "Hear talks from everywhere"
ghost_ears = !ghost_ears
if (ghost_ears)
usr << "\blue Now you hear all speech in the world"
else
usr << "\blue Now you hear speech only from nearest creatures."
prefs.toggles ^= CHAT_GHOSTEARS
src << "As a ghost, you will now [(prefs.toggles & CHAT_GHOSTEARS) ? "see all speech in the world" : "only see speech from nearby mobs"]."
prefs.save_preferences()
/client/var/ghost_sight = 0
/client/verb/toggle_ghost_sight()
set name = "Ghost sight"
set category = "OOC"
set desc = "Hear emotes from everywhere"
ghost_sight = !ghost_sight
if (ghost_sight)
usr << "\blue Now you hear all emotes in the world"
else
usr << "\blue Now you hear emotes only from nearest creatures."
prefs.toggles ^= CHAT_GHOSTSIGHT
src << "As a ghost, you will now [(prefs.toggles & CHAT_GHOSTSIGHT) ? "see all emotes in the world" : "only see emotes from nearby mobs"]."
prefs.save_preferences()
/mob/verb/observe()
set name = "Observe"
+1 -2
View File
@@ -30,5 +30,4 @@
spawn(40)
if(client)
handle_privacy_poll()
if(client.prefs.lobby_music)
Playmusic()
client.playtitlemusic()
+1 -18
View File
@@ -61,21 +61,6 @@
src << browse(output,"window=playersetup;size=210x240;can_close=0")
return
proc/Playmusic()
while(!ticker) // wait for ticker to be created
sleep(1)
var/waits = 0
var/maxwaits = 100
while(!ticker.login_music)
sleep(2)
waits++ // prevents DDoSing the server via badminery
if(waits >= maxwaits)
break
src << sound(ticker.login_music, repeat = 0, wait = 0, volume = 85, channel = 1) // MAD JAMS
Stat()
..()
@@ -131,10 +116,8 @@
if(client.prefs.be_random_name)
client.prefs.randomize_name()
observer.name = client.prefs.real_name
observer.key = key
observer.real_name = observer.name
client.prefs.copy_to_observer(observer)
observer.key = key
del(src)
return 1
+13 -38
View File
@@ -50,13 +50,9 @@ datum/preferences
//game-preferences
var/lastchangelog = "" //Saved changlog filesize to detect if there was a change
var/ooccolor = "#b82e00"
var/midis = 1 //Play admin midis
var/ghost_ears = 1 //Toggle ghost ears
var/ghost_sight = 1
var/be_special = 0 //Special role selection
var/UI_style = "Midnight"
var/sound_adminhelp = 0
var/lobby_music = 1 //Whether or not to play the lobby music(Defaults yes)
var/toggles = TOGGLES_DEFAULT
//character preferences
var/real_name //our character's name
@@ -97,7 +93,7 @@ datum/preferences
var/job_engsec_low = 0
// Want randomjob if preferences already filled - Donkie
var/userandomjob = 1 // Defaults to 1 for less assistants!
var/userandomjob = 1 //defaults to 1 for fewer assistants
// OOC Metadata:
var/metadata = ""
@@ -149,17 +145,17 @@ datum/preferences
dat += "<br>"
dat += "<b>UI Style:</b> <a href='?_src_=prefs;preference=ui'><b>[UI_style]</b></a><br>"
dat += "<b>Play admin midis:</b> <a href='?_src_=prefs;preference=hear_midis'><b>[midis == 1 ? "Yes" : "No"]</b></a><br>"
dat += "<b>Play lobby music:</b> <a href='?_src_=prefs;preference=lobby_music'><b>[lobby_music == 1 ? "Yes" : "No"]</b></a><br>"
dat += "<b>Ghost ears:</b> <a href='?_src_=prefs;preference=ghost_ears'><b>[ghost_ears == 0 ? "Nearest Creatures" : "All Speech"]</b></a><br>"
dat += "<b>Ghost sight:</b> <a href='?_src_=prefs;preference=ghost_sight'><b>[ghost_sight == 0 ? "Nearest Creatures" : "All Emotes"]</b></a><br>"
dat += "<b>Play admin midis:</b> <a href='?_src_=prefs;preference=hear_midis'><b>[(toggles & SOUND_MIDI) ? "Yes" : "No"]</b></a><br>"
dat += "<b>Play lobby music:</b> <a href='?_src_=prefs;preference=lobby_music'><b>[(toggles & SOUND_LOBBY) ? "Yes" : "No"]</b></a><br>"
dat += "<b>Ghost ears:</b> <a href='?_src_=prefs;preference=ghost_ears'><b>[(toggles & CHAT_GHOSTEARS) ? "Nearest Creatures" : "All Speech"]</b></a><br>"
dat += "<b>Ghost sight:</b> <a href='?_src_=prefs;preference=ghost_sight'><b>[(toggles & CHAT_GHOSTSIGHT) ? "Nearest Creatures" : "All Emotes"]</b></a><br>"
if(config.allow_Metadata)
dat += "<b>OOC Notes:</b> <a href='?_src_=prefs;preference=metadata;task=input'> Edit </a><br>"
if(user.client && user.client.holder)
dat += "<b>Adminhelp sound</b>: "
dat += "[(sound_adminhelp)?"On":"Off"] <a href='?_src_=prefs;preference=hear_adminhelps'>toggle</a><br>"
dat += "[(toggles & SOUND_ADMINHELP)?"On":"Off"] <a href='?_src_=prefs;preference=hear_adminhelps'>toggle</a><br>"
if(config.allow_admin_ooccolor && check_rights(R_ADMIN,0))
dat += "<br><b>OOC</b><br>"
@@ -492,8 +488,6 @@ datum/preferences
be_special = 0
be_random_name = 0
UI_style = "Midnight"
midis = 1
ghost_ears = 1
userandomjob = 1
if("input")
@@ -586,7 +580,7 @@ datum/preferences
gender = MALE
if("hear_adminhelps")
sound_adminhelp = !sound_adminhelp
toggles ^= SOUND_ADMINHELP
if("ui")
switch(UI_style)
@@ -605,20 +599,20 @@ datum/preferences
be_random_name = !be_random_name
if("hear_midis")
midis = !midis
toggles ^= SOUND_MIDI
if("lobby_music")
lobby_music = !lobby_music
if(lobby_music)
toggles ^= SOUND_LOBBY
if(toggles & SOUND_LOBBY)
user << sound(ticker.login_music, repeat = 0, wait = 0, volume = 85, channel = 1)
else
user << sound(null, repeat = 0, wait = 0, volume = 85, channel = 1)
if("ghost_ears")
ghost_ears = !ghost_ears
toggles ^= CHAT_GHOSTEARS
if("ghost_sight")
ghost_sight = !ghost_sight
toggles ^= CHAT_GHOSTSIGHT
if("save")
save_preferences()
@@ -692,28 +686,9 @@ datum/preferences
backbag = 1 //Same as above
character.backbag = backbag
if(!safety)//To prevent run-time errors due to null datum when using randomize_appearance_for()
spawn(10)
if(character&&character.client)
setup_client(character.client)
//Debugging report to track down a bug, which randomly assigned the plural gender to people.
if(character.gender in list(PLURAL, NEUTER))
if(isliving(src)) //Ghosts get neuter by default
message_admins("[character] ([character.ckey]) has spawned with their gender as plural or neuter. Please notify coders.")
character.gender = MALE
proc/copy_to_observer(mob/dead/observer/character)
spawn(10)
if(character && character.client)
setup_client(character.client)
proc/setup_client(var/client/C)
if(C)
if(C.holder)
C.holder.sound_adminhelp = src.sound_adminhelp
C.holder.ooccolor = src.ooccolor
C.midis = src.midis
if(isnull(src.ghost_ears)) src.ghost_ears = 1 //There were problems where the default was null before someone saved their profile.
C.ghost_ears = src.ghost_ears
C.ghost_sight = src.ghost_sight
+40 -35
View File
@@ -1,18 +1,47 @@
#define SAVEFILE_VERSION_MIN 7
#define SAVEFILE_VERSION_MAX 7
#define SAVEFILE_VERSION_MIN 8
#define SAVEFILE_VERSION_MAX 8
/datum/preferences/proc/load_path(ckey)
//handles converting savefiles to new formats
//MAKE SURE YOU KEEP THIS UP TO DATE!
//If the sanity checks are capable of handling any issues. Only increase SAVEFILE_VERSION_MAX,
//this will mean that savefile_version will still be over SAVEFILE_VERSION_MIN, meaning
//this savefile update doesn't run everytime we load from the savefile.
//This is mainly for format changes, such as the bitflags in toggles changing order or something.
/datum/preferences/proc/savefile_update()
if(savefile_version < 6) //really old savefile.
return 0
if(savefile_version < 8) //lazily delete everything + additional files so they can be saved in the new format
for(var/ckey in preferences_datums)
var/datum/preferences/D = preferences_datums[ckey]
if(D == src)
var/delpath = "data/player_saves/[copytext(ckey,1,2)]/[ckey]/"
if(delpath && fexists(delpath))
fdel(delpath)
break
savefile_version = 8
//save format changes
save_preferences()
save_character()
return 1
/datum/preferences/proc/load_path(ckey,filename="preferences.sav")
if(!ckey) return
path = "data/player_saves/[copytext(ckey,1,2)]/[ckey]/preferences.sav"
path = "data/player_saves/[copytext(ckey,1,2)]/[ckey]/[filename]"
/datum/preferences/proc/load_preferences()
if(!path) return 0
if(!fexists(path)) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S["version"] >> savefile_version
//Conversion
if(!savefile_version || !isnum(savefile_version) || savefile_version < SAVEFILE_VERSION_MIN || savefile_version > SAVEFILE_VERSION_MAX)
if(!savefile_update())
fdel(path)
return 0
//general preferences
S["ooccolor"] >> ooccolor
@@ -20,20 +49,7 @@
S["UI_style"] >> UI_style
S["be_special"] >> be_special
S["default_slot"] >> default_slot
//to be consolidated into a bitfield
S["sound_adminhelp"] >> sound_adminhelp
S["lobby_music"] >> lobby_music
S["midis"] >> midis
S["ghost_ears"] >> ghost_ears
S["ghost_sight"] >> ghost_sight
//Conversion
/* if(!savefile_version || savefile_version < SAVEFILE_VERSION_MIN || savefile_version > SAVEFILE_VERSION_MAX)
if(!savefile_update())
fdel(path)
C << "<font color='red'>Error: savefile_load(): Your savefile was not compatible and had to be deleted.</font>"
return 0 */
S["toggles"] >> toggles
//Sanitize
ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor))
@@ -41,41 +57,31 @@
UI_style = sanitize_inlist(UI_style, list("Midnight","Orange","old"), initial(UI_style))
be_special = sanitize_integer(be_special, 0, 65535, initial(be_special))
default_slot = sanitize_integer(default_slot, 1, MAX_SAVE_SLOTS, initial(default_slot))
sound_adminhelp = sanitize_integer(sound_adminhelp, 0, 1, initial(sound_adminhelp))
lobby_music = sanitize_integer(lobby_music, 0, 1, initial(lobby_music))
midis = sanitize_integer(midis, 0, 1, initial(midis))
ghost_ears = sanitize_integer(ghost_ears, 0, 1, initial(ghost_ears))
ghost_sight = sanitize_integer(ghost_sight, 0, 1, initial(ghost_sight))
if(isnull(toggles)) toggles = initial(toggles)
toggles = sanitize_integer(toggles, 0, 65535, initial(toggles))
return 1
/datum/preferences/proc/save_preferences()
if(!path) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S["version"] << savefile_version
//general preferences
S["ooccolor"] << ooccolor
S["lastchangelog"] << lastchangelog
S["UI_style"] << UI_style
S["be_special"] << be_special
S["default_slot"] << default_slot
//to be consolidated into a bitfield
S["sound_adminhelp"] << sound_adminhelp
S["lobby_music"] << lobby_music
S["midis"] << midis
S["ghost_ears"] << ghost_ears
S["ghost_sight"] << ghost_sight
S["toggles"] << toggles
return 1
/datum/preferences/proc/load_character(slot)
if(!path) return 0
if(!fexists(path)) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
if(!slot) slot = default_slot
@@ -156,7 +162,6 @@
/datum/preferences/proc/save_character()
if(!path) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S.cd = "/character[default_slot]"
+5 -6
View File
@@ -36,13 +36,12 @@
message = src.say_quote(message)
var/rendered = "<span class='game deadsay'><span class='prefix'>DEAD:</span> <span class='name'>[name]</span>[alt_name] <span class='message'>[message]</span></span>"
for (var/mob/M in player_list)
if (istype(M, /mob/new_player))
for(var/mob/M in player_list)
if(istype(M, /mob/new_player))
continue
if(M.client && M.client.holder && M.client.deadchat) //admins can toggle deadchat on and off. This is a proc in admin.dm and is only give to Administrators and above
if(!M.client.STFU_ghosts) //Admin shut-off for ghosts chatter
M << rendered //Admins can hear deadchat, if they choose to, no matter if they're blind/deaf or not.
else if (M.stat == DEAD)
if(M.client && M.client.holder && (M.client.prefs.toggles & CHAT_DEAD)) //admins can toggle deadchat on and off. This is a proc in admin.dm and is only give to Administrators and above
M << rendered //Admins can hear deadchat, if they choose to, no matter if they're blind/deaf or not.
else if(M.stat == DEAD)
M.show_message(rendered, 2) //Takes into account blindness and such.
return