mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 02:16:05 +00: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:
@@ -1273,9 +1273,10 @@ proc/listclearnulls(list/list)
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
|
||||
/*
|
||||
/proc/do_after(mob/M as mob, time as num)
|
||||
if(!M) return 0
|
||||
if(!M)
|
||||
return 0
|
||||
var/turf/T = M.loc
|
||||
var/holding = M.equipped()
|
||||
for(var/i=0, i<time)
|
||||
@@ -1286,6 +1287,24 @@ proc/listclearnulls(list/list)
|
||||
else
|
||||
return 0
|
||||
return 1
|
||||
*/
|
||||
|
||||
/proc/do_after(var/mob/user as mob, delay as num, var/numticks = 5) // Replacing the upper one with this one because Byond keeps feeling that the upper one is an infinate loop
|
||||
if(!user || isnull(user)) // This one should have less temptation
|
||||
return 0
|
||||
if(numticks == 0)
|
||||
return 0
|
||||
|
||||
var/delayfraction = delay/numticks
|
||||
var/turf/T = user.loc
|
||||
var/holding = user.equipped()
|
||||
|
||||
for(var/i = 0, i<numticks, i++)
|
||||
sleep(delayfraction)
|
||||
if(!src || !user || !user.canmove || !(user.loc == T) || !(user.equipped() == holding))
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
/proc/hasvar(var/datum/A, var/varname)
|
||||
//Takes: Anything that could possibly have variables and a varname to check.
|
||||
|
||||
@@ -119,7 +119,8 @@
|
||||
src.update_status()
|
||||
|
||||
master_controller = new /datum/controller/game_controller()
|
||||
spawn(-1) master_controller.setup()
|
||||
spawn(-1)
|
||||
master_controller.setup()
|
||||
return
|
||||
|
||||
//Crispy fullban
|
||||
|
||||
@@ -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>"
|
||||
@@ -215,6 +215,7 @@
|
||||
//verbs += /proc/togglebuildmode --Merged with view variables
|
||||
//verbs += /client/proc/cmd_modify_object_variables --Merged with view variables
|
||||
verbs += /client/proc/togglebuildmodeself
|
||||
verbs += /client/proc/debug_master_controller
|
||||
else return
|
||||
|
||||
//Game Admin
|
||||
@@ -413,6 +414,7 @@
|
||||
//verbs -= /client/proc/cmd_switch_radio --removed because tcommsat is staying
|
||||
verbs -= /client/proc/togglebuildmodeself
|
||||
verbs -= /client/proc/kill_airgroup
|
||||
verbs -= /client/proc/debug_master_controller
|
||||
return
|
||||
|
||||
|
||||
|
||||
@@ -7,4 +7,14 @@
|
||||
master_controller.process()
|
||||
if("No")
|
||||
return 0
|
||||
return
|
||||
|
||||
/client/proc/debug_master_controller()
|
||||
set category = "Debug"
|
||||
set name = "Debug Master Controller"
|
||||
switch(alert("Debug Master Controller or Failsafe?" ,, "Master Controller" , "Failsafe"))
|
||||
if("Master Controller")
|
||||
debug_variables(master_controller)
|
||||
if("Failsafe")
|
||||
debug_variables(Failsafe)
|
||||
return
|
||||
@@ -938,8 +938,8 @@ note dizziness decrements automatically in the mob's Life() proc.
|
||||
stat(null, "([x], [y], [z])")
|
||||
stat(null, "CPU: [world.cpu]")
|
||||
stat(null, "Controller: [controllernum]")
|
||||
//if (master_controller)
|
||||
// stat(null, "Loop: [master_controller.loop_freq]")
|
||||
if (master_controller)
|
||||
stat(null, "Current Iteration: [controller_iteration]")
|
||||
|
||||
if (spell_list.len)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user