From 52c48d11aa2f973e0122b5359b17596728e4aa6a Mon Sep 17 00:00:00 2001 From: carnie Date: Sun, 16 Jun 2013 10:29:29 +0100 Subject: [PATCH] Resolves an issue with sanitize_hexcolor where it'd return an incomplete string such as "" Resolves an issue where whitespace in names could cause a saveslot button to wrap to the next line. Byond members: can colour their name using the admin ooc-colour feature. get a icon next to their name in ooc chat. can choose their icon_state as a ghost. get 8 saveslots unlock_content tracks the return of IsByondMember(). This is to allow for easier testing/debug. --- code/__HELPERS/sanitize_values.dm | 24 ++++++++-------- code/game/verbs/ooc.dm | 23 ++++++++++++++-- code/modules/admin/admin_verbs.dm | 13 --------- code/modules/client/client defines.dm | 2 ++ code/modules/client/client procs.dm | 2 ++ code/modules/client/preferences.dm | 29 ++++++++++---------- code/modules/client/preferences_savefile.dm | 24 ++++++++-------- code/modules/mob/dead/observer/observer.dm | 17 ++++++++---- icons/member_content.dmi | Bin 0 -> 2140 bytes 9 files changed, 76 insertions(+), 58 deletions(-) create mode 100644 icons/member_content.dmi diff --git a/code/__HELPERS/sanitize_values.dm b/code/__HELPERS/sanitize_values.dm index 29e6c15d20e..dfcc7d314b0 100644 --- a/code/__HELPERS/sanitize_values.dm +++ b/code/__HELPERS/sanitize_values.dm @@ -31,17 +31,16 @@ return default -/proc/sanitize_hexcolor(color, desired_format=3, include_bang=0, default) - var/bang = include_bang ? "#" : "" +/proc/sanitize_hexcolor(color, desired_format=3, include_crunch=0, default) + var/crunch = include_crunch ? "#" : "" if(!istext(color)) - if(default) return default - return bang + repeat_string(desired_format, "0") - + color = "" + var/start = 1 + (text2ascii(color,1)==35) var/len = length(color) var/step_size = 1 + ((len+1)-start != desired_format) - - . = bang + + . = "" for(var/i=start, i<=len, i+=step_size) var/ascii = text2ascii(color,i) switch(ascii) @@ -49,7 +48,10 @@ if(97 to 102) . += ascii2text(ascii) //letters a to f if(65 to 70) . += ascii2text(ascii+32) //letters A to F - translates to lowercase else - if(default) return default - return bang + repeat_string(desired_format, "0") - - return . \ No newline at end of file + break + + if(length(.) != desired_format) + if(default) return default + return crunch + repeat_string(desired_format, "0") + + return crunch + . \ No newline at end of file diff --git a/code/game/verbs/ooc.dm b/code/game/verbs/ooc.dm index 2271bc26b80..f64a36c9c05 100644 --- a/code/game/verbs/ooc.dm +++ b/code/game/verbs/ooc.dm @@ -38,18 +38,20 @@ log_ooc("[mob.name]/[key] : [msg]") + var/keyname = unlock_content ? "[key]" : key + for(var/client/C in clients) if(C.prefs.toggles & CHAT_OOC) if(holder) if(!holder.fakekey || C.holder) if(holder.rights & R_ADMIN) - C << "OOC: [key][holder.fakekey ? "/([holder.fakekey])" : ""]: [msg]" + C << "OOC: [keyname][holder.fakekey ? "/([holder.fakekey])" : ""]: [msg]" else - C << "OOC: [key][holder.fakekey ? "/([holder.fakekey])" : ""]: [msg]" + C << "OOC: [keyname][holder.fakekey ? "/([holder.fakekey])" : ""]: [msg]" else C << "OOC: [holder.fakekey ? holder.fakekey : key]: [msg]" else - C << "OOC: [key]: [msg]" + C << "OOC: [keyname]: [msg]" var/global/normal_ooc_colour = "#002eb8" @@ -58,3 +60,18 @@ var/global/normal_ooc_colour = "#002eb8" set desc = "Set to yellow for eye burning goodness." set category = "Fun" normal_ooc_colour = newColor + +/client/verb/colorooc() + set name = "OOC Text Color" + set category = "Preferences" + + if(!unlock_content && !(holder && (holder.rights & R_ADMIN))) + src << "You must be a byond member or admin with +ADMIN rights to access this feature. Sorry" + return + + var/new_ooccolor = input(src, "Please select your OOC colour.", "OOC colour") as color|null + if(new_ooccolor) + prefs.ooccolor = new_ooccolor + prefs.save_preferences() + feedback_add_details("admin_verb","OC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + return \ No newline at end of file diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 0fcc9ad91c5..339db872a56 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -28,7 +28,6 @@ var/list/admin_verbs_admin = list( /datum/admins/proc/toggleenter, /*toggles whether people can join the current game*/ /datum/admins/proc/toggleguests, /*toggles whether guests can join the current game*/ /datum/admins/proc/announce, /*priority announce something to all clients.*/ - /client/proc/colorooc, /*allows us to set a custom colour for everythign we say in ooc*/ /client/proc/admin_ghost, /*allows us to ghost/reenter body at will*/ /client/proc/toggle_view_range, /*changes how far we can see*/ /datum/admins/proc/view_txt_log, /*shows the server log (diary) for today*/ @@ -141,7 +140,6 @@ var/list/admin_verbs_hideable = list( /datum/admins/proc/toggleenter, /datum/admins/proc/toggleguests, /datum/admins/proc/announce, - /client/proc/colorooc, /client/proc/admin_ghost, /client/proc/toggle_view_range, /datum/admins/proc/view_txt_log, @@ -381,17 +379,6 @@ var/list/admin_verbs_hideable = list( feedback_add_details("admin_verb","S") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! return -/client/proc/colorooc() - set category = "Fun" - set name = "OOC Text Color" - if(!holder) return - var/new_ooccolor = input(src, "Please select your OOC colour.", "OOC colour") as color|null - if(new_ooccolor) - prefs.ooccolor = new_ooccolor - prefs.save_preferences() - feedback_add_details("admin_verb","OC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! - return - /client/proc/stealth() set category = "Admin" set name = "Stealth Mode" diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index 3ef743c60b8..b88ee8fadd3 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -17,6 +17,8 @@ var/adminobs = null var/area = null + var/unlock_content = 0 //byond-member content + /////////////// //SOUND STUFF// /////////////// diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 9fbadcba04c..3056a000378 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -87,6 +87,8 @@ if(byond_version < MIN_CLIENT_VERSION) //Out of date client. return null + unlock_content = IsByondMember() + clients += src directory[ckey] = src diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 156c338fdd4..5b8dee959de 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -17,13 +17,11 @@ var/global/list/special_roles = list( //keep synced with the defines BE_* in set ) -var/const/MAX_SAVE_SLOTS = 3 - - datum/preferences //doohickeys for savefiles var/path var/default_slot = 1 //Holder so it doesn't default to slot 1, rather the last one used + var/max_save_slots = 3 //non-preference stuff var/warns = 0 @@ -33,7 +31,7 @@ datum/preferences //game-preferences var/lastchangelog = "" //Saved changlog filesize to detect if there was a change - var/ooccolor = "#b82e00" + var/ooccolor = "#002eb8" var/be_special = 0 //Special role selection var/UI_style = "Midnight" var/toggles = TOGGLES_DEFAULT @@ -50,7 +48,7 @@ datum/preferences var/h_color = "000" //Hair color var/f_style = "Shaved" //Face hair type var/f_color = "000" //Facial hair color - var/skin_tone = "caucasian" //Skin color + var/skin_tone = "caucasian1" //Skin color var/eye_color = "000" //Eye color //Mob preview @@ -81,9 +79,12 @@ datum/preferences /datum/preferences/New(client/C) b_type = random_blood_type() + ooccolor = normal_ooc_colour if(istype(C)) if(!IsGuestKey(C.key)) load_path(C.ckey) + if(C.unlock_content) + max_save_slots = 8 var/loaded_preferences_successfully = load_preferences() if(loaded_preferences_successfully) if(load_character()) @@ -121,12 +122,12 @@ datum/preferences if(S) dat += "
" var/name - for(var/i=1, i<=MAX_SAVE_SLOTS, i++) + for(var/i=1, i<=max_save_slots, i++) S.cd = "/character[i]" S["real_name"] >> name if(!name) name = "Character[i]" //if(i!=1) dat += " | " - dat += "[name] " + dat += "[name] " dat += "
" dat += "

