diff --git a/code/__DEFINES/configuration.dm b/code/__DEFINES/configuration.dm index c78dfb28ab2..3db0ca24c2c 100644 --- a/code/__DEFINES/configuration.dm +++ b/code/__DEFINES/configuration.dm @@ -2,6 +2,7 @@ #define CONFIG_DEF(X) /datum/config_entry/##X { resident_file = CURRENT_RESIDENT_FILE }; /datum/config_entry/##X #define CONFIG_GET(X) global.config.Get(/datum/config_entry/##X) #define CONFIG_SET(X, Y) global.config.Set(/datum/config_entry/##X, ##Y) +#define CONFIG_TWEAK(X) /datum/config_entry/##X #define CONFIG_MAPS_FILE "maps.txt" diff --git a/code/controllers/configuration/entries/config.dm b/code/controllers/configuration/entries/config.dm index dda8fd9a3ce..3be6db06c71 100644 --- a/code/controllers/configuration/entries/config.dm +++ b/code/controllers/configuration/entries/config.dm @@ -348,4 +348,27 @@ CONFIG_DEF(number/error_msg_delay) // How long to wait between messaging admins CONFIG_DEF(flag/irc_announce_new_game) -CONFIG_DEF(flag/debug_admin_hrefs) \ No newline at end of file +CONFIG_DEF(flag/debug_admin_hrefs) + + +CONFIG_DEF(number/mc_tick_rate/base_mc_tick_rate) + integer = FALSE + value = 1 + +CONFIG_DEF(number/mc_tick_rate/high_pop_mc_tick_rate) + integer = FALSE + value = 1.1 + +CONFIG_DEF(number/mc_tick_rate/high_pop_mc_mode_amount) + value = 65 + +CONFIG_DEF(number/mc_tick_rate/disable_high_pop_mc_mode_amount) + value = 60 + +CONFIG_TWEAK(number/mc_tick_rate) + abstract_type = /datum/config_entry/number/mc_tick_rate + +CONFIG_TWEAK(number/mc_tick_rate/ValidateAndSet(str_val)) + . = ..() + if (.) + Master.UpdateTickRate() diff --git a/code/controllers/master.dm b/code/controllers/master.dm index 6ed3121179d..b92853a2c47 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -573,3 +573,13 @@ GLOBAL_REAL(Master, /datum/controller/master) = new for(var/S in subsystems) var/datum/controller/subsystem/SS = S SS.StopLoadingMap() + + +/datum/controller/master/proc/UpdateTickRate() + if (!processing) + return + var/client_count = length(GLOB.clients) + if (client_count < CONFIG_GET(number/mc_tick_rate/disable_high_pop_mc_mode_amount)) + processing = CONFIG_GET(number/mc_tick_rate/base_mc_tick_rate) + else if (client_count > CONFIG_GET(number/mc_tick_rate/high_pop_mc_mode_amount)) + processing = CONFIG_GET(number/mc_tick_rate/high_pop_mc_tick_rate) \ No newline at end of file diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 7699c9cd5f8..886477fa965 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -350,6 +350,8 @@ GLOBAL_LIST(external_rsc_urls) if (menuitem) menuitem.Load_checked(src) + Master.UpdateTickRate() + ////////////// //DISCONNECT// ////////////// @@ -386,6 +388,7 @@ GLOBAL_LIST(external_rsc_urls) if(movingmob != null) movingmob.client_mobs_in_contents -= mob UNSETEMPTY(movingmob.client_mobs_in_contents) + Master.UpdateTickRate() return ..() /client/Destroy() diff --git a/config/config.txt b/config/config.txt index 1602cd4f48d..39ebc952b6b 100644 --- a/config/config.txt +++ b/config/config.txt @@ -232,9 +232,13 @@ ALLOW_HOLIDAYS ##This is currently a testing optimized setting. A good value for production would be 98. TICK_LIMIT_MC_INIT 500 -##Defines the ticklag for the world. 0.9 is the normal one, 0.5 is smoother. +##Defines the ticklag for the world. Ticklag is the amount of time between game ticks (aka byond ticks) (in 1/10ths of a second). +## This also controls the client network update rate, as well as the default client fps TICKLAG 0.5 +##Can also be set as per-second value, the following value is identical to the above. +#FPS 20 + ## Comment this out to disable automuting #AUTOMUTE_ON @@ -360,4 +364,24 @@ MINUTE_TOPIC_LIMIT 100 #IRC_ANNOUNCE_NEW_GAME ## Allow admin hrefs that don't use the new token system, will eventually be removed -DEBUG_ADMIN_HREFS \ No newline at end of file +DEBUG_ADMIN_HREFS + +###Master Controller High Pop Mode### + +##The Master Controller(MC) is the primary system controlling timed tasks and events in SS13 (lobby timer, game checks, lighting updates, atmos, etc) +##Default base MC tick rate (1 = process every "byond tick" (see: tick_lag/fps config settings), 2 = process every 2 byond ticks, etc) +## Setting this to 0 will prevent the Master Controller from ticking +BASE_MC_TICK_RATE 1 + +##High population MC tick rate +## Byond rounds timer values UP, but the tick rate is modified with heuristics during lag spites so setting this to something like 2 +## will make it run every 2 byond ticks, but will also double the effect of anti-lag heuristics. You can instead set it to something like +## 1.1 to make it run every 2 byond ticks, but only increase the effect of anti-lag heuristics by 10%. or 1.5 for 50%. +## (As an aside, you could in theory also reduce the effect of anti-lag heuristics in the base tick rate by setting it to something like 0.5) +HIGH_POP_MC_TICK_RATE 1.1 + +##Engage high pop mode if player count raises above this (Player in this context means any connected user. Lobby, ghost or in-game all count) +HIGH_POP_MC_MODE_AMOUNT 65 + +##Disengage high pop mode if player count drops below this +DISABLE_HIGH_POP_MC_MODE_AMOUNT 60