Add system to let the restart script know when a round ends so it doesn't kill the round.

This commit is contained in:
Rob Nelson
2013-09-17 04:50:35 -07:00
parent a28d341ae1
commit cc1d20f049
7 changed files with 51 additions and 6 deletions

View File

@@ -842,6 +842,7 @@
#include "code\modules\events\wallrot.dm"
#include "code\modules\ext_scripts\irc.dm"
#include "code\modules\ext_scripts\python.dm"
#include "code\modules\ext_scripts\watchdog.dm"
#include "code\modules\flufftext\Dreaming.dm"
#include "code\modules\flufftext\Hallucination.dm"
#include "code\modules\flufftext\TextFilters.dm"

View File

@@ -302,7 +302,13 @@ var/global/datum/controller/gameticker/ticker
emergency_shuttle.process()
var/mode_finished = mode.check_finished() || (emergency_shuttle.location == 2 && emergency_shuttle.alert == 1)
var/force_round_end=0
// If server's empty, force round end.
if(watchdog.waiting && player_list.len == 0)
force_round_end=1
var/mode_finished = mode.check_finished() || (emergency_shuttle.location == 2 && emergency_shuttle.alert == 1) || force_round_end
if(!mode.explosion_in_progress && mode_finished)
current_state = GAME_STATE_FINISHED
@@ -312,18 +318,20 @@ var/global/datum/controller/gameticker/ticker
spawn(50)
if (mode.station_was_nuked)
feedback_set_details("end_proper","nuke")
if(!delay_end)
if(!delay_end && !watchdog.waiting)
world << "\blue <B>Rebooting due to destruction of station in [restart_timeout/10] seconds</B>"
else
feedback_set_details("end_proper","proper completion")
if(!delay_end)
if(!delay_end && !watchdog.waiting)
world << "\blue <B>Restarting in [restart_timeout/10] seconds</B>"
if(blackbox)
blackbox.save_all_data_to_sql()
if(!delay_end)
if (watchdog.waiting)
world << "\blue <B>Server will shut down for an automatic update in a few seconds.</B>"
watchdog.signal_ready()
else if(!delay_end)
sleep(restart_timeout)
if(!delay_end)
world.Reboot()

View File

@@ -47,6 +47,10 @@
if(blackbox)
blackbox.save_all_data_to_sql()
if (watchdog.waiting)
world << "\blue <B>Server will shut down for an automatic update in a few seconds.</B>"
watchdog.signal_ready()
return
sleep(50)
world.Reboot()
return

View File

@@ -306,6 +306,11 @@ var/bomb_set
if(blackbox)
blackbox.save_all_data_to_sql()
if (watchdog.waiting)
world << "\blue <B>Server will shut down for an automatic update in a few seconds.</B>"
watchdog.signal_ready()
return
sleep(300)
log_game("Rebooting due to nuclear detonation")
world.Reboot()

View File

@@ -685,6 +685,11 @@ var/global/floorIsLava = 0
if(blackbox)
blackbox.save_all_data_to_sql()
if (watchdog.waiting)
world << "\blue <B>Server will shut down for an automatic update in a few seconds.</B>"
watchdog.signal_ready()
return
sleep(50)
world.Reboot()
@@ -871,6 +876,11 @@ var/global/floorIsLava = 0
if(blackbox)
blackbox.save_all_data_to_sql()
if (watchdog.waiting)
world << "\blue <B>Server will shut down for an automatic update in a few seconds.</B>"
watchdog.signal_ready()
return
world.Reboot()
/datum/admins/proc/unprison(var/mob/M in mob_list)

View File

@@ -6,4 +6,4 @@
var/command = config.python_path + " " + script + " " + args
return shell(command)
return shell(command)

View File

@@ -0,0 +1,17 @@
var/global/datum/watchdog/watchdog = new
/datum/watchdog
var/waiting=0 // Waiting for the server to end round or empty.
var/const/update_signal_file="data/UPDATE_READY.txt"
var/const/server_signal_file="data/SERVER_READY.txt"
/datum/watchdog/proc/check_for_update()
if(waiting)
return
if(fexists(update_signal_file) == 1)
waiting=1
/datum/watchdog/proc/signal_ready()
var/signal = file(server_signal_file)
fdel(signal)
signal << "READY"