Created global lists for hair and facial_hair datums since they are referenced frequently. This means those datums are only ever created once. Also, the list is indexed by hairstyle name. This means means we only need to store one variable to find the hair datum. It also means admins can change h_style and f_style to the name of the hair and use the Regenerate Icons function in viewvars to update a human's hair icon. If an incorrect f_style or h_style is input it won't affect anything adversely (besides hair not showing for that mob).

The hub will no longer report admins who are stealthminning.

Added a server byond_version check. All it does is tell you if your byond_version is below RECOMMENDED_VERSION and encourages you to update BYOND.

Underwear and bag lists are now a single global list rather than creating the same list for every new player.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4268 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
elly1989@rocketmail.com
2012-08-01 13:40:43 +00:00
parent e35a85c5bd
commit a9eabb0561
12 changed files with 131 additions and 272 deletions

View File

@@ -8,12 +8,27 @@ var/global/list/living_mob_list = list()//List of all living mobs, including cli
var/global/list/dead_mob_list = list()//List of all dead mobs, including clientless var/global/list/dead_mob_list = list()//List of all dead mobs, including clientless
var/global/list/client_list = list()//List of all clients, based on ckey var/global/list/client_list = list()//List of all clients, based on ckey
var/global/list/cable_list = list()//Index for all cables, so that powernets don't have to look through the entire world all the time var/global/list/cable_list = list()//Index for all cables, so that powernets don't have to look through the entire world all the time
var/global/list/hair_styles_list = list() //stores /datum/sprite_accessory/hair indexed by name
var/global/list/facial_hair_styles_list = list() //stores /datum/sprite_accessory/facial_hair indexed by name
////////////////////////// //////////////////////////
/////Initial Building///// /////Initial Building/////
////////////////////////// //////////////////////////
//Realistically, these should never be run, but ideally, they should only be run once at round-start //Realistically, these should never be run, but ideally, they should only be run once at round-start
/proc/make_datum_references_lists()
var/list/paths
//Hair - Initialise all /datum/sprite_accessory/hair into an list indexed by hair-style name
paths = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair
for(var/path in paths)
var/datum/sprite_accessory/hair/H = new path()
hair_styles_list[H.name] = H
//Facial Hair - Initialise all /datum/sprite_accessory/facial_hair into an list indexed by facialhair-style name
paths = typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair
for(var/path in paths)
var/datum/sprite_accessory/facial_hair/H = new path()
facial_hair_styles_list[H.name] = H
proc/make_player_list()//Global proc that rebuilds the player list proc/make_player_list()//Global proc that rebuilds the player list
for(var/mob/p in player_list)//Clears out everyone that logged out for(var/mob/p in player_list)//Clears out everyone that logged out
if(!(p.client)) if(!(p.client))

View File

