world/Reboot refactor (#15268)

* world/Reboot refactor

* Re adds noises

* Im being punished by my own CI!
This commit is contained in:
AffectedArc07
2021-01-15 13:03:08 -05:00
committed by GitHub
parent 56423a0049
commit 2f6b0a9a0f
7 changed files with 104 additions and 49 deletions
+39 -2
View File
@@ -59,6 +59,8 @@ SUBSYSTEM_DEF(ticker)
var/mode_result = "undefined"
/// Server end state (Did we end properly or reboot or nuke or what)
var/end_state = "undefined"
/// Time the real reboot kicks in
var/real_reboot_time = 0
/datum/controller/subsystem/ticker/Initialize()
login_music = pick(\
@@ -128,9 +130,9 @@ SUBSYSTEM_DEF(ticker)
spawn(50)
if(mode.station_was_nuked)
world.Reboot("Station destroyed by Nuclear Device.", "nuke")
reboot_helper("Station destroyed by Nuclear Device.", "nuke")
else
world.Reboot("Round ended.", "proper completion")
reboot_helper("Round ended.", "proper completion")
/datum/controller/subsystem/ticker/proc/setup()
cultdat = setupcult()
@@ -541,3 +543,38 @@ SUBSYSTEM_DEF(ticker)
var/datum/trade_destination/D = new loc_type
GLOB.weighted_randomevent_locations[D] = D.viable_random_events.len
GLOB.weighted_mundaneevent_locations[D] = D.viable_mundane_events.len
// Easy handler to make rebooting the world not a massive sleep in world/Reboot()
/datum/controller/subsystem/ticker/proc/reboot_helper(reason, end_string, delay)
// Admins delayed round end. Just alert and dont bother with anything else.
if(delay_end)
to_chat(world, "<span class='boldannounce'>An admin has delayed the round end.</span>")
return
if(!isnull(delay))
// Delay time was present. Use that.
delay = max(0, delay)
else
// Use default restart timeout
delay = restart_timeout
to_chat(world, "<span class='boldannounce'>Rebooting world in [delay/10] [delay > 10 ? "seconds" : "second"]. [reason]</span>")
real_reboot_time = world.time + delay
UNTIL(world.time > real_reboot_time) // Hold it here
// And if we re-delayed, bail again
if(delay_end)
to_chat(world, "<span class='boldannounce'>Reboot was cancelled by an admin.</span>")
return
if(end_string)
end_state = end_string
// Play a haha funny noise
var/round_end_sound = pick(GLOB.round_end_sounds)
var/sound_length = GLOB.round_end_sounds[round_end_sound]
world << round_end_sound
sleep(sound_length)
world.Reboot()
+1 -1
View File
@@ -180,7 +180,7 @@ SUBSYSTEM_DEF(vote)
if(restart)
world.Reboot("Restart vote successful.", "restart vote")
SSticker.reboot_helper("Restart vote successful.", "restart vote")
return .