Adds a config to optionally hard reboot DD (#33006)

This commit is contained in:
Jordan Brown
2017-11-24 05:53:08 -05:00
committed by CitadelStationBot
parent 9f7b3a11c3
commit dc0310eb5d
3 changed files with 35 additions and 0 deletions

View File

@@ -381,3 +381,7 @@ CONFIG_TWEAK(flag/ValidateAndSet(str_val))
. = ..()
if(. && Master.current_runlevel)
world.sleep_offline = !value
CONFIG_DEF(number/rounds_until_hard_restart)
value = -1
min_val = 0

View File

@@ -1,4 +1,7 @@
#define RESTART_COUNTER_PATH "data/round_counter.txt"
GLOBAL_VAR(security_mode)
GLOBAL_VAR(restart_counter)
GLOBAL_PROTECT(security_mode)
/world/New()
@@ -31,6 +34,10 @@ GLOBAL_PROTECT(security_mode)
GLOB.timezoneOffset = text2num(time2text(0,"hh")) * 36000
if(fexists(RESTART_COUNTER_PATH))
GLOB.restart_counter = text2num(trim(file2text(RESTART_COUNTER_PATH)))
fdel(RESTART_COUNTER_PATH)
Master.Initialize(10, FALSE)
@@ -161,6 +168,27 @@ GLOBAL_PROTECT(security_mode)
else
to_chat(world, "<span class='boldannounce'>Rebooting world...</span>")
Master.Shutdown() //run SS shutdowns
if(SERVER_TOOLS_PRESENT)
var/do_hard_reboot
// check the hard reboot counter
var/ruhr = CONFIG_GET(number/rounds_until_hard_restart)
switch(ruhr)
if(-1)
do_hard_reboot = FALSE
if(0)
do_hard_reboot = TRUE
else
if(GLOB.restart_counter >= ruhr)
do_hard_reboot = TRUE
else
text2file("[++GLOB.restart_counter]", RESTART_COUNTER_PATH)
do_hard_reboot = FALSE
if(do_hard_reboot)
log_world("World hard rebooted at [time_stamp()]")
SERVER_TOOLS_REBOOT_BYOND
log_world("World rebooted at [time_stamp()]")
..()

View File

@@ -383,3 +383,6 @@ DISABLE_HIGH_POP_MC_MODE_AMOUNT 60
## Uncomment to prevent the world from sleeping while no players are connected after initializations
#RESUME_AFTER_INITIALIZATIONS
## Uncomment to set the number of /world/Reboot()s before the DreamDaemon restarts itself. 0 means restart every round. Requires tgstation server tools.
#ROUNDS_UNTIL_HARD_RESTART 10