@@ -1,7 +1,10 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31 //This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31
#define RECOMMENDED_VERSION 494
/world/New() /world/New()
..() ..()
if(byond_version < RECOMMENDED_VERSION)
world.log << "Your server's byond version does not meet the recommended requirements for TGstation code. Please update BYOND"
diary = file("data/logs/[time2text(world.realtime, "YYYY/MM-Month/DD-Day")].log") diary = file("data/logs/[time2text(world.realtime, "YYYY/MM-Month/DD-Day")].log")
diary << {" diary << {"
@@ -22,8 +25,9 @@ Starting up. [time2text(world.timeofday, "hh:mm.ss")]
jobban_loadbanfile() jobban_loadbanfile()
jobban_updatelegacybans() jobban_updatelegacybans()
LoadBans() LoadBans()
process_teleport_locs() //Sets up the wizard teleport locations make_datum_references_lists() //initialises global lists for referencing frequently used datums (so that we only ever do it once)
process_ghost_teleport_locs() //Sets up ghost teleport locations. process_teleport_locs() //Sets up the wizard teleport locations
process_ghost_teleport_locs() //Sets up ghost teleport locations.
sleep_offline = 1 sleep_offline = 1
spawn(3000) //so we aren't adding to the round-start lag spawn(3000) //so we aren't adding to the round-start lag
@@ -32,6 +36,7 @@ Starting up. [time2text(world.timeofday, "hh:mm.ss")]
if(config.kick_inactive) if(config.kick_inactive)
KickInactiveClients() KickInactiveClients()
#undef RECOMMENDED_VERSION
#define INACTIVITY_KICK 6000 //10 minutes in ticks (approx.) #define INACTIVITY_KICK 6000 //10 minutes in ticks (approx.)
/world/proc/KickInactiveClients() /world/proc/KickInactiveClients()
for(var/client/C) for(var/client/C)
@@ -42,6 +47,7 @@ Starting up. [time2text(world.timeofday, "hh:mm.ss")]
C << "\red You have been inactive for more than 10 minutes and have been disconnected." C << "\red You have been inactive for more than 10 minutes and have been disconnected."
del(C) del(C)
spawn(3000) KickInactiveClients()//more or less five minutes spawn(3000) KickInactiveClients()//more or less five minutes
#undef INACTIVITY_KICK
/// EXPERIMENTAL STUFF /// EXPERIMENTAL STUFF

View File

@@ -10,37 +10,26 @@
if(length(uni_identity) != 39) if(length(uni_identity) != 39)
//Lazy. //Lazy.
var/temp var/temp
var/hair = 0
var/beard
// determine DNA fragment from hairstyle //Hair
// :wtc: var/hair = 0
if(!character.h_style)
character.h_style = "Skinhead"
var/hrange = round(4095 / hair_styles_list.len)
var/index = hair_styles_list.Find(character.h_style)
if(index)
hair = index * hrange - rand(1,hrange-1)
// If the character doesn't have initialized hairstyles / beardstyles, initialize it for them! //Facial Hair
if(!character.hair_style) var/beard = 0
character.hair_style = new/datum/sprite_accessory/hair/short if(!character.f_style)
character.f_style = "Shaved"
if(!character.facial_hair_style) var/f_hrange = round(4095 / facial_hair_styles_list.len)
character.facial_hair_style = new/datum/sprite_accessory/facial_hair/shaved index = facial_hair_styles_list.Find(character.f_style)
if(index)
var/list/styles = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair beard = index * f_hrange - rand(1,f_hrange-1)
var/hrange = round(4095 / styles.len)
if(character.hair_style)
var/style = styles.Find(character.hair_style.type)
if(style)
hair = style * hrange - rand(1,hrange-1)
// Beard dna code - mostly copypasted from hair code to allow for more dynamic facial hair style additions
var/list/face_styles = typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair
var/f_hrange = round(4095 / face_styles.len)
var/f_style = face_styles.Find(character.facial_hair_style.type)
if(f_style)
beard = f_style * f_hrange - rand(1,f_hrange-1)
else
beard = 0
temp = add_zero2(num2hex((character.r_hair),1), 3) temp = add_zero2(num2hex((character.r_hair),1), 3)
temp += add_zero2(num2hex((character.b_hair),1), 3) temp += add_zero2(num2hex((character.b_hair),1), 3)
@@ -78,32 +67,27 @@
if(length(struc_enzymes)!= 42) struc_enzymes = "0983E840344C39F4B059D5145FC5785DC6406A4000" if(length(struc_enzymes)!= 42) struc_enzymes = "0983E840344C39F4B059D5145FC5785DC6406A4000"
/datum/dna/proc/ready_dna(mob/living/carbon/human/character) /datum/dna/proc/ready_dna(mob/living/carbon/human/character)
var/temp var/temp
var/hair
var/beard
// determine DNA fragment from hairstyle //Hair
// :wtc: var/hair = 0
if(!character.h_style)
character.h_style = "Bald"
var/list/styles = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair var/hrange = round(4095 / hair_styles_list.len)
var/hrange = round(4095 / styles.len) var/index = hair_styles_list.Find(character.h_style)
if(index)
hair = index * hrange - rand(1,hrange-1)
var/style = styles.Find(character.hair_style.type) //Facial Hair
if(style) var/beard = 0
hair = style * hrange - rand(1,hrange-1) if(!character.f_style)
else character.f_style = "Shaved"
hair = 0
// Beard dna code - mostly copypasted from hair code to allow for more dynamic facial hair style additions var/f_hrange = round(4095 / facial_hair_styles_list.len)
var/list/face_styles = typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair index = facial_hair_styles_list.Find(character.f_style)
var/f_hrange = round(4095 / face_styles.len) if(index)
beard = index * f_hrange - rand(1,f_hrange-1)
var/f_style = face_styles.Find(character.facial_hair_style.type)
if(f_style)
beard = f_style * f_hrange - rand(1,f_hrange-1)
else
beard = 0
temp = add_zero2(num2hex((character.r_hair),1), 3) temp = add_zero2(num2hex((character.r_hair),1), 3)
temp += add_zero2(num2hex((character.b_hair),1), 3) temp += add_zero2(num2hex((character.b_hair),1), 3)
@@ -378,32 +362,17 @@
else else
H.gender = MALE H.gender = MALE
//Hair
/// BEARDS
var/beardnum = hex2num(getblock(structure,12,3))
var/list/facial_styles = typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair
var/fstyle = round(1 +(beardnum / 4096)*facial_styles.len)
var/fpath = text2path("[facial_styles[fstyle]]")
var/datum/sprite_accessory/facial_hair/fhair = new fpath
H.face_icon_state = fhair.icon_state
H.f_style = fhair.icon_state
H.facial_hair_style = fhair
// HAIR
var/hairnum = hex2num(getblock(structure,13,3)) var/hairnum = hex2num(getblock(structure,13,3))
var/list/styles = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair var/index = round(1 +(hairnum / 4096)*hair_styles_list.len)
var/style = round(1 +(hairnum / 4096)*styles.len) if((0 < index) && (index <= hair_styles_list.len))
H.h_style = hair_styles_list[index]
var/hpath = text2path("[styles[style]]") //Facial Hair
var/datum/sprite_accessory/hair/hair = new hpath var/beardnum = hex2num(getblock(structure,12,3))
index = round(1 +(beardnum / 4096)*facial_hair_styles_list.len)
H.hair_icon_state = hair.icon_state if((0 < index) && (index <= facial_hair_styles_list.len))
H.h_style = hair.icon_state H.f_style = facial_hair_styles_list[index]
H.hair_style = hair
H.update_body(0) H.update_body(0)
H.update_hair() H.update_hair()

View File

@@ -18,41 +18,15 @@
//handle facial hair (if necessary) //handle facial hair (if necessary)
if(H.gender == MALE) if(H.gender == MALE)
var/list/all_fhairs = typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair //this would probably be better as a global list var/new_style = input(user, "Select a facial hair style", "Grooming") as null|anything in facial_hair_styles_list
var/list/fhairs = list()
for(var/x in all_fhairs)
var/datum/sprite_accessory/facial_hair/F = new x //this goes for the original in preferences too, but it'd
fhairs.Add(F.name) //be nice to avoid all this instantiation and deletion...
del(F)
var/new_style = input(user, "Select a facial hair style", "Grooming") as null|anything in fhairs
if(userloc != H.loc) return //no tele-grooming if(userloc != H.loc) return //no tele-grooming
if(new_style) if(new_style)
for(var/x in all_fhairs) H.f_style = new_style
var/datum/sprite_accessory/facial_hair/F = new x
if(F.name == new_style)
H.facial_hair_style.icon_state = F.icon_state //we only change the icon_state of the hair datum, so it doesn't mess up their UI/UE
break
else
del(F)
//handle normal hair //handle normal hair
var/list/all_hairs = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair //this would probably be better as a global list var/new_style = input(user, "Select a hair style", "Grooming") as null|anything in hair_styles_list
var/list/hairs = list()
for(var/x in all_hairs)
var/datum/sprite_accessory/facial_hair/F = new x
hairs.Add(F.name)
del(F)
var/new_style = input(user, "Select a hair style", "Grooming") as null|anything in hairs
if(userloc != H.loc) return //no tele-grooming if(userloc != H.loc) return //no tele-grooming
if(new_style) if(new_style)
for(var/x in all_hairs) H.h_style = new_style
var/datum/sprite_accessory/hair/F = new x
if(F.name == new_style)
H.hair_style.icon_state = F.icon_state //we only change the icon_state of the hair datum, so it doesn't mess up their UI/UE
break
else
del(F)
H.update_hair() H.update_hair()

View File

@@ -27,15 +27,13 @@
var/n = 0 var/n = 0
var/admins = 0 var/admins = 0
for(var/mob/M in player_list) for(var/client/C in client_list)
if(C.holder)
if(M.client) if(C.stealth)
if(M.client.holder) continue //so stealthmins aren't revealed by the hub
if(!M.client.stealth) admins++
admins++ s["player[n]"] = C.key
n++
s["player[n]"] = M.client.key
n++
s["players"] = n s["players"] = n
// 7 + s["players"] + 1 = index of s["revinfo"] // 7 + s["players"] + 1 = index of s["revinfo"]

View File

@@ -2048,7 +2048,7 @@ var/global/BSACooldown = 0
feedback_inc("admin_secrets_fun_used",1) feedback_inc("admin_secrets_fun_used",1)
feedback_add_details("admin_secrets_fun_used","DF") feedback_add_details("admin_secrets_fun_used","DF")
for(var/mob/living/carbon/human/B in mob_list) for(var/mob/living/carbon/human/B in mob_list)
B.face_icon_state = "facial_wise" B.f_style = "Dward Beard"
B.update_hair() B.update_hair()
message_admins("[key_name_admin(usr)] activated dorf mode") message_admins("[key_name_admin(usr)] activated dorf mode")
else else

View File

@@ -72,10 +72,10 @@
/mob/living/carbon/human/proc/ChangeToHusk() /mob/living/carbon/human/proc/ChangeToHusk()
if(HUSK in mutations) return if(HUSK in mutations) return
if(facial_hair_style) if(f_style)
facial_hair_style.icon_state = "bald" //we only change the icon_state of the hair datum, so it doesn't mess up their UI/UE f_style = "Shaved" //we only change the icon_state of the hair datum, so it doesn't mess up their UI/UE
if(hair_style) if(h_style)
hair_style.icon_state = "bald" h_style = "Bald"
update_hair(0) update_hair(0)
mutations.Add(HUSK) mutations.Add(HUSK)

View File

@@ -1,29 +1,25 @@
/mob/living/carbon/human /mob/living/carbon/human
//Hair colour and style //Hair colour and style
var/r_hair = 0.0 var/r_hair = 0
var/g_hair = 0.0 var/g_hair = 0
var/b_hair = 0.0 var/b_hair = 0
var/h_style = "Short Hair" var/h_style = "Bald"
var/datum/sprite_accessory/hair/hair_style
var/hair_icon_state = "hair_a"
//Facial hair colour and style //Facial hair colour and style
var/r_facial = 0.0 var/r_facial = 0
var/g_facial = 0.0 var/g_facial = 0
var/b_facial = 0.0 var/b_facial = 0
var/f_style = "Shaved" var/f_style = "Shaved"
var/datum/sprite_accessory/facial_hair/facial_hair_style
var/face_icon_state = "bald"
//Eye colour //Eye colour
var/r_eyes = 0.0 var/r_eyes = 0
var/g_eyes = 0.0 var/g_eyes = 0
var/b_eyes = 0.0 var/b_eyes = 0
var/s_tone = 0.0 //Skin tone var/s_tone = 0 //Skin tone
var/age = 30.0 //Player's age (pure fluff) var/age = 30 //Player's age (pure fluff)
var/b_type = "A+" //Player's bloodtype (Not currently used, just character fluff) var/b_type = "A+" //Player's bloodtype (Not currently used, just character fluff)
var/underwear = 1 //Which underwear the player wants var/underwear = 1 //Which underwear the player wants

View File

@@ -241,21 +241,25 @@ Please contact me on #coderbus IRC. ~Carn x
var/icon/face_standing = new /icon('icons/mob/human_face.dmi',"bald_s") var/icon/face_standing = new /icon('icons/mob/human_face.dmi',"bald_s")
var/icon/face_lying = new /icon('icons/mob/human_face.dmi',"bald_l") var/icon/face_lying = new /icon('icons/mob/human_face.dmi',"bald_l")
if(facial_hair_style) if(f_style)
var/icon/facial_s = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_s") var/datum/sprite_accessory/facial_hair_style = facial_hair_styles_list[f_style]
var/icon/facial_l = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_l") if(facial_hair_style)
facial_s.Blend(rgb(r_facial, g_facial, b_facial), ICON_ADD) var/icon/facial_s = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_s")
facial_l.Blend(rgb(r_facial, g_facial, b_facial), ICON_ADD) var/icon/facial_l = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_l")
face_standing.Blend(facial_s, ICON_OVERLAY) facial_s.Blend(rgb(r_facial, g_facial, b_facial), ICON_ADD)
face_lying.Blend(facial_l, ICON_OVERLAY) facial_l.Blend(rgb(r_facial, g_facial, b_facial), ICON_ADD)
face_standing.Blend(facial_s, ICON_OVERLAY)
face_lying.Blend(facial_l, ICON_OVERLAY)
if(hair_style) if(h_style)
var/icon/hair_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_s") var/datum/sprite_accessory/hair_style = hair_styles_list[h_style]
var/icon/hair_l = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_l") if(hair_style)
hair_s.Blend(rgb(r_hair, g_hair, b_hair), ICON_ADD) var/icon/hair_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_s")
hair_l.Blend(rgb(r_hair, g_hair, b_hair), ICON_ADD) var/icon/hair_l = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_l")
face_standing.Blend(hair_s, ICON_OVERLAY) hair_s.Blend(rgb(r_hair, g_hair, b_hair), ICON_ADD)
face_lying.Blend(hair_l, ICON_OVERLAY) hair_l.Blend(rgb(r_hair, g_hair, b_hair), ICON_ADD)
face_standing.Blend(hair_s, ICON_OVERLAY)
face_lying.Blend(hair_l, ICON_OVERLAY)
overlays_lying[HAIR_LAYER] = image(face_lying) overlays_lying[HAIR_LAYER] = image(face_lying)
overlays_standing[HAIR_LAYER] = image(face_standing) overlays_standing[HAIR_LAYER] = image(face_standing)

View File

@@ -17,6 +17,10 @@ var/global/list/special_roles = list( //keep synced with the defines BE_* in set
"infested monkey" = IS_MODE_COMPILED("monkey"), // 9 "infested monkey" = IS_MODE_COMPILED("monkey"), // 9
) )
var/global/list/underwear_m = list("White", "Grey", "Green", "Blue", "Black", "Mankini", "Love-Hearts", "Black2", "Grey2", "Stripey", "Kinky", "None") //Curse whoever made male/female underwear diffrent colours
var/global/list/underwear_f = list("Red", "White", "Yellow", "Blue", "Black", "Thong", "Babydoll", "Baby-Blue", "Green", "Pink", "Kinky", "None")
var/global/list/backbaglist = list("Nothing", "Backpack", "Satchel")
var/const/BE_TRAITOR =(1<<0) var/const/BE_TRAITOR =(1<<0)
var/const/BE_OPERATIVE =(1<<1) var/const/BE_OPERATIVE =(1<<1)
var/const/BE_CHANGELING=(1<<2) var/const/BE_CHANGELING=(1<<2)
@@ -53,14 +57,10 @@ datum/preferences
//Just like it sounds //Just like it sounds
var/ooccolor = "#b82e00" var/ooccolor = "#b82e00"
var/underwear = 1 var/underwear = 1
var/list/underwear_m = list("White", "Grey", "Green", "Blue", "Black", "Mankini", "Love-Hearts", "Black2", "Grey2", "Stripey", "Kinky", "None") //Curse whoever made male/female underwear diffrent colours
var/list/underwear_f = list("Red", "White", "Yellow", "Blue", "Black", "Thong", "Babydoll", "Baby-Blue", "Green", "Pink", "Kinky", "None")
var/backbag = 2 var/backbag = 2
var/list/backbaglist = list("Nothing", "Backpack", "Satchel")
//Hair type //Hair type
var/h_style = "Short Hair" var/h_style = "Bald"
var/datum/sprite_accessory/hair/hair_style
//Hair color //Hair color
var/r_hair = 0 var/r_hair = 0
var/g_hair = 0 var/g_hair = 0
@@ -68,7 +68,6 @@ datum/preferences
//Face hair type //Face hair type
var/f_style = "Shaved" var/f_style = "Shaved"
var/datum/sprite_accessory/facial_hair/facial_hair_style
//Face hair color //Face hair color
var/r_facial = 0 var/r_facial = 0
var/g_facial = 0 var/g_facial = 0
@@ -116,8 +115,6 @@ datum/preferences
New() New()
hair_style = new/datum/sprite_accessory/hair/short
facial_hair_style = new/datum/sprite_accessory/facial_hair/shaved
randomize_name() randomize_name()
..() ..()
@@ -557,33 +554,10 @@ datum/preferences
// see preferences_setup.dm for proc // see preferences_setup.dm for proc
if("input") // input hair selection if("input") // input hair selection
var/new_style = input(user, "Select a hair style", "Character Generation") as null|anything in hair_styles_list
// Generate list of hairs via typesof()
var/list/all_hairs = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair
// List of hair names
var/list/hairs = list()
// loop through potential hairs
for(var/x in all_hairs)
var/datum/sprite_accessory/hair/H = new x // create new hair datum based on type x
hairs.Add(H.name) // add hair name to hairs
del(H) // delete the hair after it's all done
// prompt the user for a hair selection, the selection being anything in list hairs
var/new_style = input(user, "Select a hair style", "Character Generation") as null|anything in hairs
// if new style selected (not cancel)
if(new_style) if(new_style)
h_style = new_style h_style = new_style
for(var/x in all_hairs) // loop through all_hairs again. Might be slightly CPU expensive, but not significantly.
var/datum/sprite_accessory/hair/H = new x // create new hair datum
if(H.name == new_style)
hair_style = H // assign the hair_style variable a new hair datum
break
else
del(H) // if hair H not used, delete. BYOND can garbage collect, but better safe than sorry
if(link_tags["ooccolor"]) if(link_tags["ooccolor"])
var/ooccolor = input(user, "Please select OOC colour.", "OOC colour") as color var/ooccolor = input(user, "Please select OOC colour.", "OOC colour") as color
@@ -599,28 +573,12 @@ datum/preferences
// see above for commentation. This is just a slight modification of the hair code for facial hairs // see above for commentation. This is just a slight modification of the hair code for facial hairs
if("random") if("random")
randomize_facial(gender) randomize_facial(gender)
if("input") if("input")
var/new_style = input(user, "Select a facial hair style", "Character Generation") as null|anything in facial_hair_styles_list
var/list/all_fhairs = typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair
var/list/fhairs = list()
for(var/x in all_fhairs)
var/datum/sprite_accessory/facial_hair/H = new x
fhairs.Add(H.name)
del(H)
var/new_style = input(user, "Select a facial hair style", "Character Generation") as null|anything in fhairs
if(new_style) if(new_style)
f_style = new_style f_style = new_style
for(var/x in all_fhairs)
var/datum/sprite_accessory/facial_hair/H = new x
if(H.name == new_style)
facial_hair_style = H
break
else
del(H)
if(link_tags["gender"]) if(link_tags["gender"])
if(gender == MALE) if(gender == MALE)
@@ -788,9 +746,6 @@ datum/preferences
else else
character.UI = 'icons/mob/screen1_Midnight.dmi' character.UI = 'icons/mob/screen1_Midnight.dmi'
character.hair_style = hair_style
character.facial_hair_style = facial_hair_style
if(underwear > 12 || underwear < 1) if(underwear > 12 || underwear < 1)
underwear = 1 //I'm sure this is 100% unnecessary, but I'm paranoid... sue me. underwear = 1 //I'm sure this is 100% unnecessary, but I'm paranoid... sue me.
character.underwear = underwear character.underwear = underwear

