mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 22:50:26 +01:00
Job refactor: strings to references and typepaths (#59841)
* Job refactor: strings to references and typepaths
This commit is contained in:
@@ -827,8 +827,7 @@
|
||||
|
||||
dat += "<table>"
|
||||
|
||||
for(var/j in SSjob.occupations)
|
||||
var/datum/job/job = j
|
||||
for(var/datum/job/job as anything in SSjob.joinable_occupations)
|
||||
count++
|
||||
var/J_title = html_encode(job.title)
|
||||
var/J_opPos = html_encode(job.total_positions - (job.total_positions - job.current_positions))
|
||||
|
||||
@@ -99,7 +99,7 @@ GLOBAL_VAR(antag_prototypes)
|
||||
|
||||
var/out = "<B>[name]</B>[(current && (current.real_name!=name))?" (as [current.real_name])":""]<br>"
|
||||
out += "Mind currently owned by key: [key] [active?"(synced)":"(not synced)"]<br>"
|
||||
out += "Assigned role: [assigned_role]. <a href='?src=[REF(src)];role_edit=1'>Edit</a><br>"
|
||||
out += "Assigned role: [assigned_role.title]. <a href='?src=[REF(src)];role_edit=1'>Edit</a><br>"
|
||||
out += "Faction and special role: <b><font color='red'>[special_role]</font></b><br>"
|
||||
|
||||
var/special_statuses = get_special_statuses()
|
||||
|
||||
@@ -916,7 +916,7 @@
|
||||
|
||||
//Job + antagonist
|
||||
if(M.mind)
|
||||
special_role_description = "Role: <b>[M.mind.assigned_role]</b>; Antagonist: <font color='red'><b>"
|
||||
special_role_description = "Role: <b>[M.mind.assigned_role.title]</b>; Antagonist: <font color='red'><b>"
|
||||
var/i = 0
|
||||
for(var/datum/antagonist/A in M.mind.antag_datums)
|
||||
special_role_description += "[A.name]"
|
||||
@@ -966,7 +966,7 @@
|
||||
|
||||
var/Add = href_list["addjobslot"]
|
||||
|
||||
for(var/datum/job/job in SSjob.occupations)
|
||||
for(var/datum/job/job as anything in SSjob.joinable_occupations)
|
||||
if(job.title == Add)
|
||||
job.total_positions += 1
|
||||
break
|
||||
@@ -980,7 +980,7 @@
|
||||
|
||||
var/Add = href_list["customjobslot"]
|
||||
|
||||
for(var/datum/job/job in SSjob.occupations)
|
||||
for(var/datum/job/job as anything in SSjob.joinable_occupations)
|
||||
if(job.title == Add)
|
||||
var/newtime = null
|
||||
newtime = input(usr, "How many jebs do you want?", "Add wanted posters", "[newtime]") as num|null
|
||||
@@ -998,7 +998,7 @@
|
||||
|
||||
var/Remove = href_list["removejobslot"]
|
||||
|
||||
for(var/datum/job/job in SSjob.occupations)
|
||||
for(var/datum/job/job as anything in SSjob.joinable_occupations)
|
||||
if(job.title == Remove && job.total_positions - job.current_positions > 0)
|
||||
job.total_positions -= 1
|
||||
break
|
||||
@@ -1011,7 +1011,7 @@
|
||||
|
||||
var/Unlimit = href_list["unlimitjobslot"]
|
||||
|
||||
for(var/datum/job/job in SSjob.occupations)
|
||||
for(var/datum/job/job as anything in SSjob.joinable_occupations)
|
||||
if(job.title == Unlimit)
|
||||
job.total_positions = -1
|
||||
break
|
||||
@@ -1024,7 +1024,7 @@
|
||||
|
||||
var/Limit = href_list["limitjobslot"]
|
||||
|
||||
for(var/datum/job/job in SSjob.occupations)
|
||||
for(var/datum/job/job as anything in SSjob.joinable_occupations)
|
||||
if(job.title == Limit)
|
||||
job.total_positions = job.current_positions
|
||||
break
|
||||
|
||||
@@ -16,7 +16,7 @@ GLOBAL_DATUM(triple_ai_controller, /datum/triple_ai_controller)
|
||||
/datum/triple_ai_controller/proc/on_occupations_divided(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
for(var/datum/job/ai/ai_datum in SSjob.occupations)
|
||||
for(var/datum/job/ai/ai_datum in SSjob.joinable_occupations)
|
||||
ai_datum.spawn_positions = 3
|
||||
for(var/obj/effect/landmark/start/ai/secondary/secondary_ai_spawn in GLOB.start_landmarks_list)
|
||||
secondary_ai_spawn.latejoin_active = TRUE
|
||||
@@ -35,10 +35,10 @@ GLOBAL_DATUM(triple_ai_controller, /datum/triple_ai_controller)
|
||||
to_chat(usr, "This option is currently only usable during pregame. This may change at a later date.", confidential = TRUE)
|
||||
return
|
||||
|
||||
var/datum/job/job = SSjob.GetJob("AI")
|
||||
var/datum/job/job = SSjob.GetJobType(/datum/job/ai)
|
||||
if(!job)
|
||||
to_chat(usr, "Unable to locate the AI job", confidential = TRUE)
|
||||
return
|
||||
CRASH("triple_ai() called, no /datum/job/ai to be found.")
|
||||
|
||||
if(!GLOB.triple_ai_controller)
|
||||
GLOB.triple_ai_controller = new()
|
||||
|
||||
@@ -88,7 +88,7 @@ GLOBAL_DATUM(current_anonymous_theme, /datum/anonymous_theme)
|
||||
/datum/anonymous_theme/proc/anonymous_all_players()
|
||||
var/datum/anonymous_theme/theme = GLOB.current_anonymous_theme
|
||||
for(var/mob/living/player in GLOB.player_list)
|
||||
if(!player.mind || (!ishuman(player) && !issilicon(player)) || !SSjob.GetJob(player.mind.assigned_role))
|
||||
if(!player.mind || (!ishuman(player) && !issilicon(player)) || player.mind.assigned_role.faction != FACTION_STATION)
|
||||
continue
|
||||
if(issilicon(player))
|
||||
player.fully_replace_character_name(player.real_name, theme.anonymous_ai_name(isAI(player)))
|
||||
@@ -109,13 +109,14 @@ GLOBAL_DATUM(current_anonymous_theme, /datum/anonymous_theme)
|
||||
/datum/anonymous_theme/proc/restore_all_players()
|
||||
priority_announce("Names and Identities have been restored.", "Identity Restoration", SSstation.announcer.get_rand_alert_sound())
|
||||
for(var/mob/living/player in GLOB.player_list)
|
||||
if(!player.mind || (!ishuman(player) && !issilicon(player)) || !SSjob.GetJob(player.mind.assigned_role))
|
||||
if(!player.mind || (!ishuman(player) && !issilicon(player)) || player.mind.assigned_role.faction != FACTION_STATION)
|
||||
continue
|
||||
var/old_name = player.real_name //before restoration
|
||||
if(issilicon(player))
|
||||
player.apply_pref_name("[isAI(player) ? "ai" : "cyborg"]", player.client)
|
||||
else
|
||||
player.client.prefs.copy_to(player, antagonist = (LAZYLEN(player.mind.antag_datums) > 0), is_latejoiner = FALSE)
|
||||
player.client.prefs.sanitize_chosen_prefs() // Just in case they changed unlawfully.
|
||||
player.client.prefs.apply_prefs_to(player) // This is not sound logic, as the prefs may have changed since then.
|
||||
player.fully_replace_character_name(old_name, player.real_name) //this changes IDs and PDAs and whatnot
|
||||
|
||||
/**
|
||||
@@ -153,7 +154,7 @@ GLOBAL_DATUM(current_anonymous_theme, /datum/anonymous_theme)
|
||||
priority_announce("As punishment for this station's poor productivity when compared to neighbor stations, names and identities will be restricted until further notice.", "Finance Report", SSstation.announcer.get_rand_alert_sound())
|
||||
|
||||
/datum/anonymous_theme/employees/anonymous_name(mob/target)
|
||||
var/is_head_of_staff = (target.mind.assigned_role in GLOB.command_positions)
|
||||
var/is_head_of_staff = target.mind.assigned_role.departments & DEPARTMENT_COMMAND
|
||||
var/name = "[is_head_of_staff ? "Manager" : "Employee"] "
|
||||
for(var/i in 1 to 6)
|
||||
if(prob(30) || i == 1)
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
if(isobserver(usr))
|
||||
var/mob/living/carbon/human/admin_officer = new (spawnpoints[1])
|
||||
var/chosen_outfit = usr.client?.prefs?.brief_outfit
|
||||
usr.client.prefs.copy_to(admin_officer)
|
||||
usr.client.prefs.safe_transfer_prefs_to(admin_officer, is_antag = TRUE)
|
||||
admin_officer.equipOutfit(chosen_outfit)
|
||||
admin_officer.key = usr.key
|
||||
else
|
||||
@@ -175,7 +175,7 @@
|
||||
|
||||
//Spawn the body
|
||||
var/mob/living/carbon/human/ert_operative = new ertemplate.mobtype(spawnloc)
|
||||
chosen_candidate.client.prefs.copy_to(ert_operative)
|
||||
chosen_candidate.client.prefs.safe_transfer_prefs_to(ert_operative, is_antag = TRUE)
|
||||
ert_operative.key = chosen_candidate.key
|
||||
|
||||
if(ertemplate.enforce_human || !(ert_operative.dna.species.changesource_flags & ERT_SPAWN)) // Don't want any exploding plasmemes
|
||||
@@ -194,7 +194,7 @@
|
||||
ert_antag.random_names = ertemplate.random_names
|
||||
|
||||
ert_operative.mind.add_antag_datum(ert_antag,ert_team)
|
||||
ert_operative.mind.assigned_role = ert_antag.name
|
||||
ert_operative.mind.set_assigned_role(SSjob.GetJobType(ert_antag.ert_job_path))
|
||||
|
||||
//Logging and cleanup
|
||||
log_game("[key_name(ert_operative)] has been selected as an [ert_antag.name]")
|
||||
|
||||
@@ -305,7 +305,7 @@ GLOBAL_VAR_INIT(say_disabled, FALSE)
|
||||
for(var/obj/item/I in D)
|
||||
qdel(I)
|
||||
randomize_human(D)
|
||||
JB.equip(D, TRUE, FALSE)
|
||||
D.dress_up_as_job(JB, TRUE)
|
||||
COMPILE_OVERLAYS(D)
|
||||
var/icon/I = icon(getFlatIcon(D), frame = 1)
|
||||
final.Insert(I, JB.title)
|
||||
|
||||
@@ -235,54 +235,6 @@
|
||||
SSblackbox.record_feedback("nested tally", "admin_toggle", 1, list("Mute [feedback_string]", "[P.muted & mute_type]")) //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
|
||||
|
||||
//I use this proc for respawn character too. /N
|
||||
/proc/create_xeno(ckey)
|
||||
if(!ckey)
|
||||
var/list/candidates = list()
|
||||
for(var/mob/M in GLOB.player_list)
|
||||
if(M.stat != DEAD)
|
||||
continue //we are not dead!
|
||||
if(!(ROLE_ALIEN in M.client.prefs.be_special))
|
||||
continue //we don't want to be an alium
|
||||
if(M.client.is_afk())
|
||||
continue //we are afk
|
||||
if(M.mind && M.mind.current && M.mind.current.stat != DEAD)
|
||||
continue //we have a live body we are tied to
|
||||
candidates += M.ckey
|
||||
if(candidates.len)
|
||||
ckey = input("Pick the player you want to respawn as a xeno.", "Suitable Candidates") as null|anything in sortKey(candidates)
|
||||
else
|
||||
to_chat(usr, span_danger("Error: create_xeno(): no suitable candidates."), confidential = TRUE)
|
||||
if(!istext(ckey))
|
||||
return FALSE
|
||||
|
||||
var/alien_caste = input(usr, "Please choose which caste to spawn.","Pick a caste",null) as null|anything in list("Queen","Praetorian","Hunter","Sentinel","Drone","Larva")
|
||||
var/obj/effect/landmark/spawn_here = GLOB.xeno_spawn.len ? pick(GLOB.xeno_spawn) : null
|
||||
var/mob/living/carbon/alien/new_xeno
|
||||
switch(alien_caste)
|
||||
if("Queen")
|
||||
new_xeno = new /mob/living/carbon/alien/humanoid/royal/queen(spawn_here)
|
||||
if("Praetorian")
|
||||
new_xeno = new /mob/living/carbon/alien/humanoid/royal/praetorian(spawn_here)
|
||||
if("Hunter")
|
||||
new_xeno = new /mob/living/carbon/alien/humanoid/hunter(spawn_here)
|
||||
if("Sentinel")
|
||||
new_xeno = new /mob/living/carbon/alien/humanoid/sentinel(spawn_here)
|
||||
if("Drone")
|
||||
new_xeno = new /mob/living/carbon/alien/humanoid/drone(spawn_here)
|
||||
if("Larva")
|
||||
new_xeno = new /mob/living/carbon/alien/larva(spawn_here)
|
||||
else
|
||||
return FALSE
|
||||
if(!spawn_here)
|
||||
SSjob.SendToLateJoin(new_xeno, FALSE)
|
||||
|
||||
new_xeno.ckey = ckey
|
||||
var/msg = span_notice("[key_name_admin(usr)] has spawned [ckey] as a filthy xeno [alien_caste].")
|
||||
message_admins(msg)
|
||||
admin_ticket_log(new_xeno, msg)
|
||||
return TRUE
|
||||
|
||||
/*
|
||||
If a guy was gibbed and you want to revive him, this is a good way to do so.
|
||||
Works kind of like entering the game with a new character. Character receives a new mind if they didn't have one.
|
||||
@@ -310,43 +262,8 @@ Traitors and the like can also be revived with the previous role mostly intact.
|
||||
return
|
||||
|
||||
if(G_found.mind && !G_found.mind.active) //mind isn't currently in use by someone/something
|
||||
//Check if they were an alien
|
||||
if(G_found.mind.assigned_role == ROLE_ALIEN)
|
||||
if(tgui_alert(usr,"This character appears to have been an alien. Would you like to respawn them as such?",,list("Yes","No"))=="Yes")
|
||||
var/turf/T
|
||||
if(GLOB.xeno_spawn.len)
|
||||
T = pick(GLOB.xeno_spawn)
|
||||
|
||||
var/mob/living/carbon/alien/new_xeno
|
||||
switch(G_found.mind.special_role)//If they have a mind, we can determine which caste they were.
|
||||
if("Hunter")
|
||||
new_xeno = new /mob/living/carbon/alien/humanoid/hunter(T)
|
||||
if("Sentinel")
|
||||
new_xeno = new /mob/living/carbon/alien/humanoid/sentinel(T)
|
||||
if("Drone")
|
||||
new_xeno = new /mob/living/carbon/alien/humanoid/drone(T)
|
||||
if("Praetorian")
|
||||
new_xeno = new /mob/living/carbon/alien/humanoid/royal/praetorian(T)
|
||||
if("Queen")
|
||||
new_xeno = new /mob/living/carbon/alien/humanoid/royal/queen(T)
|
||||
else//If we don't know what special role they have, for whatever reason, or they're a larva.
|
||||
create_xeno(G_found.ckey)
|
||||
return
|
||||
|
||||
if(!T)
|
||||
SSjob.SendToLateJoin(new_xeno, FALSE)
|
||||
|
||||
//Now to give them their mind back.
|
||||
G_found.mind.transfer_to(new_xeno) //be careful when doing stuff like this! I've already checked the mind isn't in use
|
||||
new_xeno.key = G_found.key
|
||||
to_chat(new_xeno, "You have been fully respawned. Enjoy the game.", confidential = TRUE)
|
||||
var/msg = span_adminnotice("[key_name_admin(usr)] has respawned [new_xeno.key] as a filthy xeno.")
|
||||
message_admins(msg)
|
||||
admin_ticket_log(new_xeno, msg)
|
||||
return //all done. The ghost is auto-deleted
|
||||
|
||||
//check if they were a monkey
|
||||
else if(findtext(G_found.real_name,"monkey"))
|
||||
if(findtext(G_found.real_name,"monkey"))
|
||||
if(tgui_alert(usr,"This character appears to have been a monkey. Would you like to respawn them as such?",,list("Yes","No"))=="Yes")
|
||||
var/mob/living/carbon/human/species/monkey/new_monkey = new
|
||||
SSjob.SendToLateJoin(new_monkey)
|
||||
@@ -359,7 +276,7 @@ Traitors and the like can also be revived with the previous role mostly intact.
|
||||
return //all done. The ghost is auto-deleted
|
||||
|
||||
|
||||
//Ok, it's not a xeno or a monkey. So, spawn a human.
|
||||
//Ok, it's not a monkey. So, spawn a human.
|
||||
var/mob/living/carbon/human/new_character = new//The mob being spawned.
|
||||
SSjob.SendToLateJoin(new_character)
|
||||
|
||||
@@ -367,7 +284,7 @@ Traitors and the like can also be revived with the previous role mostly intact.
|
||||
if(G_found.mind && !G_found.mind.active) //mind isn't currently in use by someone/something
|
||||
/*Try and locate a record for the person being respawned through GLOB.data_core.
|
||||
This isn't an exact science but it does the trick more often than not.*/
|
||||
var/id = md5("[G_found.real_name][G_found.mind.assigned_role]")
|
||||
var/id = md5("[G_found.real_name][G_found.mind.assigned_role.title]")
|
||||
|
||||
record_found = find_record("id", id, GLOB.data_core.locked)
|
||||
|
||||
@@ -377,9 +294,7 @@ Traitors and the like can also be revived with the previous role mostly intact.
|
||||
new_character.age = record_found.fields["age"]
|
||||
new_character.hardset_dna(record_found.fields["identity"], record_found.fields["enzymes"], null, record_found.fields["name"], record_found.fields["blood_type"], new record_found.fields["species"], record_found.fields["features"])
|
||||
else
|
||||
var/datum/preferences/A = new()
|
||||
A.copy_to(new_character)
|
||||
A.real_name = G_found.real_name
|
||||
new_character.randomize_human_appearance()
|
||||
new_character.dna.update_dna_identity()
|
||||
|
||||
new_character.name = new_character.real_name
|
||||
@@ -388,8 +303,8 @@ Traitors and the like can also be revived with the previous role mostly intact.
|
||||
G_found.mind.transfer_to(new_character) //be careful when doing stuff like this! I've already checked the mind isn't in use
|
||||
else
|
||||
new_character.mind_initialize()
|
||||
if(!new_character.mind.assigned_role)
|
||||
new_character.mind.assigned_role = "Assistant"//If they somehow got a null assigned role.
|
||||
if(is_unassigned_job(new_character.mind.assigned_role))
|
||||
new_character.mind.set_assigned_role(SSjob.GetJobType(SSjob.overflow_role))
|
||||
|
||||
new_character.key = G_found.key
|
||||
|
||||
@@ -406,10 +321,9 @@ Traitors and the like can also be revived with the previous role mostly intact.
|
||||
//Now for special roles and equipment.
|
||||
var/datum/antagonist/traitor/traitordatum = new_character.mind.has_antag_datum(/datum/antagonist/traitor)
|
||||
if(traitordatum)
|
||||
SSjob.EquipRank(new_character, new_character.mind.assigned_role, 1)
|
||||
SSjob.EquipRank(new_character, new_character.mind.assigned_role, new_character.client)
|
||||
traitordatum.equip()
|
||||
|
||||
|
||||
switch(new_character.mind.special_role)
|
||||
if(ROLE_WIZARD)
|
||||
new_character.forceMove(pick(GLOB.wizardstart))
|
||||
@@ -429,23 +343,23 @@ Traitors and the like can also be revived with the previous role mostly intact.
|
||||
new_character.forceMove(pick(ninja_spawn))
|
||||
|
||||
else//They may also be a cyborg or AI.
|
||||
switch(new_character.mind.assigned_role)
|
||||
if("Cyborg")//More rigging to make em' work and check if they're traitor.
|
||||
switch(new_character.mind.assigned_role.type)
|
||||
if(/datum/job/cyborg)//More rigging to make em' work and check if they're traitor.
|
||||
new_character = new_character.Robotize(TRUE)
|
||||
if("AI")
|
||||
if(/datum/job/ai)
|
||||
new_character = new_character.AIize()
|
||||
else
|
||||
SSjob.EquipRank(new_character, new_character.mind.assigned_role, 1)//Or we simply equip them.
|
||||
if(!traitordatum) // Already equipped there.
|
||||
SSjob.EquipRank(new_character, new_character.mind.assigned_role, new_character.client)//Or we simply equip them.
|
||||
|
||||
//Announces the character on all the systems, based on the record.
|
||||
if(!issilicon(new_character))//If they are not a cyborg/AI.
|
||||
if(!record_found&&new_character.mind.assigned_role!=new_character.mind.special_role)//If there are no records for them. If they have a record, this info is already in there. MODE people are not announced anyway.
|
||||
//Power to the user!
|
||||
if(tgui_alert(new_character,"Warning: No data core entry detected. Would you like to announce the arrival of this character by adding them to various databases, such as medical records?",,list("No","Yes"))=="Yes")
|
||||
GLOB.data_core.manifest_inject(new_character)
|
||||
if(!record_found && (new_character.mind.assigned_role.job_flags & JOB_CREW_MEMBER))
|
||||
//Power to the user!
|
||||
if(tgui_alert(new_character,"Warning: No data core entry detected. Would you like to announce the arrival of this character by adding them to various databases, such as medical records?",,list("No","Yes"))=="Yes")
|
||||
GLOB.data_core.manifest_inject(new_character)
|
||||
|
||||
if(tgui_alert(new_character,"Would you like an active AI to announce this character?",,list("No","Yes"))=="Yes")
|
||||
AnnounceArrival(new_character, new_character.mind.assigned_role)
|
||||
if(tgui_alert(new_character,"Would you like an active AI to announce this character?",,list("No","Yes"))=="Yes")
|
||||
AnnounceArrival(new_character, new_character.mind.assigned_role.title)
|
||||
|
||||
var/msg = span_adminnotice("[admin] has respawned [player_key] as [new_character.real_name].")
|
||||
message_admins(msg)
|
||||
|
||||
@@ -86,11 +86,9 @@
|
||||
if("infinite_sec")
|
||||
if(!is_debugger)
|
||||
return
|
||||
var/datum/job/J = SSjob.GetJob("Security Officer")
|
||||
if(!J)
|
||||
return
|
||||
J.total_positions = -1
|
||||
J.spawn_positions = -1
|
||||
var/datum/job/sec_job = SSjob.GetJobType(/datum/job/security_officer)
|
||||
sec_job.total_positions = -1
|
||||
sec_job.spawn_positions = -1
|
||||
message_admins("[key_name_admin(holder)] has removed the cap on security officers.")
|
||||
//Buttons for helpful stuff. This is where people land in the tgui
|
||||
if("clear_virus")
|
||||
@@ -607,7 +605,7 @@
|
||||
if (length(players))
|
||||
var/mob/chosen = players[1]
|
||||
if (chosen.client)
|
||||
chosen.client.prefs.copy_to(spawnedMob)
|
||||
chosen.client.prefs.safe_transfer_prefs_to(spawnedMob, is_antag = TRUE)
|
||||
spawnedMob.key = chosen.key
|
||||
players -= chosen
|
||||
if (ishuman(spawnedMob) && ispath(humanoutfit, /datum/outfit))
|
||||
|
||||
Reference in New Issue
Block a user