mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 12:07:27 +01:00
An attempt to make the master controller more robust. This shouldn't cause terrible additional lag, given that the master controller doesn't actually fire that often, and can also give us a clue as to what part of the controller has died in case of failure
Modifies do_after to something that fires a lot less, and is hopefully more robust against infinite loops. It is now theoretically possible to run around and then come back to the same place and have it complete, but that's only really valid for extremely long times (like handcuff removal) and if you get lucky and dodge one of the timed checks. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3421 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
+124
-22
@@ -1,9 +1,26 @@
|
||||
var/global/datum/controller/game_controller/master_controller //Set in world.New()
|
||||
var/global/datum/failsafe/Failsafe
|
||||
var/global/controllernum = "no"
|
||||
var/global/controller_iteration = 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
datum/controller/game_controller
|
||||
var/processing = 1
|
||||
|
||||
var/global/air_master_ready = 0
|
||||
var/global/tension_master_ready = 0
|
||||
var/global/sun_ready = 0
|
||||
var/global/mobs_ready = 0
|
||||
var/global/diseases_ready = 0
|
||||
var/global/machines_ready = 0
|
||||
var/global/objects_ready = 0
|
||||
var/global/networks_ready = 0
|
||||
var/global/powernets_ready = 0
|
||||
var/global/ticker_ready = 0
|
||||
|
||||
proc
|
||||
setup()
|
||||
setup_objects()
|
||||
@@ -73,57 +90,142 @@ datum/controller/game_controller
|
||||
|
||||
process()
|
||||
|
||||
if(!Failsafe)
|
||||
Failsafe = new /datum/failsafe
|
||||
spawn(0)
|
||||
Failsafe.spin()
|
||||
|
||||
|
||||
if(!processing)
|
||||
return 0
|
||||
controllernum = "yes"
|
||||
spawn (100) controllernum = "no"
|
||||
spawn (100)
|
||||
controllernum = "no"
|
||||
|
||||
controller_iteration++
|
||||
|
||||
var/start_time = world.timeofday
|
||||
|
||||
air_master.process()
|
||||
air_master_ready = 0
|
||||
tension_master_ready = 0
|
||||
sun_ready = 0
|
||||
mobs_ready = 0
|
||||
diseases_ready = 0
|
||||
machines_ready = 0
|
||||
objects_ready = 0
|
||||
networks_ready = 0
|
||||
powernets_ready = 0
|
||||
ticker_ready = 0
|
||||
|
||||
tension_master.process()
|
||||
|
||||
|
||||
|
||||
|
||||
spawn(0)
|
||||
air_master.process()
|
||||
air_master_ready = 1
|
||||
spawn(0)
|
||||
tension_master.process()
|
||||
tension_master_ready = 1
|
||||
|
||||
sleep(1)
|
||||
|
||||
sun.calc_position()
|
||||
spawn(0)
|
||||
sun.calc_position()
|
||||
sun_ready = 1
|
||||
|
||||
sleep(-1)
|
||||
|
||||
for(var/mob/M in world)
|
||||
M.Life()
|
||||
spawn(0)
|
||||
for(var/mob/M in world)
|
||||
M.Life()
|
||||
mobs_ready = 1
|
||||
|
||||
|
||||
|
||||
sleep(-1)
|
||||
|
||||
for(var/datum/disease/D in active_diseases)
|
||||
D.process()
|
||||
spawn(0)
|
||||
for(var/datum/disease/D in active_diseases)
|
||||
D.process()
|
||||
diseases_ready = 1
|
||||
|
||||
for(var/obj/machinery/machine in machines)
|
||||
if(machine)
|
||||
machine.process()
|
||||
if(machine && machine.use_power)
|
||||
machine.auto_use_power()
|
||||
spawn(0)
|
||||
for(var/obj/machinery/machine in machines)
|
||||
if(machine)
|
||||
machine.process()
|
||||
if(machine && machine.use_power)
|
||||
machine.auto_use_power()
|
||||
|
||||
machines_ready = 1
|
||||
|
||||
sleep(-1)
|
||||
sleep(1)
|
||||
|
||||
for(var/obj/object in processing_objects)
|
||||
object.process()
|
||||
spawn(0)
|
||||
for(var/obj/object in processing_objects)
|
||||
object.process()
|
||||
objects_ready = 1
|
||||
|
||||
for(var/datum/pipe_network/network in pipe_networks)
|
||||
network.process()
|
||||
spawn(0)
|
||||
for(var/datum/pipe_network/network in pipe_networks)
|
||||
network.process()
|
||||
networks_ready = 1
|
||||
|
||||
for(var/datum/powernet/P in powernets)
|
||||
P.reset()
|
||||
spawn(0)
|
||||
for(var/datum/powernet/P in powernets)
|
||||
P.reset()
|
||||
powernets_ready = 1
|
||||
|
||||
sleep(-1)
|
||||
|
||||
ticker.process()
|
||||
spawn(0)
|
||||
ticker.process()
|
||||
ticker_ready = 1
|
||||
|
||||
sleep(world.timeofday+12-start_time)
|
||||
|
||||
spawn process()
|
||||
while(!air_master_ready || !tension_master_ready || !sun_ready || !mobs_ready || !diseases_ready || !machines_ready || !objects_ready || !networks_ready || !powernets_ready || !ticker_ready)
|
||||
sleep(1)
|
||||
|
||||
spawn
|
||||
process()
|
||||
|
||||
|
||||
return 1
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
/datum/failsafe // This thing pretty much just keeps poking the master controller
|
||||
var/spinning = 1
|
||||
var/current_iteration = 0
|
||||
|
||||
/datum/failsafe/proc/spin()
|
||||
if(!master_controller) // Well fuck. How did this happen?
|
||||
sleep(50)
|
||||
if(!master_controller)
|
||||
master_controller = new /datum/controller/game_controller()
|
||||
spawn(-1)
|
||||
master_controller.setup()
|
||||
|
||||
else
|
||||
while(spinning)
|
||||
current_iteration = controller_iteration
|
||||
sleep(150) // Wait 15 seconds
|
||||
if(current_iteration == controller_iteration) // Mm. The master controller hasn't ticked yet.
|
||||
|
||||
for (var/mob/M in world)
|
||||
if (M.client && M.client.holder)
|
||||
M << "<font color='red' size='2'><b> Warning. The Master Controller has not fired in the last 15 seconds. Restart recommended. Automatic restart in 15 seconds.</b></font>"
|
||||
|
||||
sleep(150)
|
||||
if(current_iteration == controller_iteration)
|
||||
for (var/mob/M in world)
|
||||
if (M.client && M.client.holder)
|
||||
M << "<font color='red' size='2'><b> Warning. The Master Controller has not fired in the last 30 seconds. Automatic restart beginning.</b></font>"
|
||||
master_controller.process()
|
||||
sleep(150)
|
||||
else
|
||||
for (var/mob/M in world)
|
||||
if (M.client && M.client.holder)
|
||||
M << "<font color='red' size='2'><b> The Master Controller has fired. Automatic restart aborted.</b></font>"
|
||||
Reference in New Issue
Block a user