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/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/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/////
//////////////////////////
//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
for(var/mob/p in player_list)//Clears out everyone that logged out
if(!(p.client))

View File

@@ -1,7 +1,10 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31
#define RECOMMENDED_VERSION 494
/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 << {"
@@ -22,6 +25,7 @@ Starting up. [time2text(world.timeofday, "hh:mm.ss")]
jobban_loadbanfile()
jobban_updatelegacybans()
LoadBans()
make_datum_references_lists() //initialises global lists for referencing frequently used datums (so that we only ever do it once)
process_teleport_locs() //Sets up the wizard teleport locations
process_ghost_teleport_locs() //Sets up ghost teleport locations.
sleep_offline = 1
@@ -32,6 +36,7 @@ Starting up. [time2text(world.timeofday, "hh:mm.ss")]
if(config.kick_inactive)
KickInactiveClients()
#undef RECOMMENDED_VERSION
#define INACTIVITY_KICK 6000 //10 minutes in ticks (approx.)
/world/proc/KickInactiveClients()
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."
del(C)
spawn(3000) KickInactiveClients()//more or less five minutes
#undef INACTIVITY_KICK
/// EXPERIMENTAL STUFF

View File

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

View File

@@ -18,41 +18,15 @@
//handle facial hair (if necessary)
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/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
var/new_style = input(user, "Select a facial hair style", "Grooming") as null|anything in facial_hair_styles_list
if(userloc != H.loc) return //no tele-grooming
if(new_style)
for(var/x in all_fhairs)
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)
H.f_style = new_style
//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/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
var/new_style = input(user, "Select a hair style", "Grooming") as null|anything in hair_styles_list
if(userloc != H.loc) return //no tele-grooming
if(new_style)
for(var/x in all_hairs)
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.h_style = new_style
H.update_hair()

View File

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

View File

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

View File

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

View File

@@ -1,29 +1,25 @@
/mob/living/carbon/human
//Hair colour and style
var/r_hair = 0.0
var/g_hair = 0.0
var/b_hair = 0.0
var/h_style = "Short Hair"
var/datum/sprite_accessory/hair/hair_style
var/hair_icon_state = "hair_a"
var/r_hair = 0
var/g_hair = 0
var/b_hair = 0
var/h_style = "Bald"
//Facial hair colour and style
var/r_facial = 0.0
var/g_facial = 0.0
var/b_facial = 0.0
var/r_facial = 0
var/g_facial = 0
var/b_facial = 0
var/f_style = "Shaved"
var/datum/sprite_accessory/facial_hair/facial_hair_style
var/face_icon_state = "bald"
//Eye colour
var/r_eyes = 0.0
var/g_eyes = 0.0
var/b_eyes = 0.0
var/r_eyes = 0
var/g_eyes = 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/underwear = 1 //Which underwear the player wants

View File

@@ -241,6 +241,8 @@ Please contact me on #coderbus IRC. ~Carn x
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")
if(f_style)
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")
var/icon/facial_l = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_l")
@@ -249,6 +251,8 @@ Please contact me on #coderbus IRC. ~Carn x
face_standing.Blend(facial_s, ICON_OVERLAY)
face_lying.Blend(facial_l, ICON_OVERLAY)
if(h_style)
var/datum/sprite_accessory/hair_style = hair_styles_list[h_style]
if(hair_style)
var/icon/hair_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_s")
var/icon/hair_l = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_l")

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
)
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_OPERATIVE =(1<<1)
var/const/BE_CHANGELING=(1<<2)
@@ -53,14 +57,10 @@ datum/preferences
//Just like it sounds
var/ooccolor = "#b82e00"
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/list/backbaglist = list("Nothing", "Backpack", "Satchel")
//Hair type
var/h_style = "Short Hair"
var/datum/sprite_accessory/hair/hair_style
var/h_style = "Bald"
//Hair color
var/r_hair = 0
var/g_hair = 0
@@ -68,7 +68,6 @@ datum/preferences
//Face hair type
var/f_style = "Shaved"
var/datum/sprite_accessory/facial_hair/facial_hair_style
//Face hair color
var/r_facial = 0
var/g_facial = 0
@@ -116,8 +115,6 @@ datum/preferences
New()
hair_style = new/datum/sprite_accessory/hair/short
facial_hair_style = new/datum/sprite_accessory/facial_hair/shaved
randomize_name()
..()
@@ -557,33 +554,10 @@ datum/preferences
// see preferences_setup.dm for proc
if("input") // input hair selection
// 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)
var/new_style = input(user, "Select a hair style", "Character Generation") as null|anything in hair_styles_list
if(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"])
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
if("random")
randomize_facial(gender)
if("input")
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
var/new_style = input(user, "Select a facial hair style", "Character Generation") as null|anything in facial_hair_styles_list
if(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(gender == MALE)
@@ -788,9 +746,6 @@ datum/preferences
else
character.UI = 'icons/mob/screen1_Midnight.dmi'
character.hair_style = hair_style
character.facial_hair_style = facial_hair_style
if(underwear > 12 || underwear < 1)
underwear = 1 //I'm sure this is 100% unnecessary, but I'm paranoid... sue me.
character.underwear = underwear

View File

@@ -26,47 +26,11 @@ datum/preferences
return
proc/randomize_hair(var/gender)
// Generate list of all possible hairs via typesof(), subtract the parent type however
var/list/all_hairs = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair
h_style = pick(hair_styles_list)
// 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
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
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
f_style = pick(facial_hair_styles_list)
proc/randomize_skin_tone()
var/tone
@@ -222,19 +186,19 @@ datum/preferences
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)
// Hair and facial hair, improved by Doohl
var/datum/sprite_accessory/hair_style = hair_styles_list[h_style]
if(hair_style)
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)
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(hair_s, ICON_OVERLAY)
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)
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
@@ -532,27 +496,7 @@ datum/preferences
del(preview_icon)
del(mouth_s)
del(facial_s)
del(hair_s)
del(eyes_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)
convert_hairstyles() // convert version 4 hairstyles to version 5
style_to_datum() // convert f_style and h_style to /datum
return 1
#undef SAVEFILE_VERSION_MAX