Skip to content

Commit

Permalink
world.fps and SStimers safety check (#9478)
Browse files Browse the repository at this point in the history
* tgstation/tgstation#45236

* uncomment unused
  • Loading branch information
Tsar-Salat authored Oct 6, 2023
1 parent 85e8332 commit d697800
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion code/controllers/master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
// Sort subsystems by display setting for easy access.
sortTim(subsystems, GLOBAL_PROC_REF(cmp_subsystem_display))
// Set world options.
world.fps = CONFIG_GET(number/fps)
world.change_fps(CONFIG_GET(number/fps))
var/initialized_tod = REALTIMEOFDAY

if(sleep_offline_after_initializations)
Expand Down
23 changes: 23 additions & 0 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,29 @@ GLOBAL_VAR(restart_counter)

/world/proc/refresh_atmos_grid()

/world/proc/change_fps(new_value = 20)
if(new_value <= 0)
CRASH("change_fps() called with [new_value] new_value.")
if(fps == new_value)
return //No change required.

fps = new_value
on_tickrate_change()

/* UNUSED. uncomment if using
/world/proc/change_tick_lag(new_value = 0.5)
if(new_value <= 0)
CRASH("change_tick_lag() called with [new_value] new_value.")
if(tick_lag == new_value)
return //No change required.
tick_lag = new_value
on_tickrate_change()
*/

/world/proc/on_tickrate_change()
SStimer?.reset_buckets()

/world/proc/init_byond_tracy()
var/library

Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/verbs/fps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SSblackbox.record_feedback("nested tally", "admin_toggle", 1, list("Set Server FPS", "[new_fps]")) //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

CONFIG_SET(number/fps, new_fps)
world.fps = new_fps
world.change_fps(new_fps)

0 comments on commit d697800

Please sign in to comment.