mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +00:00
Unary Vent Pump Optimizations.
We have like 250 of these on the map, each one calculates the atmospheric properties of the air around it each tick. 99% of the time this isn't even needed. So...if it's not needed this tick we hibernate for 5 to 10 ticks before checking again.
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
var/area_uid
|
var/area_uid
|
||||||
var/id_tag = null
|
var/id_tag = null
|
||||||
|
|
||||||
|
var/hibernate = 0 //Do we even process?
|
||||||
var/on = 0
|
var/on = 0
|
||||||
var/pump_direction = 1 //0 = siphoning, 1 = releasing
|
var/pump_direction = 1 //0 = siphoning, 1 = releasing
|
||||||
|
|
||||||
@@ -153,6 +154,9 @@
|
|||||||
/obj/machinery/atmospherics/unary/vent_pump/process()
|
/obj/machinery/atmospherics/unary/vent_pump/process()
|
||||||
..()
|
..()
|
||||||
|
|
||||||
|
if (hibernate)
|
||||||
|
return 1
|
||||||
|
|
||||||
if (!node)
|
if (!node)
|
||||||
on = 0
|
on = 0
|
||||||
if(!can_pump())
|
if(!can_pump())
|
||||||
@@ -186,6 +190,16 @@
|
|||||||
transfer_moles = min(transfer_moles, environment.total_moles*air_contents.volume/environment.volume) //group_multiplier gets divided out here
|
transfer_moles = min(transfer_moles, environment.total_moles*air_contents.volume/environment.volume) //group_multiplier gets divided out here
|
||||||
|
|
||||||
power_draw = pump_gas(src, environment, air_contents, transfer_moles, active_power_usage)
|
power_draw = pump_gas(src, environment, air_contents, transfer_moles, active_power_usage)
|
||||||
|
else
|
||||||
|
//If we're in an area that is fucking ideal, and we don't have to do anything, chances are we won't next tick either so why redo these calculations?
|
||||||
|
//JESUS FUCK. THERE ARE LITERALLY 250 OF YOU MOTHERFUCKERS ON ZLEVEL ONE AND YOU DO THIS SHIT EVERY TICK WHEN VERY OFTEN THERE IS NO REASON TO
|
||||||
|
|
||||||
|
if(pump_direction && pressure_checks == PRESSURE_CHECK_EXTERNAL && controller_iteration > 10) //99% of all vents
|
||||||
|
//Fucking hibernate because you ain't doing shit.
|
||||||
|
hibernate = 1
|
||||||
|
spawn(rand(100,200)) //hibernate for 10 or 20 seconds randomly
|
||||||
|
hibernate = 0
|
||||||
|
|
||||||
|
|
||||||
if (power_draw < 0)
|
if (power_draw < 0)
|
||||||
last_power_draw = 0
|
last_power_draw = 0
|
||||||
@@ -270,6 +284,9 @@
|
|||||||
/obj/machinery/atmospherics/unary/vent_pump/receive_signal(datum/signal/signal)
|
/obj/machinery/atmospherics/unary/vent_pump/receive_signal(datum/signal/signal)
|
||||||
if(stat & (NOPOWER|BROKEN))
|
if(stat & (NOPOWER|BROKEN))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
hibernate = 0
|
||||||
|
|
||||||
//log_admin("DEBUG \[[world.timeofday]\]: /obj/machinery/atmospherics/unary/vent_pump/receive_signal([signal.debug_print()])")
|
//log_admin("DEBUG \[[world.timeofday]\]: /obj/machinery/atmospherics/unary/vent_pump/receive_signal([signal.debug_print()])")
|
||||||
if(!signal.data["tag"] || (signal.data["tag"] != id_tag) || (signal.data["sigtype"]!="command"))
|
if(!signal.data["tag"] || (signal.data["tag"] != id_tag) || (signal.data["sigtype"]!="command"))
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user