Resolves further merge conflicts

This commit is contained in:
Krausus
2015-08-03 23:40:28 -04:00
396 changed files with 13577 additions and 11129 deletions
@@ -57,7 +57,7 @@ var/global/datum/controller/processScheduler/processScheduler
var/process
// Add all the processes we can find, except for the ticker
for (process in typesof(/datum/controller/process) - /datum/controller/process)
for (process in subtypesof(/datum/controller/process))
if (!(process in deferredSetupList))
addProcess(new process(src))
+2 -2
View File
@@ -101,8 +101,7 @@ var/global/datum/controller/process/air_system/air_master
for(var/turf/simulated/T in turfs_in)
T.CalculateAdjacentTurfs()
if(!T.blocks_air)
if(T.air.check_tile_graphic())
T.update_visuals(T.air)
T.update_visuals()
for(var/direction in cardinal)
if(!(T.atmos_adjacent_turfs & direction))
continue
@@ -124,6 +123,7 @@ var/global/datum/controller/process/air_system/air_master
EG.breakdown_cooldown ++
if(EG.breakdown_cooldown == 10)
EG.self_breakdown()
scheck()
return
if(EG.breakdown_cooldown > 20)
EG.dismantle()
+6
View File
@@ -0,0 +1,6 @@
/datum/controller/process/alarm/setup()
name = "alarm"
schedule_interval = 20 // every 2 seconds
/datum/controller/process/alarm/doWork()
alarm_manager.fire()
+1 -1
View File
@@ -35,7 +35,7 @@ var/global/datum/controller/holiday/holiday_master //This has to be defined befo
var/MM = text2num(time2text(world.timeofday, "MM")) // get the current month
var/DD = text2num(time2text(world.timeofday, "DD")) // get the current day
for(var/H in typesof(/datum/holiday) - /datum/holiday)
for(var/H in subtypesof(/datum/holiday))
var/datum/holiday/holiday = new H()
if(holiday.shouldCelebrate(DD, MM, YY))
holiday.celebrate()
+18 -2
View File
@@ -1,3 +1,5 @@
/var/global/machinery_sort_required = 0
/datum/controller/process/machinery/setup()
name = "machinery"
schedule_interval = 20 // every 2 seconds
@@ -9,9 +11,16 @@
stat(null, "[powernets.len] powernets")
/datum/controller/process/machinery/doWork()
process_sort()
process_power()
process_power_drain()
process_machines()
/datum/controller/process/machinery/proc/process_sort()
if(machinery_sort_required)
machinery_sort_required = 0
machines = dd_sortedObjectList(machines)
/datum/controller/process/machinery/proc/process_machines()
for(var/obj/machinery/M in machines)
if(M && isnull(M.gcDestroyed))
@@ -53,5 +62,12 @@
// Use src explicitly after a try/catch, or BYOND messes src up. I have no idea why.
src.scheck()
continue
else
powernets -= powerNetwork
powernets.Remove(powerNetwork)
/datum/controller/process/machinery/proc/process_power_drain()
// Currently only used by powersinks. These items get priority processed before machinery
for(var/obj/item/I in processing_power_items)
if(!I.pwr_drain()) // 0 = Process Kill, remove from processing list.
processing_power_items.Remove(I)
scheck()
+3 -3
View File
@@ -161,7 +161,7 @@
var/list/overflow_whitelist = list() //whitelist for overflow
/datum/configuration/New()
var/list/L = typesof(/datum/game_mode) - /datum/game_mode
var/list/L = subtypesof(/datum/game_mode)
for (var/T in L)
// I wish I didn't have to instance the game modes in order to look up
// their information, but it is the only way (at least that I know of).
@@ -688,7 +688,7 @@
/datum/configuration/proc/pick_mode(mode_name)
// I wish I didn't have to instance the game modes in order to look up
// their information, but it is the only way (at least that I know of).
for (var/T in (typesof(/datum/game_mode) - /datum/game_mode))
for (var/T in subtypesof(/datum/game_mode))
var/datum/game_mode/M = new T()
if (M.config_tag && M.config_tag == mode_name)
return M
@@ -697,7 +697,7 @@
/datum/configuration/proc/get_runnable_modes()
var/list/datum/game_mode/runnable_modes = new
for (var/T in (typesof(/datum/game_mode) - /datum/game_mode))
for (var/T in subtypesof(/datum/game_mode))
var/datum/game_mode/M = new T()
//world << "DEBUG: [T], tag=[M.config_tag], prob=[probabilities[M.config_tag]]"
if (!(M.config_tag in modes))
+1 -19
View File
@@ -25,7 +25,7 @@ var/global/datum/controller/failsafe/failsafe
failsafe = src
failsafe.process()
//failsafe.process()
/datum/controller/failsafe/proc/process()
processing = 1
@@ -36,22 +36,4 @@ var/global/datum/controller/failsafe/failsafe
while(1) // More efficient than recursivly calling ourself over and over. background = 1 ensures we do not trigger an infinite loop.
iteration++
if(processing)
if(master_controller.processing) // Only poke if these overrides aren't in effect
if(masterControllerIteration == master_controller.iteration) // Master controller hasn't finished processing in the defined interval.
switch(masterControllerAlertLevel)
if(0 to 3)
masterControllerAlertLevel++
if(4)
admins << "<font color='red' size='2'><b>Warning. The master Controller has not fired in the last [masterControllerAlertLevel * processing_interval] ticks. Automatic restart in [processing_interval] ticks.</b></font>"
masterControllerAlertLevel = 5
if(5)
admins << "<font color='red' size='2'><b>Warning. The master Controller has still not fired within the last [masterControllerAlertLevel * processing_interval] ticks. Killing and restarting...</b></font>"
new /datum/controller/game_controller() // Replace the old master controller (hence killing the old one's process).
master_controller.process() // Start it rolling again.
masterControllerAlertLevel = 0
else
masterControllerAlertLevel = 0
masterControllerIteration = master_controller.iteration
sleep(processing_interval)
+1 -285
View File
@@ -18,35 +18,12 @@ var/global/pipe_processing_killed = 0
/datum/controller/proc/recover() // If we are replacing an existing controller (due to a crash) we attempt to preserve as much as we can.
datum/controller/game_controller
var/breather_ticks = 2 //a somewhat crude attempt to iron over the 'bumps' caused by high-cpu use by letting the MC have a breather for this many ticks after every loop
var/minimum_ticks = 20 //The minimum length of time between MC ticks
var/air_cost = 0
var/sun_cost = 0
var/mobs_cost = 0
var/diseases_cost = 0
var/machines_cost = 0
var/aibots_cost = 0
var/objects_cost = 0
var/networks_cost = 0
var/powernets_cost = 0
var/nano_cost = 0
var/events_cost = 0
var/puddles_cost
var/ticker_cost = 0
var/garbageCollectorCost = 0
var/total_cost = 0
var/last_thing_processed
var/list/shuttle_list // For debugging and VV
var/datum/ore_distribution/asteroid_ore_map // For debugging and VV.
datum/controller/game_controller/New()
//There can be only one master_controller. Out with the old and in with the new.
if(master_controller != src)
if(istype(master_controller))
Recover()
del(master_controller)
master_controller = src
@@ -58,8 +35,6 @@ datum/controller/game_controller/New()
if(!syndicate_code_phrase) syndicate_code_phrase = generate_code_phrase()
if(!syndicate_code_response) syndicate_code_response = generate_code_phrase()
//if(!emergency_shuttle) emergency_shuttle = new /datum/emergency_shuttle_controller() MOVED TO SCHEDULER
//if(!shuttle_controller) shuttle_controller = new /datum/shuttle_controller()
datum/controller/game_controller/proc/setup()
world.tick_lag = config.Ticklag
@@ -67,35 +42,17 @@ datum/controller/game_controller/proc/setup()
spawn(20)
createRandomZlevel()
/* MOVED TO SCHEDULER
if(!air_master)
air_master = new /datum/controller/air_system()
air_master.Setup()
if(!ticker)
ticker = new /datum/controller/gameticker()
*/
setup_objects()
setup_starlight()
setupgenetics()
setupfactions()
setup_economy()
SetupXenoarch()
//SetupXenoarch()
for(var/i=0, i<max_secret_rooms, i++)
make_mining_asteroid_secret()
populate_spawn_points()
/* MOVED TO SCHEDULER
spawn(0)
if(ticker)
ticker.pregame()
lighting_controller.Initialize()
*/
datum/controller/game_controller/proc/setup_objects()
world << "\red \b Initializing objects"
@@ -118,14 +75,6 @@ datum/controller/game_controller/proc/setup_objects()
var/obj/machinery/atmospherics/unary/vent_scrubber/T = U
T.broadcast_status()
//Create the mining ore distribution map.
asteroid_ore_map = new /datum/ore_distribution()
asteroid_ore_map.populate_distribution_map()
//Set up roundstart seed list.
//populate_seed_list()
world << "\red \b Initializations complete."
sleep(-1)
@@ -134,236 +83,3 @@ datum/controller/game_controller/proc/setup_starlight()
for(var/turf/space/S in world)
S.update_starlight()
world << "\red \b Starlight Initilization Complete"
datum/controller/game_controller/proc/process()
processing = 1
spawn(0)
//set background = 1
while(1) //far more efficient than recursively calling ourself
if(!failsafe) new /datum/controller/failsafe()
if(processing)
var/timer
var/start_time = world.timeofday
controller_iteration++
vote.process()
// transfer_controller.process()
shuttle_controller.process()
process_newscaster()
//AIR
if(!air_processing_killed)
timer = world.timeofday
last_thing_processed = air_master.type
air_master.current_cycle++
// if(!air_master.tick()) Runtimed.
if(!air_master.process())
air_master.failed_ticks++
if(air_master.failed_ticks > 5)
world << "<font color='red'><b>RUNTIMES IN ATMOS TICKER. Killing air simulation!</font></b>"
world.log << "### LINDA SHUTDOWN"
message_admins("LINDAALERT: unable to run [air_master.tick_progress], shutting down!")
log_admin("LINDAALERT: unable run zone/process() -- [air_master.tick_progress]")
air_processing_killed = 1
air_master.failed_ticks = 0
air_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//SUN
timer = world.timeofday
last_thing_processed = sun.type
sun.calc_position()
sun_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//MOBS
timer = world.timeofday
processMobs()
mobs_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//MACHINES
timer = world.timeofday
processMachines()
machines_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//BOTS
timer = world.timeofday
process_bots()
aibots_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//OBJECTS
timer = world.timeofday
processObjects()
objects_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//PIPENETS
if(!pipe_processing_killed)
timer = world.timeofday
processPipenets()
networks_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//POWERNETS
timer = world.timeofday
processPowernets()
powernets_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//NANO UIS
timer = world.timeofday
processNano()
nano_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//EVENTS
timer = world.timeofday
processEvents()
events_cost = (world.timeofday - timer) / 10
/*
//PUDDLES
timer = world.timeofday
processPuddles()
puddles_cost = (world.timeofday - timer) / 10
*/
//TICKER
timer = world.timeofday
last_thing_processed = ticker.type
ticker.process()
ticker_cost = (world.timeofday - timer) / 10
// GC
timer = world.timeofday
last_thing_processed = garbageCollector.type
garbageCollector.processGarbage()
garbageCollectorCost = (world.timeofday - timer) / 10
//TIMING
total_cost = air_cost + sun_cost + mobs_cost + diseases_cost + machines_cost + aibots_cost + objects_cost + networks_cost + powernets_cost + nano_cost + events_cost + puddles_cost + ticker_cost + garbageCollectorCost
var/end_time = world.timeofday
if(end_time < start_time) //why not just use world.time instead?
start_time -= 864000 //deciseconds in a day
sleep( round(minimum_ticks - (end_time - start_time),1) )
else
sleep(10)
/datum/controller/game_controller/proc/processMobs()
for (var/mob/Mob in mob_list)
if (Mob)
last_thing_processed = Mob.type
Mob.Life()
continue
mob_list = mob_list - Mob
/datum/controller/game_controller/proc/processMachines()
for (var/obj/machinery/Machinery in machines)
if (Machinery && Machinery.loc)
last_thing_processed = Machinery.type
if(Machinery.process() != PROCESS_KILL)
if (Machinery) // Why another check?
if (Machinery.use_power)
Machinery.auto_use_power()
continue
if(Machinery) Machinery.removeAtProcessing()
/datum/controller/game_controller/proc/process_bots()
for(var/obj/machinery/bot/Bot in aibots)
if(Bot && isnull(Bot.gcDestroyed))
last_thing_processed = Bot.type
spawn(0)
Bot.bot_process()
continue
else
aibots -= Bot
/datum/controller/game_controller/proc/processObjects()
for (var/obj/Object in processing_objects)
if (Object && Object.loc)
last_thing_processed = Object.type
Object.process()
continue
processing_objects -= Object
/datum/controller/game_controller/proc/processPipenets()
last_thing_processed = /datum/pipe_network
for (var/datum/pipe_network/Pipe_Network in pipe_networks)
if(Pipe_Network)
Pipe_Network.process()
continue
pipe_networks -= Pipe_Network
/datum/controller/game_controller/proc/processPowernets()
last_thing_processed = /datum/powernet
for (var/datum/powernet/Powernet in powernets)
if (Powernet)
Powernet.reset()
continue
powernets -= Powernet
/datum/controller/game_controller/proc/processNano()
last_thing_processed = /datum/nanoui
for (var/datum/nanoui/Nanoui in nanomanager.processing_uis)
if (Nanoui)
Nanoui.process()
continue
nanomanager.processing_uis -= Nanoui
/datum/controller/game_controller/proc/processEvents()
last_thing_processed = /datum/event
event_manager.process()
/*
/datum/controller/game_controller/proc/processPuddles()
last_thing_processed = /datum/puddle
for (var/datum/puddle/Puddle in puddles)
if (Puddle)
Puddle.process()
continue
*/
datum/controller/game_controller/proc/Recover() //Mostly a placeholder for now.
var/msg = "## DEBUG: [time2text(world.timeofday)] MC restarted. Reports:\n"
for(var/varname in master_controller.vars)
switch(varname)
if("tag","bestF","type","parent_type","vars") continue
else
var/varval = master_controller.vars[varname]
if(istype(varval,/datum))
var/datum/D = varval
msg += "\t [varname] = [D.type]\n"
else
msg += "\t [varname] = [varval]\n"
world.log << msg
+30
View File
@@ -0,0 +1,30 @@
// We manually initialize the alarm handlers instead of looping over all existing types
// to make it possible to write: camera.triggerAlarm() rather than alarm_manager.managers[datum/alarm_handler/camera].triggerAlarm() or a variant thereof.
/var/global/datum/alarm_handler/atmosphere/atmosphere_alarm = new()
/var/global/datum/alarm_handler/camera/camera_alarm = new()
/var/global/datum/alarm_handler/fire/fire_alarm = new()
/var/global/datum/alarm_handler/motion/motion_alarm = new()
/var/global/datum/alarm_handler/power/power_alarm = new()
/datum/subsystem/alarm
name = "Alarm"
var/list/datum/alarm/all_handlers
/datum/subsystem/alarm/New()
all_handlers = list(atmosphere_alarm, camera_alarm, fire_alarm, motion_alarm, power_alarm)
/datum/subsystem/alarm/fire()
for(var/datum/alarm_handler/AH in all_handlers)
AH.process()
/datum/subsystem/alarm/proc/active_alarms()
var/list/all_alarms = new
for(var/datum/alarm_handler/AH in all_handlers)
var/list/alarms = AH.alarms
all_alarms += alarms
return all_alarms
/datum/subsystem/alarm/proc/number_of_active_alarms()
var/list/alarms = active_alarms()
return alarms.len
+46
View File
@@ -0,0 +1,46 @@
#define NEW_SS_GLOBAL(varname) if(varname != src){if(istype(varname)){Recover();qdel(varname);}varname = src;}
/datum/subsystem
//things you will want to define
var/name //name of the subsystem
var/priority = 0 //priority affects order of initialization. Higher priorities are initialized first, lower priorities later. Can be decimal and negative values.
var/wait = 20 //time to wait (in deciseconds) between each call to fire(). Must be a positive integer.
//things you will probably want to leave alone
var/can_fire = 0 //prevent fire() calls
var/last_fire = 0 //last world.time we called fire()
var/next_fire = 0 //scheduled world.time for next fire()
var/cpu = 0 //cpu-usage stats (somewhat vague)
var/cost = 0 //average time to execute
var/times_fired = 0 //number of times we have called fire()
//used to initialize the subsystem BEFORE the map has loaded
/datum/subsystem/New()
//previously, this would have been named 'process()' but that name is used everywhere for different things!
//fire() seems more suitable. This is the procedure that gets called every 'wait' deciseconds.
//fire(), and the procs it calls, SHOULD NOT HAVE ANY SLEEP OPERATIONS in them!
//YE BE WARNED!
/datum/subsystem/proc/fire()
can_fire = 0
//used to initialize the subsystem AFTER the map has loaded
/datum/subsystem/proc/Initialize(start_timeofday)
var/time = (world.timeofday - start_timeofday) / 10
var/msg = "Initialized [name] SubSystem within [time] seconds"
world << "<span class='userdanger'>[msg]</span>"
world.log << msg
//hook for printing stats to the "MC" statuspanel for admins to see performance and related stats etc.
/datum/subsystem/proc/stat_entry()
stat(name, "[round(cost,0.001)]ds\t(CPU:[round(cpu,1)]%)")
//could be used to postpone a costly subsystem for one cycle
//for instance, during cpu intensive operations like explosions
/datum/subsystem/proc/postpone()
if(next_fire - world.time < wait)
next_fire += wait
//usually called via datum/subsystem/New() when replacing a subsystem (i.e. due to a recurring crash)
//should attempt to salvage what it can from the old instance of subsystem
/datum/subsystem/proc/Recover()
+7 -25
View File
@@ -1,26 +1,6 @@
//TODO: rewrite and standardise all controller datums to the datum/controller type
//TODO: allow all controllers to be deleted for clean restarts (see WIP master controller stuff) - MC done - lighting done
/client/proc/show_distribution_map()
set category = "Debug"
set name = "Show Distribution Map"
set desc = "Print the asteroid ore distribution map to the world."
if(!holder) return
if(master_controller && master_controller.asteroid_ore_map)
master_controller.asteroid_ore_map.print_distribution_map()
/client/proc/remake_distribution_map()
set category = "Debug"
set name = "Remake Distribution Map"
set desc = "Rebuild the asteroid ore distribution map."
if(!holder) return
if(master_controller && master_controller.asteroid_ore_map)
master_controller.asteroid_ore_map = new /datum/ore_distribution()
master_controller.asteroid_ore_map.populate_distribution_map()
/client/proc/restart_controller(controller in list("Master","Failsafe","Supply"))
set category = "Debug"
@@ -31,10 +11,6 @@
usr = null
src = null
switch(controller)
if("Master")
new /datum/controller/game_controller()
master_controller.process()
feedback_add_details("admin_verb","RMC")
if("Failsafe")
new /datum/controller/failsafe()
feedback_add_details("admin_verb","RFailsafe")
@@ -45,7 +21,7 @@
return
/client/proc/debug_controller(controller in list("Master","failsafe","Ticker","Air","Lighting","Jobs","Sun","Radio","Supply","Shuttles","Emergency Shuttle","Configuration","pAI", "Cameras","Garbage", "Transfer Controller","Event","Scheduler"))
/client/proc/debug_controller(controller in list("Master","failsafe","Ticker","Air","Lighting","Jobs","Sun","Radio","Supply","Shuttles","Emergency Shuttle","Configuration","pAI", "Cameras","Garbage", "Transfer Controller","Event","Alarm","Scheduler"))
set category = "Debug"
set name = "Debug Controller"
set desc = "Debug the various periodic loop controllers for the game (be careful!)"
@@ -97,12 +73,18 @@
if("Event")
debug_variables(event_manager)
feedback_add_details("admin_verb","DEvent")
if("Alarm")
debug_variables(alarm_manager)
feedback_add_details("admin_verb", "DAlarm")
if("Garbage")
debug_variables(garbageCollector)
feedback_add_details("admin_verb","DGarbage")
if("Scheduler")
debug_variables(processScheduler)
feedback_add_details("admin_verb","DprocessScheduler")
if("Nano")
debug_variables(nanomanager)
feedback_add_details("admin_verb","DNano")
message_admins("Admin [key_name_admin(usr)] is debugging the [controller] controller.")
return