View File

@@ -26,47 +26,11 @@ datum/preferences
return return
proc/randomize_hair(var/gender) proc/randomize_hair(var/gender)
// Generate list of all possible hairs via typesof(), subtract the parent type however h_style = pick(hair_styles_list)
var/list/all_hairs = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair
// List of hair datums. Used in pick() to select random hair
var/list/hairs = list()
// Loop through potential hairs
for(var/x in all_hairs)
var/datum/sprite_accessory/hair/H = new x // create new hair datum based on type x
if(gender == FEMALE && H.choose_female) // if female and hair is female-suitable, add to possible hairs
hairs.Add(H)
else if(gender != FEMALE && H.choose_male) // if male and hair is male-suitable, add to hairs
hairs.Add(H)
else
del(H) // delete if incompatible
if(hairs.len > 0) // if hairs could be generated
hair_style = pick(hairs) // assign random hair
h_style = hair_style.name
proc/randomize_facial() // uncommented, see randomize_hair() for commentation proc/randomize_facial() // uncommented, see randomize_hair() for commentation
var/list/all_fhairs = typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair f_style = pick(facial_hair_styles_list)
var/list/fhairs = list()
for(var/x in all_fhairs)
var/datum/sprite_accessory/facial_hair/H = new x
if(gender == FEMALE && H.choose_female)
fhairs.Add(H)
else if(gender != FEMALE && H.choose_male)
fhairs.Add(H)
else
del(H)
if(fhairs.len > 0)
facial_hair_style = pick(fhairs)
f_style = facial_hair_style.name
proc/randomize_skin_tone() proc/randomize_skin_tone()
var/tone var/tone
@@ -138,7 +102,7 @@ datum/preferences
green = max(min(green + rand (-25, 25), 255), 0) green = max(min(green + rand (-25, 25), 255), 0)
blue = max(min(blue + rand (-25, 25), 255), 0) blue = max(min(blue + rand (-25, 25), 255), 0)
switch (target) switch(target)
if ("hair") if ("hair")
r_hair = red r_hair = red
g_hair = green g_hair = green
@@ -222,20 +186,20 @@ datum/preferences
var/icon/eyes_s = new/icon("icon" = 'icons/mob/human_face.dmi', "icon_state" = "eyes_s") var/icon/eyes_s = new/icon("icon" = 'icons/mob/human_face.dmi', "icon_state" = "eyes_s")
eyes_s.Blend(rgb(r_eyes, g_eyes, b_eyes), ICON_ADD) eyes_s.Blend(rgb(r_eyes, g_eyes, b_eyes), ICON_ADD)
var/datum/sprite_accessory/hair_style = hair_styles_list[h_style]
// Hair and facial hair, improved by Doohl if(hair_style)
var/icon/hair_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_s") var/icon/hair_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_s")
hair_s.Blend(rgb(r_hair, g_hair, b_hair), ICON_ADD) hair_s.Blend(rgb(r_hair, g_hair, b_hair), ICON_ADD)
eyes_s.Blend(hair_s, ICON_OVERLAY)
var/icon/facial_s = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_s")
facial_s.Blend(rgb(r_facial, g_facial, b_facial), ICON_ADD)
var/icon/mouth_s = new/icon("icon" = 'icons/mob/human_face.dmi', "icon_state" = "mouth_[g]_s") var/icon/mouth_s = new/icon("icon" = 'icons/mob/human_face.dmi', "icon_state" = "mouth_[g]_s")
eyes_s.Blend(hair_s, ICON_OVERLAY)
eyes_s.Blend(mouth_s, ICON_OVERLAY) eyes_s.Blend(mouth_s, ICON_OVERLAY)
eyes_s.Blend(facial_s, ICON_OVERLAY)
var/datum/sprite_accessory/facial_hair_style = facial_hair_styles_list[f_style]
if(facial_hair_style)
var/icon/facial_s = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_s")
facial_s.Blend(rgb(r_facial, g_facial, b_facial), ICON_ADD)
eyes_s.Blend(facial_s, ICON_OVERLAY)
var/icon/clothes_s = null var/icon/clothes_s = null
if(job_civilian_low & ASSISTANT)//This gives the preview icon clothes depending on which job(if any) is set to 'high' if(job_civilian_low & ASSISTANT)//This gives the preview icon clothes depending on which job(if any) is set to 'high'
@@ -532,27 +496,7 @@ datum/preferences
del(preview_icon) del(preview_icon)
del(mouth_s) del(mouth_s)
del(facial_s)
del(hair_s)
del(eyes_s) del(eyes_s)
del(clothes_s) del(clothes_s)
proc/style_to_datum()
// use h_style and f_style to load /datum hairs
// hairs
for(var/x in typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair)
var/datum/sprite_accessory/hair/H = new x
if(H.name == h_style)
hair_style = H
else
del(H)
// facial hairs
for(var/x in typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair)
var/datum/sprite_accessory/facial_hair/H = new x
if(H.name == f_style)
facial_hair_style = H
else
del(H)

View File

@@ -188,8 +188,6 @@ datum/preferences/proc/savefile_load(mob/user)
if(version && version < SAVEFILE_VERSION_MAX) if(version && version < SAVEFILE_VERSION_MAX)
convert_hairstyles() // convert version 4 hairstyles to version 5 convert_hairstyles() // convert version 4 hairstyles to version 5
style_to_datum() // convert f_style and h_style to /datum
return 1 return 1
#undef SAVEFILE_VERSION_MAX #undef SAVEFILE_VERSION_MAX