Occupation Choices

" @@ -200,11 +201,12 @@ datum/preferences if(config.allow_Metadata) dat += "OOC Notes: Edit
" - if(user.client && user.client.holder) - dat += "Adminhelp Sound: " - dat += "[(toggles & SOUND_ADMINHELP)?"On":"Off"]
" + if(user.client) + if(user.client.holder) + dat += "Adminhelp Sound: " + dat += "[(toggles & SOUND_ADMINHELP)?"On":"Off"]
" - if(config.allow_admin_ooccolor && check_rights(R_ADMIN,0)) + if(user.client.unlock_content || (user.client.holder && (user.client.holder.rights & R_ADMIN))) dat += "
OOC
" dat += "    Change
" @@ -239,7 +241,7 @@ datum/preferences dat += "
" //user << browse(dat, "window=preferences;size=560x560") - var/datum/browser/popup = new(user, "preferences", "
Character Setup
", 580, 560) + var/datum/browser/popup = new(user, "preferences", "
Character Setup
", 580, 580) popup.set_content(dat) popup.open(0) @@ -453,7 +455,6 @@ datum/preferences proc/process_link(mob/user, list/href_list) - if(!user) return if(!istype(user, /mob/new_player)) return if(href_list["preference"] == "job") @@ -522,7 +523,7 @@ datum/preferences var/new_hair = input(user, "Choose your character's hair colour:", "Character Preference") as null|color if(new_hair) h_color = sanitize_hexcolor(new_hair) - + if("h_style") var/new_h_style diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index ed32650e0e2..b0be8e5d1b5 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -15,21 +15,21 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car if its version is below SAVEFILE_VERSION_MAX but above the minimum, it will load data but later call the respective update_preferences() or update_character() proc. Those procs allow coders to specify format changes so users do not lose their setups and have to redo them again. - + Failing all that, the standard sanity checks are performed. They simply check the data is suitable, reverting to initial() values if necessary. */ /datum/preferences/proc/savefile_needs_update(savefile/S) var/savefile_version S["version"] >> savefile_version - + if(savefile_version < SAVEFILE_VERSION_MIN) S.dir.Cut() return -2 if(savefile_version < SAVEFILE_VERSION_MAX) return savefile_version return -1 - + /datum/preferences/proc/update_preferences(current_version) return @@ -71,7 +71,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car if(11) underwear = "Ladies Kinky" if(12) underwear = "Tankini" if(13) underwear = "Nude" - + /* if(current_version < 10) //would be the step to upgrade 9 to 10 //do stuff @@ -92,7 +92,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car var/savefile/S = new /savefile(path) if(!S) return 0 S.cd = "/" - + var/needs_update = savefile_needs_update(S) if(needs_update == -2) //fatal, can't load any data return 0 @@ -108,13 +108,15 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car //try to fix any outdated data if necessary if(needs_update >= 0) update_preferences(needs_update) //needs_update = savefile_version if we need an update (positive integer) - + + + //Sanitize ooccolor = sanitize_hexcolor(ooccolor, 6, 1, initial(ooccolor)) lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog)) UI_style = sanitize_inlist(UI_style, list("Midnight", "Plasmafire", "Retro"), 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)) + default_slot = sanitize_integer(default_slot, 1, max_save_slots, initial(default_slot)) toggles = sanitize_integer(toggles, 0, 65535, initial(toggles)) return 1 @@ -144,11 +146,11 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car if(!S) return 0 S.cd = "/" if(!slot) slot = default_slot - slot = sanitize_integer(slot, 1, MAX_SAVE_SLOTS, initial(default_slot)) + slot = sanitize_integer(slot, 1, max_save_slots, initial(default_slot)) if(slot != default_slot) default_slot = slot S["default_slot"] << slot - + S.cd = "/character[slot]" var/needs_update = savefile_needs_update(S) if(needs_update == -2) //fatal, can't load any data @@ -184,7 +186,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car //try to fix any outdated data if necessary if(needs_update >= 0) update_character(needs_update) //needs_update == savefile_version if we need an update (positive integer) - + //Sanitize metadata = sanitize_text(metadata, initial(metadata)) real_name = reject_bad_name(real_name) @@ -224,7 +226,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car var/savefile/S = new /savefile(path) if(!S) return 0 S.cd = "/character[default_slot]" - + S["version"] << SAVEFILE_VERSION_MAX //load_character will sanitize any bad data, so assume up-to-date. //Character diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 09b917bd21f..b71594cd192 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -37,10 +37,7 @@ if(body.real_name) name = body.real_name else - if(gender == MALE) - name = capitalize(pick(first_names_male)) + " " + capitalize(pick(last_names)) - else - name = capitalize(pick(first_names_female)) + " " + capitalize(pick(last_names)) + name = random_name(gender) mind = body.mind //we don't transfer the mind but we keep a reference to it. @@ -48,7 +45,7 @@ loc = T if(!name) //To prevent nameless ghosts - name = capitalize(pick(first_names_male)) + " " + capitalize(pick(last_names)) + name = random_name(gender) real_name = name ..() @@ -259,4 +256,12 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp if (see_invisible == SEE_INVISIBLE_OBSERVER_NOLIGHTING) see_invisible = SEE_INVISIBLE_OBSERVER else - see_invisible = SEE_INVISIBLE_OBSERVER_NOLIGHTING \ No newline at end of file + see_invisible = SEE_INVISIBLE_OBSERVER_NOLIGHTING + +/mob/dead/observer/verb/pick_form() + set name = "Pick Ghost Form" + set category = "Ghost" + set desc = "Choose your ghostly appearance" + var/new_form = input(src, "Thanks for supporting BYOND - Choose your ghostly form:","Thanks for supporting BYOND","ghost") as null|anything in list("ghost","ghostking","ghostian2") + if(new_form) + icon_state = new_form \ No newline at end of file diff --git a/icons/member_content.dmi b/icons/member_content.dmi new file mode 100644 index 0000000000000000000000000000000000000000..bb59764627628423b93e55a312d327170cb00f6d GIT binary patch literal 2140 zcmV-i2&4CjP)V=-0C=2JR&a84_w-Y6@%7{?OD!tS%+FJ>RWQ*r;NmRLOex7wuvIX!;Nr|k z%}mcIfpCgT5=&AQY!#G}auU;(xHwZXi;5L&6%4sJ(~1&vQz2|+1y?^81s7jWE&vw{ z8LLJt>!1Jt2dPO!K~zYIy_S7!Th$qdpZj57$6vAY**IzA)}(1@(*ahS5L0h#jIx0k z>N-|Uniw!`NCU*CiGemIwrL=tX>6K=HpIjRXp_odFjhvzN3%3ZleTF?32mCvG}$x6qhNj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