Refactors the latejoin list

This commit is contained in:
CitadelStationBot
2017-06-04 15:08:35 -05:00
parent 94405f5176
commit e8663bee81
15 changed files with 86 additions and 58 deletions

View File

@@ -131,9 +131,12 @@
return return
//Removes any null entries from the list //Removes any null entries from the list
//Returns TRUE if the list had nulls, FALSE otherwise
/proc/listclearnulls(list/L) /proc/listclearnulls(list/L)
var/list/N = new(L.len) var/start_len = L.len
var/list/N = new(start_len)
L -= N L -= N
return L.len < start_len
/* /*
* Returns list containing all the entries from first list that are not present in second. * Returns list containing all the entries from first list that are not present in second.

View File

@@ -507,7 +507,8 @@
return return
//First we spawn a dude. //First we spawn a dude.
var/mob/living/carbon/human/new_character = new(pick(GLOB.latejoin))//The mob being spawned. var/mob/living/carbon/human/new_character = new//The mob being spawned.
SSjob.SendToLateJoin(new_character)
G_found.client.prefs.copy_to(new_character) G_found.client.prefs.copy_to(new_character)
new_character.dna.update_dna_identity() new_character.dna.update_dna_identity()

View File

@@ -32,7 +32,6 @@ GLOBAL_LIST_EMPTY(generic_event_spawns) //list of all spawns for events
GLOBAL_LIST_EMPTY(wizardstart) GLOBAL_LIST_EMPTY(wizardstart)
GLOBAL_LIST_EMPTY(newplayer_start) GLOBAL_LIST_EMPTY(newplayer_start)
GLOBAL_LIST_EMPTY(latejoin)
GLOBAL_LIST_EMPTY(prisonwarp) //prisoners go to these GLOBAL_LIST_EMPTY(prisonwarp) //prisoners go to these
GLOBAL_LIST_EMPTY(holdingfacility) //captured people go here GLOBAL_LIST_EMPTY(holdingfacility) //captured people go here
GLOBAL_LIST_EMPTY(xeno_spawn)//Aliens spawn at these. GLOBAL_LIST_EMPTY(xeno_spawn)//Aliens spawn at these.

View File

@@ -11,6 +11,7 @@ SUBSYSTEM_DEF(job)
var/initial_players_to_assign = 0 //used for checking against population caps var/initial_players_to_assign = 0 //used for checking against population caps
var/list/prioritized_jobs = list() var/list/prioritized_jobs = list()
var/list/latejoin_trackers = list() //Don't read this list, use GetLateJoinTurfs() instead
/datum/controller/subsystem/job/Initialize(timeofday) /datum/controller/subsystem/job/Initialize(timeofday)
if(!occupations.len) if(!occupations.len)
@@ -380,21 +381,7 @@ SUBSYSTEM_DEF(job)
break break
if(!S) //if there isn't a spawnpoint send them to latejoin, if there's no latejoin go yell at your mapper if(!S) //if there isn't a spawnpoint send them to latejoin, if there's no latejoin go yell at your mapper
log_world("Couldn't find a round start spawn point for [rank]") log_world("Couldn't find a round start spawn point for [rank]")
S = get_turf(pick(GLOB.latejoin)) SendToLateJoin(H)
if(!S) //final attempt, lets find some area in the arrivals shuttle to spawn them in to.
log_world("Couldn't find a round start latejoin spawn point.")
for(var/turf/T in get_area_turfs(/area/shuttle/arrival))
if(!T.density)
var/clear = 1
for(var/obj/O in T)
if(O.density)
clear = 0
break
if(clear)
S = T
continue
if(istype(S, /obj/effect/landmark) && isturf(S.loc))
H.loc = S.loc
if(H.mind) if(H.mind)
H.mind.assigned_role = rank H.mind.assigned_role = rank
@@ -516,3 +503,45 @@ SUBSYSTEM_DEF(job)
newjob.total_positions = J.total_positions newjob.total_positions = J.total_positions
newjob.spawn_positions = J.spawn_positions newjob.spawn_positions = J.spawn_positions
newjob.current_positions = J.current_positions newjob.current_positions = J.current_positions
/datum/controller/subsystem/job/proc/SendToAtom(mob/M, atom/A, buckle)
if(buckle && isliving(M) && istype(A, /obj/structure/chair))
var/obj/structure/chair/C = A
if(C.buckle_mob(M, FALSE, FALSE))
return
M.forceMove(get_turf(A))
/datum/controller/subsystem/job/proc/SendToLateJoin(mob/M, buckle = TRUE)
if(latejoin_trackers.len)
SendToAtom(M, pick(latejoin_trackers), buckle)
else
//bad mojo
var/area/shuttle/arrival/A = locate() in GLOB.sortedAreas
if(A)
//first check if we can find a chair
var/obj/structure/chair/C = locate() in A
if(C)
SendToAtom(M, C, buckle)
return
else //last hurrah
var/list/avail = list()
for(var/turf/T in A)
if(!is_blocked_turf(T, TRUE))
avail += T
if(avail.len)
SendToAtom(M, pick(avail), FALSE)
return
//pick an open spot on arrivals and dump em
var/list/arrivals_turfs = shuffle(get_area_turfs(/area/shuttle/arrival))
if(arrivals_turfs.len)
for(var/turf/T in arrivals_turfs)
if(!is_blocked_turf(T, TRUE))
SendToAtom(M, T, FALSE)
return
//last chance, pick ANY spot on arrivals and dump em
SendToAtom(M, arrivals_turfs[1], FALSE)
else
var/msg = "Unable to send mob [M] to late join!"
message_admins(msg)
CRASH(msg)

View File

@@ -1447,7 +1447,7 @@
special_role = "Wizard" special_role = "Wizard"
assigned_role = "Wizard" assigned_role = "Wizard"
if(!GLOB.wizardstart.len) if(!GLOB.wizardstart.len)
current.loc = pick(GLOB.latejoin) SSjob.SendToLateJoin(current)
to_chat(current, "HOT INSERTION, GO GO GO") to_chat(current, "HOT INSERTION, GO GO GO")
else else
current.loc = pick(GLOB.wizardstart) current.loc = pick(GLOB.wizardstart)

View File

@@ -212,13 +212,12 @@
/obj/machinery/abductor/experiment/proc/SendBack(mob/living/carbon/human/H) /obj/machinery/abductor/experiment/proc/SendBack(mob/living/carbon/human/H)
H.Sleeping(8) H.Sleeping(8)
H.uncuff()
if(console && console.pad && console.pad.teleport_target) if(console && console.pad && console.pad.teleport_target)
H.forceMove(console.pad.teleport_target) H.forceMove(console.pad.teleport_target)
H.uncuff()
return return
//Area not chosen / It's not safe area - teleport to arrivals //Area not chosen / It's not safe area - teleport to arrivals
H.forceMove(pick(GLOB.latejoin)) SSjob.SendToLateJoin(H, FALSE)
H.uncuff()
return return

View File

@@ -142,7 +142,8 @@
return return
//First we spawn a dude. //First we spawn a dude.
var/mob/living/carbon/human/new_character = new(pick(GLOB.latejoin))//The mob being spawned. var/mob/living/carbon/human/new_character = new//The mob being spawned.
SSjob.SendToLateJoin(new_character)
G_found.client.prefs.copy_to(new_character) G_found.client.prefs.copy_to(new_character)
new_character.dna.update_dna_identity() new_character.dna.update_dna_identity()

View File

@@ -182,7 +182,7 @@
/obj/effect/landmark/latejoin/Initialize(mapload) /obj/effect/landmark/latejoin/Initialize(mapload)
..() ..()
GLOB.latejoin += loc SSjob.latejoin_trackers += loc
qdel(src) qdel(src)
// carp. // carp.

View File

@@ -25,7 +25,7 @@
return ..() return ..()
/obj/structure/chair/proc/RemoveFromLatejoin() /obj/structure/chair/proc/RemoveFromLatejoin()
GLOB.latejoin -= src //These may be here due to the arrivals shuttle SSjob.latejoin_trackers -= src //These may be here due to the arrivals shuttle
/obj/structure/chair/deconstruct() /obj/structure/chair/deconstruct()
// If we have materials, and don't have the NOCONSTRUCT flag // If we have materials, and don't have the NOCONSTRUCT flag

View File

@@ -590,7 +590,7 @@
set category = "Admin" set category = "Admin"
set name = "Unprison" set name = "Unprison"
if (M.z == ZLEVEL_CENTCOM) if (M.z == ZLEVEL_CENTCOM)
M.loc = pick(GLOB.latejoin) SSjob.SendToLateJoin(M)
message_admins("[key_name_admin(usr)] has unprisoned [key_name_admin(M)]") message_admins("[key_name_admin(usr)] has unprisoned [key_name_admin(M)]")
log_admin("[key_name(usr)] has unprisoned [key_name(M)]") log_admin("[key_name(usr)] has unprisoned [key_name(M)]")
else else

View File

@@ -227,7 +227,7 @@
return 0 return 0
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/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) : pick(GLOB.latejoin) var/obj/effect/landmark/spawn_here = GLOB.xeno_spawn.len ? pick(GLOB.xeno_spawn) : null
var/mob/living/carbon/alien/new_xeno var/mob/living/carbon/alien/new_xeno
switch(alien_caste) switch(alien_caste)
if("Queen") if("Queen")
@@ -244,6 +244,8 @@
new_xeno = new /mob/living/carbon/alien/larva(spawn_here) new_xeno = new /mob/living/carbon/alien/larva(spawn_here)
else else
return 0 return 0
if(!spawn_here)
SSjob.SendToLateJoin(new_xeno, FALSE)
new_xeno.ckey = ckey new_xeno.ckey = ckey
var/msg = "<span class='notice'>[key_name_admin(usr)] has spawned [ckey] as a filthy xeno [alien_caste].</span>" var/msg = "<span class='notice'>[key_name_admin(usr)] has spawned [ckey] as a filthy xeno [alien_caste].</span>"
@@ -284,8 +286,6 @@ Traitors and the like can also be revived with the previous role mostly intact.
var/turf/T var/turf/T
if(GLOB.xeno_spawn.len) if(GLOB.xeno_spawn.len)
T = pick(GLOB.xeno_spawn) T = pick(GLOB.xeno_spawn)
else
T = pick(GLOB.latejoin)
var/mob/living/carbon/alien/new_xeno 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. switch(G_found.mind.special_role)//If they have a mind, we can determine which caste they were.
@@ -302,6 +302,9 @@ Traitors and the like can also be revived with the previous role mostly intact.
else//If we don't know what special role they have, for whatever reason, or they're a larva. else//If we don't know what special role they have, for whatever reason, or they're a larva.
create_xeno(G_found.ckey) create_xeno(G_found.ckey)
return return
if(!T)
SSjob.SendToLateJoin(new_xeno, FALSE)
//Now to give them their mind back. //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 G_found.mind.transfer_to(new_xeno) //be careful when doing stuff like this! I've already checked the mind isn't in use
@@ -315,7 +318,8 @@ Traitors and the like can also be revived with the previous role mostly intact.
//check if they were a monkey //check if they were a monkey
else if(findtext(G_found.real_name,"monkey")) else if(findtext(G_found.real_name,"monkey"))
if(alert("This character appears to have been a monkey. Would you like to respawn them as such?",,"Yes","No")=="Yes") if(alert("This character appears to have been a monkey. Would you like to respawn them as such?",,"Yes","No")=="Yes")
var/mob/living/carbon/monkey/new_monkey = new(pick(GLOB.latejoin)) var/mob/living/carbon/monkey/new_monkey = new
SSjob.SendToLateJoin(new_monkey)
G_found.mind.transfer_to(new_monkey) //be careful when doing stuff like this! I've already checked the mind isn't in use G_found.mind.transfer_to(new_monkey) //be careful when doing stuff like this! I've already checked the mind isn't in use
new_monkey.key = G_found.key new_monkey.key = G_found.key
to_chat(new_monkey, "You have been fully respawned. Enjoy the game.") to_chat(new_monkey, "You have been fully respawned. Enjoy the game.")
@@ -326,7 +330,8 @@ Traitors and the like can also be revived with the previous role mostly intact.
//Ok, it's not a xeno or a monkey. So, spawn a human. //Ok, it's not a xeno or a monkey. So, spawn a human.
var/mob/living/carbon/human/new_character = new(pick(GLOB.latejoin))//The mob being spawned. var/mob/living/carbon/human/new_character = new//The mob being spawned.
SSjob.SendToLateJoin(new_character)
var/datum/data/record/record_found //Referenced to later to either randomize or not randomize the character. var/datum/data/record/record_found //Referenced to later to either randomize or not randomize the character.
if(G_found.mind && !G_found.mind.active) //mind isn't currently in use by someone/something if(G_found.mind && !G_found.mind.active) //mind isn't currently in use by someone/something

View File

@@ -14,9 +14,7 @@
/datum/round_event/ghost_role/devil/spawn_role() /datum/round_event/ghost_role/devil/spawn_role()
//selecting a spawn_loc //selecting a spawn_loc
var/list/spawn_locs = GLOB.latejoin if(!SSjob.latejoin_trackers.len)
var/spawn_loc = pick(spawn_locs)
if(!spawn_loc)
return MAP_ERROR return MAP_ERROR
//selecting a candidate player //selecting a candidate player
@@ -45,6 +43,8 @@
/proc/create_event_devil(spawn_loc) /proc/create_event_devil(spawn_loc)
var/mob/living/carbon/human/new_devil = new(spawn_loc) var/mob/living/carbon/human/new_devil = new(spawn_loc)
if(!spawn_loc)
SSjob.SendToLateJoin(new_devil)
var/datum/preferences/A = new() //Randomize appearance for the devil. var/datum/preferences/A = new() //Randomize appearance for the devil.
A.copy_to(new_devil) A.copy_to(new_devil)
new_devil.dna.update_dna_identity() new_devil.dna.update_dna_identity()

View File

@@ -0,0 +1,10 @@
diff a/code/modules/events/devil.dm b/code/modules/events/devil.dm (rejected hunks)
@@ -30,7 +28,7 @@
var/datum/mind/Mind = create_devil_mind(key)
Mind.active = 1
- var/mob/living/carbon/human/devil = create_event_devil(spawn_loc)
+ var/mob/living/carbon/human/devil = create_event_devil()
Mind.transfer_to(devil)
SSticker.mode.finalize_devil(Mind, FALSE)
SSticker.mode.add_devil_objectives(src, 2)

View File

@@ -322,28 +322,9 @@
if(isliving(equip)) //Borgs get borged in the equip, so we need to make sure we handle the new mob. if(isliving(equip)) //Borgs get borged in the equip, so we need to make sure we handle the new mob.
character = equip character = equip
var/D SSjob.SendToLateJoin(character)
if(GLOB.latejoin.len)
D = get_turf(pick(GLOB.latejoin))
if(!D)
for(var/turf/T in get_area_turfs(/area/shuttle/arrival))
if(!T.density)
var/clear = 1
for(var/obj/O in T)
if(O.density)
clear = 0
break
if(clear)
D = T
continue
character.loc = D
character.update_parallax_teleport() character.update_parallax_teleport()
var/atom/movable/chair = locate(/obj/structure/chair) in character.loc
if(chair)
chair.buckle_mob(character)
SSticker.minds += character.mind SSticker.minds += character.mind
var/mob/living/carbon/human/humanc var/mob/living/carbon/human/humanc

View File

@@ -48,16 +48,16 @@
console = locate(/obj/machinery/requests_console) in A console = locate(/obj/machinery/requests_console) in A
areas += A areas += A
if(GLOB.latejoin.len) if(SSjob.latejoin_trackers.len)
WARNING("Map contains predefined latejoin spawn points and an arrivals shuttle. Using the arrivals shuttle.") WARNING("Map contains predefined latejoin spawn points and an arrivals shuttle. Using the arrivals shuttle.")
if(!new_latejoin.len) if(!new_latejoin.len)
WARNING("Arrivals shuttle contains no chairs for spawn points. Reverting to latejoin landmarks.") WARNING("Arrivals shuttle contains no chairs for spawn points. Reverting to latejoin landmarks.")
if(!GLOB.latejoin.len) if(!SSjob.latejoin_trackers.len)
WARNING("No latejoin landmarks exist. Players will spawn unbuckled on the shuttle.") WARNING("No latejoin landmarks exist. Players will spawn unbuckled on the shuttle.")
return return
GLOB.latejoin = new_latejoin SSjob.latejoin_trackers = new_latejoin
/obj/docking_port/mobile/arrivals/dockRoundstart() /obj/docking_port/mobile/arrivals/dockRoundstart()
SSshuttle.generate_transit_dock(src) SSshuttle.generate_transit_dock(src)
@@ -114,7 +114,7 @@
Launch(FALSE) Launch(FALSE)
/obj/docking_port/mobile/arrivals/proc/CheckTurfsPressure() /obj/docking_port/mobile/arrivals/proc/CheckTurfsPressure()
for(var/I in GLOB.latejoin) for(var/I in SSjob.latejoin_trackers)
var/turf/open/T = get_turf(I) var/turf/open/T = get_turf(I)
var/pressure = T.air.return_pressure() var/pressure = T.air.return_pressure()
if(pressure < HAZARD_LOW_PRESSURE || pressure > HAZARD_HIGH_PRESSURE) //simple safety check if(pressure < HAZARD_LOW_PRESSURE || pressure > HAZARD_HIGH_PRESSURE) //simple safety check