From 6eb2c72730a5e83bb17d29514c874bcf89be7ed1 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 7 Jun 2024 08:28:05 +0200 Subject: [PATCH] [MIRROR] Fixes brig cell timer adjusting reducing the time by the time served for every operation. The maximum allowed time is based on the timer and not time served. (#28024) Fixes brig cell timer adjusting reducing the time by the time served for every operation. The maximum allowed time is based on the timer and not time served. (#83520) Fixes brig cell timer reducing the time by the time served for every operation. This caused increasing time on timers that were run sufficiently long enough to actually decrease time instead, which was dumb. Also sets the max timer for the brig cell to be based on the timer and not account for time served. Makes the buttons work as advertised. :cl: fix: Fixes the brig cell timer adjustment not working correctly on live timers. /:cl: Co-authored-by: Pickle-Coding <58013024+Pickle-Coding@users.noreply.github.com> --- code/game/machinery/doors/brigdoors.dm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/code/game/machinery/doors/brigdoors.dm b/code/game/machinery/doors/brigdoors.dm index 9b17d56973a..ede704801e3 100644 --- a/code/game/machinery/doors/brigdoors.dm +++ b/code/game/machinery/doors/brigdoors.dm @@ -21,12 +21,14 @@ text_color = "#F44" header_text_color = "#F88" - var/id = null // id of linked machinery/lockers - + /// ID of linked machinery/lockers. + var/id = null + /// The time at which the timer started. var/activation_time = 0 + /// The time offset from the activation time before releasing. var/timer_duration = 0 - - var/timing = FALSE // boolean, true/1 timer is on, false/0 means it's not timing + /// Is the timer on? + var/timing = FALSE ///List of weakrefs to nearby doors var/list/doors = list() ///List of weakrefs to nearby flashers @@ -142,7 +144,7 @@ sec_radio.talk_into(src, "Timer has expired. Releasing prisoner.", FREQ_SECURITY) timing = FALSE - activation_time = null + activation_time = 0 set_timer(0) end_processing() @@ -172,12 +174,12 @@ /** * Return time left. * Arguments: - * * seconds - return time in seconds it TRUE, else deciseconds. + * * seconds - Return the time in seconds if TRUE, else deciseconds. */ /obj/machinery/status_display/door_timer/proc/time_left(seconds = FALSE) - . = max(0, timer_duration - (activation_time ? REALTIMEOFDAY - activation_time : 0)) // SKYRAT EDIT CHANGE: original was world.time + . = max(0, timer_duration + activation_time - REALTIMEOFDAY) // SKYRAT EDIT CHANGE: original was world.time if(seconds) - . /= 10 + . /= (1 SECONDS) /** * Set the timer. Does NOT automatically start counting down, but does update the display. @@ -188,7 +190,7 @@ * value - time in deciseconds to set the timer for. */ /obj/machinery/status_display/door_timer/proc/set_timer(value) - var/new_time = clamp(value, 0, MAX_TIMER) + var/new_time = clamp(value, 0, MAX_TIMER + world.time - activation_time) . = new_time == timer_duration //return 1 on no change timer_duration = new_time update_content() @@ -233,7 +235,7 @@ if("time") var/value = text2num(params["adjust"]) if(value) - . = set_timer(time_left() + value) + . = set_timer(timer_duration + value) user.investigate_log("modified the timer by [value/10] seconds for cell [id], currently [time_left(seconds = TRUE)]", INVESTIGATE_RECORDS) user.log_message("modified the timer by [value/10] seconds for cell [id], currently [time_left(seconds = TRUE)]", LOG_ATTACK) if("start")