Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] /datum/species => /decl/species #290

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions code/_helpers/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,21 @@ var/global/list/string_slot_flags = list(
return 1

// This is all placeholder procs for an eventual PR to change them to use decls.
var/list/all_species
var/list/playable_species // A list of ALL playable species, whitelisted, latejoin or otherwise.
var/list/all_species = list()
var/list/playable_species = list() // A list of ALL playable species, whitelisted, latejoin or otherwise.
/proc/build_species_lists()
if(global.all_species && global.playable_species)
return
global.playable_species = list()
global.all_species = list()
for(var/species_type in typesof(/datum/species))
var/datum/species/species = species_type
var/species_name = initial(species.name)
if(species_name)
global.all_species[species_name] = new species
species = get_species_by_key(species_name)
global.all_species.Cut()
global.playable_species.Cut()
var/list/species_decls = decls_repository.get_decls_of_subtype(/decl/species)
for(var/species_type in species_decls)
var/decl/species/species = species_decls[species_type]
if(species.name)
global.all_species[species.name] = species
if(!(species.spawn_flags & SPECIES_IS_RESTRICTED))
global.playable_species += species.name
if(GLOB.using_map.default_species)
global.playable_species |= GLOB.using_map.default_species

/proc/get_species_by_key(var/species_key)
build_species_lists()
. = global.all_species[species_key]
Expand Down
8 changes: 4 additions & 4 deletions code/_helpers/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ proc/random_hair_style(gender, species)
species = species || GLOB.using_map.default_species
var/h_style = "Bald"

var/datum/species/mob_species = get_species_by_key(species)
var/decl/species/mob_species = get_species_by_key(species)
var/list/valid_hairstyles = mob_species.get_hair_styles()
if(valid_hairstyles.len)
h_style = pick(valid_hairstyles)
Expand All @@ -38,22 +38,22 @@ proc/random_hair_style(gender, species)
proc/random_facial_hair_style(gender, var/species)
species = species || GLOB.using_map.default_species
var/f_style = "Shaved"
var/datum/species/mob_species = get_species_by_key(species)
var/decl/species/mob_species = get_species_by_key(species)
var/list/valid_facialhairstyles = mob_species.get_facial_hair_styles(gender)
if(valid_facialhairstyles.len)
f_style = pick(valid_facialhairstyles)
return f_style

proc/random_name(gender, species)
if(species)
var/datum/species/current_species = get_species_by_key(species)
var/decl/species/current_species = get_species_by_key(species)
if(current_species)
var/decl/cultural_info/current_culture = SSlore.get_culture(current_species.default_cultural_info[TAG_CULTURE])
if(current_culture)
return current_culture.get_random_name(null, gender)
return capitalize(pick(gender == FEMALE ? GLOB.first_names_female : GLOB.first_names_male)) + " " + capitalize(pick(GLOB.last_names))

proc/random_skin_tone(var/datum/species/current_species)
proc/random_skin_tone(var/decl/species/current_species)
var/species_tone = current_species ? 35 - current_species.max_skin_tone() : -185
switch(pick(60;"caucasian", 15;"afroamerican", 10;"african", 10;"latino", 5;"albino"))
if("caucasian") . = -10
Expand Down
10 changes: 5 additions & 5 deletions code/datums/mil_ranks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var/datum/mil_branches/mil_branches = new()
/**
* Return all spawn branches for the given input
*/
/datum/mil_branches/proc/spawn_branches(var/datum/species/S)
/datum/mil_branches/proc/spawn_branches(var/decl/species/S)
if(!S)
return spawn_branches_.Copy()
. = LAZYACCESS(spawn_branches_by_species_, S)
Expand All @@ -67,21 +67,21 @@ var/datum/mil_branches/mil_branches = new()
/**
* Return all spawn ranks for the given input
*/
/datum/mil_branches/proc/spawn_ranks(var/branch_name, var/datum/species/S)
/datum/mil_branches/proc/spawn_ranks(var/branch_name, var/decl/species/S)
var/datum/mil_branch/branch = get_branch(branch_name)
return branch && branch.spawn_ranks(S)

/**
* Return a true value if branch_name is a valid spawn branch key
*/
/datum/mil_branches/proc/is_spawn_branch(var/branch_name, var/datum/species/S)
/datum/mil_branches/proc/is_spawn_branch(var/branch_name, var/decl/species/S)
return (branch_name in spawn_branches(S))


/**
* Return a true value if rank_name is a valid spawn rank in branch under branch_name
*/
/datum/mil_branches/proc/is_spawn_rank(var/branch_name, var/rank_name, var/datum/species/S)
/datum/mil_branches/proc/is_spawn_rank(var/branch_name, var/rank_name, var/decl/species/S)
var/datum/mil_branch/branch = get_branch(branch_name)
if(branch && (rank_name in branch.spawn_ranks(S)))
return TRUE
Expand Down Expand Up @@ -128,7 +128,7 @@ var/datum/mil_branches/mil_branches = new()
if(rank_path in spawn_rank_types)
spawn_ranks_[rank.name] = rank

/datum/mil_branch/proc/spawn_ranks(var/datum/species/S)
/datum/mil_branch/proc/spawn_ranks(var/decl/species/S)
if(!S)
return spawn_ranks_.Copy()
. = spawn_ranks_by_species_[S]
Expand Down
2 changes: 1 addition & 1 deletion code/game/antagonist/station/changeling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ GLOBAL_DATUM_INIT(changelings, /datum/antagonist/changeling, new)
return 1
else if(isnewplayer(player.current))
if(player.current.client && player.current.client.prefs)
var/datum/species/S = get_species_by_key(player.current.client.prefs.species)
var/decl/species/S = get_species_by_key(player.current.client.prefs.species)
if(S && (S.species_flags & SPECIES_FLAG_NO_SCAN))
return 0
if(player.current.client.prefs.organ_data[BP_CHEST] == "cyborg") // Full synthetic.
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/changeling/changeling_powers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ var/global/list/possible_changeling_IDs = list("Alpha","Beta","Gamma","Delta","E
changeling.geneticdamage = 30

var/S_name = chosen_dna.speciesName
var/datum/species/S_dat = get_species_by_key(S_name)
var/decl/species/S_dat = get_species_by_key(S_name)
var/changeTime = 2 SECONDS
if(mob_size != S_dat.mob_size)
src.visible_message("<span class='warning'>[src]'s body begins to twist, their mass changing rapidly!</span>")
Expand Down Expand Up @@ -604,7 +604,7 @@ var/list/datum/absorbed_dna/hivemind_bank = list()
if(!chosen_dna)
return

var/datum/species/spec = get_species_by_key(chosen_dna.speciesName)
var/decl/species/spec = get_species_by_key(chosen_dna.speciesName)

if(spec && spec.species_flags & SPECIES_FLAG_NEED_DIRECT_ABSORB)
to_chat(src, "<span class='notice'>That species must be absorbed directly.</span>")
Expand Down
8 changes: 4 additions & 4 deletions code/game/jobs/job/_job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
to_chat(feedback, "<span class='boldannounce'>Wrong rank for [title]. Valid ranks in [prefs.branches[title]] are: [get_ranks(prefs.branches[title])].</span>")
return TRUE

var/datum/species/S = get_species_by_key(prefs.species)
var/decl/species/S = get_species_by_key(prefs.species)
if(!is_species_allowed(S))
to_chat(feedback, "<span class='boldannounce'>Restricted species, [S], for [title].</span>")
return TRUE
Expand Down Expand Up @@ -239,7 +239,7 @@
active++
return active

/datum/job/proc/is_species_allowed(var/datum/species/S)
/datum/job/proc/is_species_allowed(var/decl/species/S)
if(GLOB.using_map.is_species_job_restricted(S, src))
return FALSE
// We also make sure that there is at least one valid branch-rank combo for the species.
Expand All @@ -248,7 +248,7 @@
return LAZYLEN(get_branch_rank(S))

// Don't use if the map doesn't use branches but jobs do.
/datum/job/proc/get_branch_rank(var/datum/species/S)
/datum/job/proc/get_branch_rank(var/decl/species/S)
. = species_branch_rank_cache_[S]
if(.)
return
Expand Down Expand Up @@ -364,7 +364,7 @@
reasons["Your branch of service does not allow it."] = TRUE
else if(!isnull(allowed_ranks) && (!caller.prefs.ranks[title] || !is_rank_allowed(caller.prefs.branches[title], caller.prefs.ranks[title])))
reasons["Your rank choice does not allow it."] = TRUE
var/datum/species/S = get_species_by_key(caller.prefs.species)
var/decl/species/S = get_species_by_key(caller.prefs.species)
if(S)
if(!is_species_allowed(S))
reasons["Your species choice does not allow it."] = TRUE
Expand Down
6 changes: 3 additions & 3 deletions code/game/jobs/whitelist.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var/list/whitelist = list()
return 1

/proc/is_species_whitelisted(mob/M, var/species_name)
var/datum/species/S = get_species_by_key(species_name)
var/decl/species/S = get_species_by_key(species_name)
return is_alien_whitelisted(M, S)

//todo: admin aliens
Expand All @@ -68,8 +68,8 @@ var/list/whitelist = list()
return 1
return whitelist_lookup(L.name, M.ckey)

if(istype(species,/datum/species))
var/datum/species/S = species
if(istype(species,/decl/species))
var/decl/species/S = species
if(!(S.spawn_flags & (SPECIES_IS_WHITELISTED|SPECIES_IS_RESTRICTED)))
return 1
return whitelist_lookup(S.get_root_species_name(M), M.ckey)
Expand Down
2 changes: 1 addition & 1 deletion code/game/movietitles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ client
else if(H.real_name)
corpses += H.real_name
for(var/spec in monkies)
var/datum/species/S = get_species_by_key(spec)
var/decl/species/S = get_species_by_key(spec)
corpses += "[monkies[spec]] [lowertext(monkies[spec] > 1 ? S.name_plural : S.name)]"
if(corpses.len)
titles += "<center>BASED ON REAL EVENTS<br>In memory of [english_list(corpses)].</center>"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define GET_ALLOWED_VALUES(write_to, check_key) \
var/datum/species/S = get_species_by_key(pref.species); \
var/decl/species/S = get_species_by_key(pref.species); \
if(!S) { \
write_to = list(); \
} else if(S.force_cultural_info[check_key]) { \
Expand Down
4 changes: 2 additions & 2 deletions code/modules/client/preference_setup/general/01_basic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ datum/preferences
to_file(S["name_is_always_random"], pref.be_random_name)

/datum/category_item/player_setup_item/physical/basic/sanitize_character()
var/datum/species/S = get_species_by_key(pref.species) || get_species_by_key(GLOB.using_map.default_species)
var/decl/species/S = get_species_by_key(pref.species) || get_species_by_key(GLOB.using_map.default_species)
pref.age = sanitize_integer(pref.age, S.min_age, S.max_age, initial(pref.age))
pref.gender = sanitize_inlist(pref.gender, S.genders, pick(S.genders))
pref.spawnpoint = sanitize_inlist(pref.spawnpoint, spawntypes(), initial(pref.spawnpoint))
Expand Down Expand Up @@ -56,7 +56,7 @@ datum/preferences
. = jointext(.,null)

/datum/category_item/player_setup_item/physical/basic/OnTopic(var/href,var/list/href_list, var/mob/user)
var/datum/species/S = get_species_by_key(pref.species)
var/decl/species/S = get_species_by_key(pref.species)

if(href_list["rename"])
var/raw_name = input(user, "Choose your character's name:", "Character Name") as text|null
Expand Down
20 changes: 10 additions & 10 deletions code/modules/client/preference_setup/general/02_body.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
if(!pref.species || !(pref.species in get_playable_species()))
pref.species = GLOB.using_map.default_species

var/datum/species/mob_species = get_species_by_key(pref.species)
var/decl/species/mob_species = get_species_by_key(pref.species)

var/low_skin_tone = mob_species ? (35 - mob_species.max_skin_tone()) : -185
sanitize_integer(pref.skin_tone, low_skin_tone, 34, initial(pref.skin_tone))
Expand Down Expand Up @@ -148,7 +148,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
pref.update_preview_icon()
send_rsc(user, pref.preview_icon, "previewicon.png")

var/datum/species/mob_species = get_species_by_key(pref.species)
var/decl/species/mob_species = get_species_by_key(pref.species)
var/title = "<b>Species<a href='?src=\ref[src];show_species=1'><small>?</small></a>:</b> <a href='?src=\ref[src];set_species=1'>[mob_species.name]</a>"
var/append_text = "<a href='?src=\ref[src];toggle_species_verbose=1'>[hide_species ? "Expand" : "Collapse"]</a>"
. += "<hr>"
Expand Down Expand Up @@ -295,12 +295,12 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O

. = jointext(.,null)

/datum/category_item/player_setup_item/physical/body/proc/has_flag(var/datum/species/mob_species, var/flag)
/datum/category_item/player_setup_item/physical/body/proc/has_flag(var/decl/species/mob_species, var/flag)
return mob_species && (mob_species.appearance_flags & flag)

/datum/category_item/player_setup_item/physical/body/OnTopic(var/href,var/list/href_list, var/mob/user)

var/datum/species/mob_species = get_species_by_key(pref.species)
var/decl/species/mob_species = get_species_by_key(pref.species)
if(href_list["toggle_species_verbose"])
hide_species = !hide_species
return TOPIC_REFRESH
Expand Down Expand Up @@ -328,7 +328,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
else if(href_list["show_species"])
var/choice = input("Which species would you like to look at?") as null|anything in get_playable_species()
if(choice)
var/datum/species/current_species = get_species_by_key(choice)
var/decl/species/current_species = get_species_by_key(choice)
show_browser(user, current_species.get_description(), "window=species;size=700x400")
return TOPIC_HANDLED

Expand All @@ -337,7 +337,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
var/list/species_to_pick = list()
for(var/species in get_playable_species())
if(!check_rights(R_ADMIN, 0) && config.usealienwhitelist)
var/datum/species/current_species = get_species_by_key(species)
var/decl/species/current_species = get_species_by_key(species)
if(!(current_species.spawn_flags & SPECIES_CAN_JOIN))
continue
else if((current_species.spawn_flags & SPECIES_IS_WHITELISTED) && !is_alien_whitelisted(preference_mob(),current_species))
Expand Down Expand Up @@ -545,7 +545,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
pref.rlimb_data[second_limb] = null

if("Prosthesis")
var/datum/species/temp_species = get_species_by_key(pref.species || GLOB.using_map.default_species)
var/decl/species/temp_species = get_species_by_key(pref.species || GLOB.using_map.default_species)
var/tmp_bodytype = temp_species.get_bodytype(user)
var/list/usable_manufacturers = list()
for(var/company in chargen_robolimbs)
Expand Down Expand Up @@ -652,7 +652,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
ResetFacialHair()

/datum/category_item/player_setup_item/proc/ResetHair()
var/datum/species/mob_species = get_species_by_key(pref.species)
var/decl/species/mob_species = get_species_by_key(pref.species)
var/list/valid_hairstyles = mob_species.get_hair_styles()

if(valid_hairstyles.len)
Expand All @@ -662,7 +662,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
pref.h_style = GLOB.hair_styles_list["Bald"]

/datum/category_item/player_setup_item/proc/ResetFacialHair()
var/datum/species/mob_species = get_species_by_key(pref.species)
var/decl/species/mob_species = get_species_by_key(pref.species)
var/list/valid_facialhairstyles = mob_species.get_facial_hair_styles(pref.gender)

if(valid_facialhairstyles.len)
Expand All @@ -672,7 +672,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
pref.f_style = GLOB.facial_hair_styles_list["Shaved"]

/datum/category_item/player_setup_item/physical/body/proc/sanitize_organs()
var/datum/species/mob_species = get_species_by_key(pref.species)
var/decl/species/mob_species = get_species_by_key(pref.species)
if(mob_species && mob_species.spawn_flags & SPECIES_NO_ROBOTIC_INTERNAL_ORGANS)
for(var/name in pref.organ_data)
var/status = pref.organ_data[name]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
pref.all_underwear[WRC.name] = WRI.name
break

var/datum/species/mob_species = get_species_by_key(pref.species)
var/decl/species/mob_species = get_species_by_key(pref.species)
if(!(mob_species && mob_species.appearance_flags & HAS_UNDERWEAR))
pref.all_underwear.Cut()

Expand Down
4 changes: 2 additions & 2 deletions code/modules/client/preference_setup/laws/laws_pref.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
/datum/category_item/player_setup_item/law_pref/sanitize_character()
if(!istype(pref.laws)) pref.laws = list()

var/datum/species/species = get_species_by_key(pref.species)
var/decl/species/species = get_species_by_key(pref.species)
if(!(species && species.has_organ[BP_POSIBRAIN]))
pref.is_shackled = initial(pref.is_shackled)
else
pref.is_shackled = sanitize_bool(pref.is_shackled, initial(pref.is_shackled))

/datum/category_item/player_setup_item/law_pref/content()
. = list()
var/datum/species/species = get_species_by_key(pref.species)
var/decl/species/species = get_species_by_key(pref.species)

if(!(species && species.has_organ[BP_POSIBRAIN]))
. += "<b>Your Species Has No Laws</b><br>"
Expand Down
8 changes: 4 additions & 4 deletions code/modules/client/preference_setup/occupation/occupation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
if(!SSmapping || !SSjobs.job_lists_by_map_name)
return

var/datum/species/S = preference_species()
var/decl/species/S = preference_species()
. = list()
. += "<style>.Points,a.Points{background: #cc5555;}</style>"
. += "<style>a.Points:hover{background: #55cc55;}</style>"
Expand Down Expand Up @@ -266,7 +266,7 @@
if(LAZYLEN(removing_ranks))
pref.ranks -= removing_ranks

var/datum/species/S = preference_species()
var/decl/species/S = preference_species()
for(var/job_name in SSjobs.titles_to_datums)

var/datum/job/job = SSjobs.get_by_title(job_name)
Expand Down Expand Up @@ -335,7 +335,7 @@
else if(href_list["char_branch"])
var/datum/job/job = locate(href_list["checking_job"])
if(istype(job))
var/datum/species/S = preference_species()
var/decl/species/S = preference_species()
var/list/options = job.allowed_branches ? job.get_branch_rank(S) : mil_branches.spawn_branches(S)
var/choice = input(user, "Choose your branch of service.", CHARACTER_PREFERENCE_INPUT_TITLE) as null|anything in options
if(choice && CanUseTopic(user) && mil_branches.is_spawn_branch(choice, S))
Expand All @@ -350,7 +350,7 @@
var/datum/job/job = locate(href_list["checking_job"])
if(istype(job))
var/datum/mil_branch/branch = mil_branches.get_branch(pref.branches[job.title])
var/datum/species/S = preference_species()
var/decl/species/S = preference_species()
var/list/branch_rank = job.allowed_branches ? job.get_branch_rank(S) : mil_branches.spawn_branches(S)
var/list/options = branch_rank[branch.name] || mil_branches.spawn_ranks(branch.name, S)
var/choice = input(user, "Choose your rank.", CHARACTER_PREFERENCE_INPUT_TITLE) as null|anything in options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
//Sets up skills_allocated
/datum/preferences/proc/sanitize_skills(var/list/input)
. = list()
var/datum/species/S = get_species_by_key(species)
var/decl/species/S = get_species_by_key(species)
for(var/job_name in SSjobs.titles_to_datums)
var/datum/job/job = SSjobs.get_by_title(job_name)
var/input_skills = list()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/masks/miscellaneous.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
/obj/item/clothing/mask/rubber/species/Initialize()
. = ..()
visible_name = species
var/datum/species/S = get_species_by_key(species)
var/decl/species/S = get_species_by_key(species)
if(istype(S))
var/decl/cultural_info/C = SSlore.get_culture(S.default_cultural_info[TAG_CULTURE])
if(istype(C))
Expand Down
Loading