From 56802e42313126b88adababfa60857cd5c0a34de Mon Sep 17 00:00:00 2001 From: Wildkins Date: Tue, 13 Dec 2022 12:41:11 -0500 Subject: [PATCH] Fix respawn timers not resetting upon spawning (#15300) --- code/game/machinery/cryopod.dm | 2 + code/modules/mob/abstract/new_player/menu.dm | 66 +++++++++++--------- code/modules/mob/living/login.dm | 1 + code/modules/mob/mob.dm | 4 -- html/changelogs/johnwildkins-respawn.yml | 7 +++ 5 files changed, 45 insertions(+), 35 deletions(-) create mode 100644 html/changelogs/johnwildkins-respawn.yml diff --git a/code/game/machinery/cryopod.dm b/code/game/machinery/cryopod.dm index d6d44d0899a..3e271204fad 100644 --- a/code/game/machinery/cryopod.dm +++ b/code/game/machinery/cryopod.dm @@ -524,6 +524,7 @@ var/global/list/frozen_crew = list() if(occupant.client) occupant.client.eye = src.occupant.client.mob occupant.client.perspective = MOB_PERSPECTIVE + occupant.reset_death_timers() occupant.forceMove(get_turf(src)) occupant = null @@ -538,6 +539,7 @@ var/global/list/frozen_crew = list() occupant.client.perspective = EYE_PERSPECTIVE occupant.client.eye = src time_entered = world.time + occupant.set_respawn_time() update_icon() /obj/machinery/cryopod/update_icon() diff --git a/code/modules/mob/abstract/new_player/menu.dm b/code/modules/mob/abstract/new_player/menu.dm index 8b4fc81c0d6..7251816c2a2 100644 --- a/code/modules/mob/abstract/new_player/menu.dm +++ b/code/modules/mob/abstract/new_player/menu.dm @@ -253,41 +253,45 @@ alert(src, "Please wait, the map is not initialized yet.") return 0 - if(alert(src,"Are you sure you wish to observe? You will have to wait [config.respawn_delay] minutes before being able to respawn!","Player Setup","Yes","No") == "Yes") - if(!client) - return TRUE - var/mob/abstract/observer/observer = new /mob/abstract/observer(src) - spawning = 1 - sound_to(src, sound(null, repeat = 0, wait = 0, volume = 85, channel = 1)) + if(!client) + return TRUE + // Only display the warning if it's a /new/ new player, + // if they've died and gone back to menu they probably already know their respawn time (and it won't be reset anymore) + if(!get_death_time(CREW)) + if(alert(src, "Are you sure you wish to observe? You will have to wait [config.respawn_delay] minutes before being able to respawn.", "Player Setup", "Yes", "No") != "Yes") + return FALSE + var/mob/abstract/observer/observer = new /mob/abstract/observer(src) + spawning = 1 + sound_to(src, sound(null, repeat = 0, wait = 0, volume = 85, channel = 1)) - observer.started_as_observer = 1 - close_spawn_windows() - var/obj/O = locate("landmark*Observer-Start") in landmarks_list - if(istype(O)) - to_chat(src, "Now teleporting.") - observer.forceMove(O.loc) - else - to_chat(src, "Could not locate an observer spawn point. Use the Teleport verb to jump to the station map.") - observer.timeofdeath = world.time // Set the time of death so that the respawn timer works correctly. + observer.started_as_observer = 1 + close_spawn_windows() + var/obj/O = locate("landmark*Observer-Start") in landmarks_list + if(istype(O)) + to_chat(src, "Now teleporting.") + observer.forceMove(O.loc) + else + to_chat(src, "Could not locate an observer spawn point. Use the Teleport verb to jump to the station map.") + observer.timeofdeath = world.time // Set the time of death so that the respawn timer works correctly. - announce_ghost_joinleave(src) - var/mob/living/carbon/human/dummy/mannequin/mannequin = new - client.prefs.dress_preview_mob(mannequin) - observer.appearance = mannequin.appearance - observer.appearance_flags = KEEP_TOGETHER - observer.alpha = 127 - observer.layer = initial(observer.layer) - observer.invisibility = initial(observer.invisibility) - observer.desc = initial(observer.desc) + announce_ghost_joinleave(src) + var/mob/living/carbon/human/dummy/mannequin/mannequin = new + client.prefs.dress_preview_mob(mannequin) + observer.appearance = mannequin.appearance + observer.appearance_flags = KEEP_TOGETHER + observer.alpha = 127 + observer.layer = initial(observer.layer) + observer.invisibility = initial(observer.invisibility) + observer.desc = initial(observer.desc) - observer.real_name = client.prefs.real_name - observer.name = observer.real_name - if(!client.holder && !config.antag_hud_allowed) - observer.verbs -= /mob/abstract/observer/verb/toggle_antagHUD - observer.ckey = ckey - observer.initialise_postkey() - qdel(src) + observer.real_name = client.prefs.real_name + observer.name = observer.real_name + if(!client.holder && !config.antag_hud_allowed) + observer.verbs -= /mob/abstract/observer/verb/toggle_antagHUD + observer.ckey = ckey + observer.initialise_postkey() + qdel(src) /mob/abstract/new_player/proc/show_lore_summary() if(config.lore_summary) diff --git a/code/modules/mob/living/login.dm b/code/modules/mob/living/login.dm index 32835412c77..682e7ec19bf 100644 --- a/code/modules/mob/living/login.dm +++ b/code/modules/mob/living/login.dm @@ -6,4 +6,5 @@ mind.active = 1 //indicates that the mind is currently synced with a client //If they're SSD, remove it so they can wake back up. update_antag_icons(mind) + reset_death_timers() return . diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index b8aede1e3ec..ef6e567812d 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -480,12 +480,8 @@ announce_ghost_joinleave(client, 0) - // Run this here to null out death timers for the next go. - var/mob/abstract/new_player/M = new /mob/abstract/new_player() - M.reset_death_timers() - if(!client) log_game("[usr.key] AM failed due to disconnect.", ckey=key_name(usr)) qdel(M) diff --git a/html/changelogs/johnwildkins-respawn.yml b/html/changelogs/johnwildkins-respawn.yml new file mode 100644 index 00000000000..8c111b82f81 --- /dev/null +++ b/html/changelogs/johnwildkins-respawn.yml @@ -0,0 +1,7 @@ +author: JohnWildkins + +delete-after: True + +changes: + - bugfix: "Respawn timers are now properly reset upon spawning / being granted a respawn." + - tweak: "Respawn / death timer is no longer reset when observing after having already spawned once in the round."