Kill airlocks' process(), SSpower, and misc. performance tweaks (#2175)

changes:

Airlocks no longer tick (exceptions: firedoors, uranium airlocks)
Airlock commands run before round-start are queued to run at round-start.
Airlock commands that failed to run are scheduled to try again in 2 seconds with timers.
Callbacks can now be registered with SSticker to run at round-start in a non-blocking way.
Added a new subsystem (SSpower) for handling power-related functions. Currently doesn't do a whole lot, but this will likely eventually change.
RCON functionality has been moved from SSmachinery to SSpower.
The global cable list has been moved into SSpower.
Powernet sensors no longer process purely to keep themselves in the global machines list, instead they are added to a list in SSpower.
Power terminals no longer pointlessly tick.
Removed some variables from SSticker that weren't used by anything.
Holographic overlays such as those used by consoles are now cached.
Xenoarcheology setup is now tick-checked.
ZAS now uses post-fire timing.
The req_access and req_one_access lists are no longer initialized by default on all /obj types.
Openturfs will only emit starlight if they are bordering a non-openturf dynamically lit turf.
Powernets are now stored in SSpower instead of being a global.
The global mouse list is now stored in SSmob instead of being a global.
Fixed some weirdness in APCs' Destroy() caused by a merge.
SSwireless now pre-bakes to reduce round-start processing.
SSwireless no longer uses processing queues.
This commit is contained in:
Lohikar
2017-05-11 14:19:51 -05:00
committed by skull132
parent b52e374df3
commit 6ef9191275
37 changed files with 318 additions and 234 deletions

View File

@@ -184,18 +184,14 @@
area.power_equip = 0
area.power_environ = 0
area.power_change()
qdel(wires)
wires = null
qdel(terminal)
terminal = null
QDEL_NULL(wires)
QDEL_NULL(terminal)
if(cell)
cell.forceMove(loc)
cell = null
QDEL_NULL(spark_system)
QDEL_NULL(spark_system)
// Malf AI, removes the APC from AI's hacked APCs list.
if((hacker) && (hacker.hacked_apcs) && (src in hacker.hacked_apcs))
hacker.hacked_apcs -= src

View File

@@ -21,11 +21,11 @@
var/update_locked = 0
/obj/machinery/power/breakerbox/Initialize()
LAZYADD(SSmachinery.breaker_boxes, src)
LAZYADD(SSpower.breaker_boxes, src)
return ..()
/obj/machinery/power/breakerbox/Destroy()
LAZYREMOVE(SSmachinery.breaker_boxes, src)
LAZYREMOVE(SSpower.breaker_boxes, src)
SSmachinery.queue_rcon_update()
return ..()

View File

@@ -90,13 +90,13 @@ var/list/possible_cable_coil_colours = list(
var/turf/T = src.loc // hide if turf is not intact
if(level==1) hide(!T.is_plating())
cable_list += src //add it to the global cable list
SSpower.all_cables += src //add it to the global cable list
/obj/structure/cable/Destroy() // called when a cable is deleted
if(powernet)
cut_cable_from_powernet() // update the powernets
cable_list -= src //remove it from global cable list
SSpower.all_cables -= src //remove it from global cable list
return ..() // then go ahead and delete the cable
///////////////////////////////////

View File

@@ -159,7 +159,6 @@
// this is used to calc the probability the light burns out
var/rigged = 0 // true if rigged to explode
var/datum/effect_system/sparks/spark_system
// the smaller bulb light fixture
@@ -205,7 +204,6 @@
// create a new lighting fixture
/obj/machinery/light/Initialize(mapload)
. = ..()
spark_system = bind_spark(src, 3)
on = has_power()
switch(fitting)
@@ -222,7 +220,6 @@
var/area/A = get_area(src)
if(A)
on = 0
QDEL_NULL(spark_system)
return ..()
/obj/machinery/light/update_icon()
@@ -411,7 +408,7 @@
user << "You stick \the [W] into the light socket!"
if(has_power() && (W.flags & CONDUCT))
spark_system.queue()
spark(src, 3)
//if(!user.mutations & COLD_RESISTANCE)
if (prob(75))
electrocute_mob(user, get_area(src), src, rand(0.7,1.0))
@@ -553,7 +550,7 @@
if(status == LIGHT_OK || status == LIGHT_BURNED)
playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1)
if(on)
spark_system.queue()
spark(src, 3)
status = LIGHT_BROKEN
update()
CHECK_TICK // For lights-out events.

View File

@@ -237,13 +237,15 @@
. += C
return .
// rebuild all power networks from scratch - only called at world creation or by the admin verb
// rebuild all power networks from scratch - called by area movement, world start, & by an admin verb.
/proc/makepowernets()
var/list/powernets = SSpower.powernets
for(var/datum/powernet/PN in powernets)
qdel(PN)
powernets.Cut()
for(var/obj/structure/cable/PC in cable_list)
for(var/thing in SSpower.all_cables)
var/obj/structure/cable/PC = thing
if(!PC.powernet)
var/datum/powernet/NewPN = new()
NewPN.add_cable(PC)

View File

@@ -21,7 +21,7 @@
var/problem = 0 // If this is not 0 there is some sort of issue in the powernet. Monitors will display warnings.
/datum/powernet/New()
powernets += src
SSpower.powernets += src
..()
/datum/powernet/Destroy()
@@ -31,7 +31,7 @@
for(var/obj/machinery/power/M in nodes)
nodes -= M
M.powernet = null
powernets -= src
SSpower.powernets -= src
return ..()
//Returns the amount of excess power (before refunding to SMESs) from last tick.

View File

@@ -25,6 +25,11 @@
/obj/machinery/power/sensor/Initialize()
. = ..()
auto_set_name()
SSpower.all_sensors += src
/obj/machinery/power/sensor/Destroy()
. = ..()
SSpower.all_sensors -= src
// Proc: auto_set_name()
// Parameters: None
@@ -42,12 +47,6 @@
return 1
return 0
// Proc: process()
// Parameters: None
// Description: This has to be here because we need sensors to remain in Machines list.
/obj/machinery/power/sensor/process()
return 1
// Proc: reading_to_text()
// Parameters: 1 (amount - Power in Watts to be converted to W, kW or MW)
// Description: Helper proc that converts reading in Watts to kW or MW (returns string version of amount parameter)

View File

@@ -51,7 +51,7 @@ var/global/list/rad_collectors = list()
else
user << "\red The controls are locked!"
return
..()
..()
/obj/machinery/power/rad_collector/attackby(obj/item/W, mob/user)

View File

@@ -30,8 +30,3 @@
/obj/machinery/power/terminal/hide(var/i)
invisibility = i ? 101 : initial(invisibility)
icon_state = i ? "term-f" : "term"
// Needed so terminals are not removed from machines list.
// Powernet rebuilds need this to work properly.
/obj/machinery/power/terminal/process()
return 1