Skip to content

Commit

Permalink
[MIRROR] Fixes brig cell timer adjusting reducing the time by the tim…
Browse files Browse the repository at this point in the history
…e served for every operation. The maximum allowed time is based on the timer and not time served. [MDB IGNORE] (#2870)

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

* Update brigdoors.dm

* Update brigdoors.dm

---------

Co-authored-by: Pickle-Coding <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
  • Loading branch information
3 people authored and StealsThePRs committed Jun 7, 2024
1 parent 7acf9e9 commit 7509ecd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions code/game/machinery/doors/brigdoors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)) // NOVA EDIT CHANGE: original was world.time
. = max(0, timer_duration + activation_time - REALTIMEOFDAY) // NOVA EDIT CHANGE, Original: . = max(0, timer_duration + activation_time - world.time)
if(seconds)
. /= 10
. /= (1 SECONDS)

/**
* Set the timer. Does NOT automatically start counting down, but does update the display.
Expand All @@ -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 + REALTIMEOFDAY - activation_time) // NOVA EDIT CHANGE, Original: 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()
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 7509ecd

Please sign in to comment.