Fix loadout item duplication on spawn (#13811)

This commit is contained in:
Wildkins
2022-05-06 19:04:51 -04:00
committed by GitHub
parent 12126b16cf
commit d2db90d9c4
4 changed files with 24 additions and 116 deletions

View File

@@ -305,7 +305,7 @@
unassigned -= player
return TRUE
/datum/controller/subsystem/jobs/proc/EquipRank(mob/living/carbon/human/H, rank, joined_late = FALSE)
/datum/controller/subsystem/jobs/proc/EquipRank(mob/living/carbon/human/H, rank, joined_late = FALSE, spawning_at)
if(!H)
return null
@@ -314,6 +314,10 @@
if(SSatlas.current_sector.description)
to_chat(H, SSatlas.current_sector.get_chat_description())
if("Arrivals Shuttle" in current_map.allowed_spawns && spawning_at == "Arrivals Shuttle")
H.centcomm_despawn_timer = addtimer(CALLBACK(H, /mob/living/.proc/centcomm_timeout), 10 MINUTES, TIMER_STOPPABLE)
to_chat(H,SPAN_NOTICE("You have ten minutes to reach the station before you will be forced there."))
var/datum/job/job = GetJob(rank)
var/list/spawn_in_storage = list()
@@ -339,6 +343,10 @@
else
to_chat(H,"Your job is [rank] and the game just can't handle it! Please report this bug to an administrator.")
if(istype(H)) //give humans wheelchairs, if they need them.
if(H.needs_wheelchair())
H.equip_wheelchair()
if(!joined_late || job.latejoin_at_spawnpoints)
var/obj/S = get_roundstart_spawnpoint(rank)
if(istype(S, /obj/effect/landmark/start) && istype(S.loc, /turf))
@@ -382,10 +390,6 @@
if(LAZYLEN(spawn_in_storage))
EquipItemsStorage(H, H.client.prefs, spawn_in_storage)
if(istype(H)) //give humans wheelchairs, if they need them.
if(H.needs_wheelchair())
H.equip_wheelchair()
to_chat(H, "<B>You are [job.get_total_positions() == 1 ? "the" : "a"] [alt_title ? alt_title : rank].</B>")
if(job.supervisors)
@@ -402,12 +406,18 @@
H.species.equip_later_gear(H)
H.species_items_equipped = TRUE
// So shoes aren't silent if people never change 'em.
H.update_noise_level()
BITSET(H.hud_updateflag, ID_HUD)
BITSET(H.hud_updateflag, IMPLOYAL_HUD)
BITSET(H.hud_updateflag, SPECIALROLE_HUD)
INVOKE_ASYNC(GLOBAL_PROC, .proc/show_location_blurb, H.client, 30)
if(spawning_at == "Arrivals Shuttle")
to_chat(H, "<b>[current_map.command_spawn_message]</b>")
if(joined_late)
var/antag_count = 0
for(var/antag_type in SSticker.mode.antag_tags)
@@ -481,75 +491,6 @@
H.visible_message("<span class='notice'>[H.name] makes their way to the [current_map.dock_short]'s robotic storage, and departs.</span>", "<span class='notice'>You make your way into [current_map.dock_short]'s robotic storage, and depart.</span>", range = 3)
DespawnMob(H)
/datum/controller/subsystem/jobs/proc/EquipPersonal(mob/living/carbon/human/H, rank, joined_late = FALSE, spawning_at)
Debug("EP/([H]): Entry.")
if(!H)
Debug("EP/([H]): Abort, H is null.")
return null
EquipRank(H, rank, joined_late)
if("Arrivals Shuttle" in current_map.allowed_spawns)
H.centcomm_despawn_timer = addtimer(CALLBACK(H, /mob/living/.proc/centcomm_timeout), 10 MINUTES, TIMER_STOPPABLE)
if(spawning_at == "Arrivals Shuttle")
to_chat(H,SPAN_NOTICE("You have ten minutes to reach the station before you will be forced there."))
var/datum/job/job = GetJob(rank)
H.job = rank
var/list/spawn_in_storage = list()
if(H.needs_wheelchair())
H.equip_wheelchair()
if(job)
//Equip custom gear loadout.
var/list/custom_equip_slots = list() //If more than one item takes the same slot, all after the first one spawn in storage.
var/list/custom_equip_leftovers = list()
EquipCustom(H, job, H.client.prefs, custom_equip_leftovers, spawn_in_storage, custom_equip_slots)
Debug("EP/([H]): EC Complated, running pre_equip and late_equip.")
//Equip job items.
job.pre_equip(H) // Spawn in the backpack
job.late_equip(H)
job.setup_account(H)
spawn_in_storage += EquipCustomDeferred(H, H.client.prefs, custom_equip_leftovers, custom_equip_slots)
else
to_chat(H,"Your job is [rank] and the game just can't handle it! Please report this bug to an administrator.")
if(LAZYLEN(spawn_in_storage))
EquipItemsStorage(H, H.client.prefs, spawn_in_storage)
//Gives glasses to the vision impaired
if(H.disabilities & NEARSIGHTED)
var/equipped = H.equip_to_slot_or_del(new /obj/item/clothing/glasses/regular(H), slot_glasses)
if(equipped != 1)
var/obj/item/clothing/glasses/G = H.glasses
G.prescription = 7
if(H.species && !H.species_items_equipped)
H.species.equip_later_gear(H)
H.species_items_equipped = TRUE
// So shoes aren't silent if people never change 'em.
H.update_noise_level()
BITSET(H.hud_updateflag, ID_HUD)
BITSET(H.hud_updateflag, IMPLOYAL_HUD)
BITSET(H.hud_updateflag, SPECIALROLE_HUD)
if(spawning_at == "Arrivals Shuttle")
to_chat(H, "<b>[current_map.command_spawn_message]</b>")
Debug("EP/([H]): Completed.")
return H
/datum/controller/subsystem/jobs/proc/LoadJobs(jobsfile)
if (!config.load_jobs_from_txt)
return FALSE
@@ -953,11 +894,11 @@
for(var/item in prefs.gear)
var/datum/gear/L = gear_datums[item]
if(L.slot == slot_w_uniform)
if(U.uniform && !spawned_uniform)
if(U.uniform && !spawned_uniform && !istype(H.w_uniform, U.uniform))
H.equip_or_collect(new U.uniform(H), H.back)
spawned_uniform = TRUE
if(L.slot == slot_wear_suit)
if(U.suit && !spawned_suit)
if(U.suit && !spawned_suit && !istype(H.wear_suit, U.suit))
H.equip_or_collect(new U.suit(H), H.back)
spawned_suit = TRUE
#undef Debug