Skip to content

Commit 59db997

Browse files
authored
Chronofailure experiment (discordia-space#8630)
* Chronofailure experiment * happy happy green message
1 parent 38f38f0 commit 59db997

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

code/controllers/master.dm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
4343
var/init_timeofday
4444
var/init_time
4545
var/tickdrift = 0
46+
var/chronofailure = FALSE
4647

4748
/// How long is the MC sleeping between runs, read only (set by Loop() based off of anti-tick-contention heuristics)
4849
var/sleep_delta = 1
@@ -100,6 +101,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
100101
Recover()
101102
qdel(Master)
102103
Master = src
104+
chronofailure = FALSE // presume time is stable before evidence otherwise
103105
else
104106
//Code used for first master on game boot or if existing master got deleted
105107
Master = src
@@ -376,6 +378,23 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
376378
tickdrift = max(0, MC_AVERAGE_FAST(tickdrift, (((REALTIMEOFDAY - init_timeofday) - (world.time - init_time)) / world.tick_lag)))
377379
var/starting_tick_usage = TICK_USAGE
378380

381+
if(REALTIMEOFDAY < init_timeofday || REALTIMEOFDAY < 0 || world.time < 0)
382+
chronofailure = TRUE
383+
log_game("CHRONOFAILURE: Time collapse with rollover number [midnight_rollovers].")
384+
send2coders(message = "CHRONOFAILURE: Time is collapsing, rollover number [midnight_rollovers]. Attempting timeless reboot.", color = "#ff0000", admiralty = 1)
385+
restart_timeout = 0 // time isn't trustworthy anymore
386+
restart_clear = 0
387+
switch(Recreate_MC()) // attempt reboot
388+
if(-1)
389+
log_game("CHRONOFAILURE: MC reboot failed.")
390+
send2coders(message = "CHRONOFAILURE: Timeless reboot failed.", color = "#ff0000", admiralty = 1)
391+
if(0)
392+
log_game("CHRONOFAILURE: MC reboot failed beyond repair.")
393+
send2coders(message = "CHRONOFAILURE: Timeless reboot failed beyond repair.", color = "#ff0000", admiralty = 1)
394+
if(1)
395+
log_game("CHRONOFAILURE: MC reboot successful.")
396+
send2coders(message = "CHRONOFAILURE: Timeless reboot successful.", color = "#00ff00", admiralty = 1)
397+
379398
if (init_stage != init_stage_completed)
380399
return MC_LOOP_RTN_NEWSTAGES
381400
if (processing <= 0)

0 commit comments

Comments
 (0)