diff --git a/code/controllers/master.dm b/code/controllers/master.dm index 9511bcfde67..5beab69ad42 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -202,7 +202,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new // Sort subsystems by display setting for easy access. sortTim(subsystems, /proc/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) diff --git a/code/game/world.dm b/code/game/world.dm index ef449e51efa..05ee9f5d86e 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -306,3 +306,27 @@ GLOBAL_VAR(restart_counter) maxz++ SSmobs.MaxZChanged() SSidlenpcpool.MaxZChanged() + + +/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() + + +/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() \ No newline at end of file diff --git a/code/modules/admin/verbs/fps.dm b/code/modules/admin/verbs/fps.dm index ce72889a204..f120f540b9f 100644 --- a/code/modules/admin/verbs/fps.dm +++ b/code/modules/admin/verbs/fps.dm @@ -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)