[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.

🆑
fix: Fixes the brig cell timer adjustment not working correctly on live
timers.
/🆑

Co-authored-by: Pickle-Coding <58013024+Pickle-Coding@users.noreply.github.com>
This commit is contained in:
SkyratBot
2024-06-07 08:28:05 +02:00
committed by GitHub
co-authored by Pickle-Coding
parent 78d916abb6
commit 6eb2c72730
+12 -10
View File
@@ -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")