mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 02:34:00 +00:00
Ports "Makes global master vars static"
* https://github.com/tgstation/tgstation/pull/27523
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
#define MC_TICK_CHECK ( ( world.tick_usage > CURRENT_TICKLIMIT || src.state != SS_RUNNING ) ? pause() : 0 )
|
#define MC_TICK_CHECK ( ( world.tick_usage > Master.current_ticklimit || src.state != SS_RUNNING ) ? pause() : 0 )
|
||||||
|
|
||||||
// Used for splitting up your remaining time into phases, if you want to evenly divide it.
|
// Used for splitting up your remaining time into phases, if you want to evenly divide it.
|
||||||
#define MC_SPLIT_TICK_INIT(phase_count) var/original_tick_limit = CURRENT_TICKLIMIT; var/split_tick_phases = ##phase_count
|
#define MC_SPLIT_TICK_INIT(phase_count) var/original_tick_limit = Master.current_ticklimit; var/split_tick_phases = ##phase_count
|
||||||
#define MC_SPLIT_TICK \
|
#define MC_SPLIT_TICK \
|
||||||
if(split_tick_phases > 1){\
|
if(split_tick_phases > 1){\
|
||||||
CURRENT_TICKLIMIT = ((original_tick_limit - world.tick_usage) / split_tick_phases) + world.tick_usage;\
|
Master.current_ticklimit = ((original_tick_limit - world.tick_usage) / split_tick_phases) + world.tick_usage;\
|
||||||
--split_tick_phases;\
|
--split_tick_phases;\
|
||||||
} else {\
|
} else {\
|
||||||
CURRENT_TICKLIMIT = original_tick_limit;\
|
Master.current_ticklimit = original_tick_limit;\
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to smooth out costs to try and avoid oscillation.
|
// Used to smooth out costs to try and avoid oscillation.
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
#define TICK_LIMIT_MC 70
|
#define TICK_LIMIT_MC 70
|
||||||
#define TICK_LIMIT_MC_INIT_DEFAULT 98
|
#define TICK_LIMIT_MC_INIT_DEFAULT 98
|
||||||
|
|
||||||
#define TICK_CHECK ( world.tick_usage > CURRENT_TICKLIMIT )
|
#define TICK_CHECK ( world.tick_usage > Master.current_ticklimit )
|
||||||
#define CHECK_TICK if TICK_CHECK stoplag()
|
#define CHECK_TICK if TICK_CHECK stoplag()
|
||||||
|
|||||||
@@ -120,4 +120,4 @@ var/round_start_time = 0
|
|||||||
. += round(i*DELTA_CALC)
|
. += round(i*DELTA_CALC)
|
||||||
sleep(i*world.tick_lag*DELTA_CALC)
|
sleep(i*world.tick_lag*DELTA_CALC)
|
||||||
i *= 2
|
i *= 2
|
||||||
while (world.tick_usage > min(TICK_LIMIT_TO_RUN, CURRENT_TICKLIMIT))
|
while (world.tick_usage > min(TICK_LIMIT_TO_RUN, Master.current_ticklimit))
|
||||||
|
|||||||
@@ -7,14 +7,6 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
var/datum/controller/master/Master = new()
|
var/datum/controller/master/Master = new()
|
||||||
var/MC_restart_clear = 0
|
|
||||||
var/MC_restart_timeout = 0
|
|
||||||
var/MC_restart_count = 0
|
|
||||||
|
|
||||||
|
|
||||||
//current tick limit, assigned by the queue controller before running a subsystem.
|
|
||||||
//used by check_tick as well so that the procs subsystems call can obey that SS's tick limits
|
|
||||||
var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
|
||||||
|
|
||||||
/datum/controller/master
|
/datum/controller/master
|
||||||
name = "Master"
|
name = "Master"
|
||||||
@@ -52,6 +44,14 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
|||||||
|
|
||||||
var/current_runlevel //for scheduling different subsystems for different stages of the round
|
var/current_runlevel //for scheduling different subsystems for different stages of the round
|
||||||
|
|
||||||
|
var/static/restart_clear = 0
|
||||||
|
var/static/restart_timeout = 0
|
||||||
|
var/static/restart_count = 0
|
||||||
|
|
||||||
|
//current tick limit, assigned before running a subsystem.
|
||||||
|
//used by CHECK_TICK as well so that the procs subsystems call can obey that SS's tick limits
|
||||||
|
var/static/current_ticklimit = TICK_LIMIT_RUNNING
|
||||||
|
|
||||||
/datum/controller/master/New()
|
/datum/controller/master/New()
|
||||||
// Highlander-style: there can only be one! Kill off the old and replace it with the new.
|
// Highlander-style: there can only be one! Kill off the old and replace it with the new.
|
||||||
subsystems = list()
|
subsystems = list()
|
||||||
@@ -79,14 +79,14 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
|||||||
// -1 if we encountered a runtime trying to recreate it
|
// -1 if we encountered a runtime trying to recreate it
|
||||||
/proc/Recreate_MC()
|
/proc/Recreate_MC()
|
||||||
. = -1 //so if we runtime, things know we failed
|
. = -1 //so if we runtime, things know we failed
|
||||||
if (world.time < MC_restart_timeout)
|
if (world.time < Master.restart_timeout)
|
||||||
return 0
|
return 0
|
||||||
if (world.time < MC_restart_clear)
|
if (world.time < Master.restart_clear)
|
||||||
MC_restart_count *= 0.5
|
Master.restart_count *= 0.5
|
||||||
|
|
||||||
var/delay = 50 * ++MC_restart_count
|
var/delay = 50 * ++Master.restart_count
|
||||||
MC_restart_timeout = world.time + delay
|
Master.restart_timeout = world.time + delay
|
||||||
MC_restart_clear = world.time + (delay * 2)
|
Master.restart_clear = world.time + (delay * 2)
|
||||||
Master.processing = 0 //stop ticking this one
|
Master.processing = 0 //stop ticking this one
|
||||||
try
|
try
|
||||||
new/datum/controller/master()
|
new/datum/controller/master()
|
||||||
@@ -155,13 +155,13 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
|||||||
|
|
||||||
var/start_timeofday = REALTIMEOFDAY
|
var/start_timeofday = REALTIMEOFDAY
|
||||||
// Initialize subsystems.
|
// Initialize subsystems.
|
||||||
CURRENT_TICKLIMIT = config.tick_limit_mc_init
|
current_ticklimit = config.tick_limit_mc_init
|
||||||
for (var/datum/controller/subsystem/SS in subsystems)
|
for (var/datum/controller/subsystem/SS in subsystems)
|
||||||
if (SS.flags & SS_NO_INIT)
|
if (SS.flags & SS_NO_INIT)
|
||||||
continue
|
continue
|
||||||
SS.Initialize(REALTIMEOFDAY)
|
SS.Initialize(REALTIMEOFDAY)
|
||||||
CHECK_TICK
|
CHECK_TICK
|
||||||
CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
current_ticklimit = TICK_LIMIT_RUNNING
|
||||||
var/time = (REALTIMEOFDAY - start_timeofday) / 10
|
var/time = (REALTIMEOFDAY - start_timeofday) / 10
|
||||||
|
|
||||||
var/msg = "Initializations complete within [time] second[time == 1 ? "" : "s"]!"
|
var/msg = "Initializations complete within [time] second[time == 1 ? "" : "s"]!"
|
||||||
@@ -268,7 +268,7 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
|||||||
while (1)
|
while (1)
|
||||||
tickdrift = max(0, MC_AVERAGE_FAST(tickdrift, (((REALTIMEOFDAY - init_timeofday) - (world.time - init_time)) / world.tick_lag)))
|
tickdrift = max(0, MC_AVERAGE_FAST(tickdrift, (((REALTIMEOFDAY - init_timeofday) - (world.time - init_time)) / world.tick_lag)))
|
||||||
if (processing <= 0)
|
if (processing <= 0)
|
||||||
CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
current_ticklimit = TICK_LIMIT_RUNNING
|
||||||
sleep(10)
|
sleep(10)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
|||||||
// because sleeps are processed in the order received, so longer sleeps are more likely to run first
|
// because sleeps are processed in the order received, so longer sleeps are more likely to run first
|
||||||
if (world.tick_usage > TICK_LIMIT_MC)
|
if (world.tick_usage > TICK_LIMIT_MC)
|
||||||
sleep_delta += 2
|
sleep_delta += 2
|
||||||
CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING - (TICK_LIMIT_RUNNING * 0.5)
|
current_ticklimit = TICK_LIMIT_RUNNING * 0.5
|
||||||
sleep(world.tick_lag * (processing + sleep_delta))
|
sleep(world.tick_lag * (processing + sleep_delta))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -314,7 +314,7 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
|||||||
if (!error_level)
|
if (!error_level)
|
||||||
iteration++
|
iteration++
|
||||||
error_level++
|
error_level++
|
||||||
CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
current_ticklimit = TICK_LIMIT_RUNNING
|
||||||
sleep(10)
|
sleep(10)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -326,7 +326,7 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
|||||||
if (!error_level)
|
if (!error_level)
|
||||||
iteration++
|
iteration++
|
||||||
error_level++
|
error_level++
|
||||||
CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
current_ticklimit = TICK_LIMIT_RUNNING
|
||||||
sleep(10)
|
sleep(10)
|
||||||
continue
|
continue
|
||||||
error_level--
|
error_level--
|
||||||
@@ -337,7 +337,7 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
|||||||
iteration++
|
iteration++
|
||||||
last_run = world.time
|
last_run = world.time
|
||||||
src.sleep_delta = MC_AVERAGE_FAST(src.sleep_delta, sleep_delta)
|
src.sleep_delta = MC_AVERAGE_FAST(src.sleep_delta, sleep_delta)
|
||||||
CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING - (TICK_LIMIT_RUNNING * 0.25) //reserve the tail 1/4 of the next tick for the mc.
|
current_ticklimit = TICK_LIMIT_RUNNING - (TICK_LIMIT_RUNNING * 0.25) //reserve the tail 1/4 of the next tick for the mc.
|
||||||
sleep(world.tick_lag * (processing + sleep_delta))
|
sleep(world.tick_lag * (processing + sleep_delta))
|
||||||
|
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
|
|||||||
else
|
else
|
||||||
tick_precentage = tick_remaining
|
tick_precentage = tick_remaining
|
||||||
|
|
||||||
CURRENT_TICKLIMIT = world.tick_usage + tick_precentage
|
current_ticklimit = world.tick_usage + tick_precentage
|
||||||
|
|
||||||
if (!(queue_node_flags & SS_TICKER))
|
if (!(queue_node_flags & SS_TICKER))
|
||||||
ran_non_ticker = TRUE
|
ran_non_ticker = TRUE
|
||||||
|
|||||||
Reference in New Issue
Block a user