Port missing PR - [MIRROR]SSmachines optimizations (#5403)

* Update Fire.dm

* Update machines.dm

* Update fuel.dm
This commit is contained in:
Razgriz
2022-12-15 21:49:31 -07:00
committed by GitHub
parent 2cbe1726a1
commit 120047e124
3 changed files with 27 additions and 25 deletions

View File

@@ -170,7 +170,7 @@ If it gains pressure too slowly, it may leak or just rupture instead of explodin
continue continue
//Spread the fire. //Spread the fire.
if(prob( 50 + 50 * (firelevel/vsc.fire_firelevel_multiplier) ) && my_tile.CanPass(src, enemy_tile, 0,0) && enemy_tile.CanPass(src, my_tile, 0,0)) if(prob( 50 + 50 * (firelevel/vsc.fire_firelevel_multiplier) ) && my_tile.CanPass(src, enemy_tile) && enemy_tile.CanPass(src, my_tile))
enemy_tile.create_fire(firelevel) enemy_tile.create_fire(firelevel)
else else

View File

@@ -6,9 +6,6 @@
// //
// SSmachines subsystem - Processing machines, pipenets, and powernets! // SSmachines subsystem - Processing machines, pipenets, and powernets!
// //
// Implementation Plan:
// PHASE 1 - Add subsystem using the existing global list vars
// PHASE 2 - Move the global list vars into the subsystem.
SUBSYSTEM_DEF(machines) SUBSYSTEM_DEF(machines)
name = "Machines" name = "Machines"
@@ -24,12 +21,6 @@ SUBSYSTEM_DEF(machines)
var/cost_powernets = 0 var/cost_powernets = 0
var/cost_power_objects = 0 var/cost_power_objects = 0
// TODO - PHASE 2 - Switch these from globals to instance vars
// var/list/pipenets = list()
// var/list/machinery = list()
// var/list/powernets = list()
// var/list/power_objects = list()
var/list/current_run = list() var/list/current_run = list()
/datum/controller/subsystem/machines/Initialize(timeofday) /datum/controller/subsystem/machines/Initialize(timeofday)
@@ -51,28 +42,31 @@ SUBSYSTEM_DEF(machines)
// The above is a lie. Turbolifts also call this proc. // The above is a lie. Turbolifts also call this proc.
/datum/controller/subsystem/machines/proc/makepowernets() /datum/controller/subsystem/machines/proc/makepowernets()
// TODO - check to not run while in the middle of a tick! // TODO - check to not run while in the middle of a tick!
for(var/datum/powernet/PN in powernets) for(var/datum/powernet/PN as anything in powernets)
qdel(PN) qdel(PN)
powernets.Cut() powernets.Cut()
setup_powernets_for_cables(cable_list) setup_powernets_for_cables(cable_list)
/datum/controller/subsystem/machines/proc/setup_powernets_for_cables(list/cables) /datum/controller/subsystem/machines/proc/setup_powernets_for_cables(list/cables)
for(var/obj/structure/cable/PC in cables) for(var/obj/structure/cable/PC as anything in cables)
if(!PC.powernet) if(!PC.powernet)
var/datum/powernet/NewPN = new() var/datum/powernet/NewPN = new()
NewPN.add_cable(PC) NewPN.add_cable(PC)
propagate_network(PC,PC.powernet) propagate_network(PC,PC.powernet)
/datum/controller/subsystem/machines/proc/setup_atmos_machinery(list/atmos_machines) /datum/controller/subsystem/machines/proc/setup_atmos_machinery(list/atmos_machines)
for(var/obj/machinery/atmospherics/machine in atmos_machines) var/list/actual_atmos_machines = list()
machine.atmos_init()
CHECK_TICK
for(var/obj/machinery/atmospherics/machine in atmos_machines) for(var/obj/machinery/atmospherics/machine in atmos_machines)
machine.atmos_init()
actual_atmos_machines += machine
CHECK_TICK
for(var/obj/machinery/atmospherics/machine as anything in actual_atmos_machines)
machine.build_network() machine.build_network()
CHECK_TICK CHECK_TICK
for(var/obj/machinery/atmospherics/unary/U in atmos_machines) for(var/obj/machinery/atmospherics/unary/U as anything in actual_atmos_machines)
if(istype(U, /obj/machinery/atmospherics/unary/vent_pump)) if(istype(U, /obj/machinery/atmospherics/unary/vent_pump))
var/obj/machinery/atmospherics/unary/vent_pump/T = U var/obj/machinery/atmospherics/unary/vent_pump/T = U
T.broadcast_status() T.broadcast_status()
@@ -163,16 +157,24 @@ SUBSYSTEM_DEF(machines)
return return
/datum/controller/subsystem/machines/Recover() /datum/controller/subsystem/machines/Recover()
// TODO - PHASE 2 for(var/datum/D as anything in global.pipe_networks)
// if (istype(SSmachines.pipenets)) if(!istype(D, /datum/pipe_network))
// pipenets = SSmachines.pipenets error("Found wrong type during SSmachinery recovery: list=global.pipe_networks, item=[D], type=[D?.type]")
// if (istype(SSmachines.machinery)) global.pipe_networks -= D
// machinery = SSmachines.machinery for(var/datum/D as anything in global.processing_machines)
// if (istype(SSmachines.powernets)) if(!istype(D, /obj/machinery))
// powernets = SSmachines.powernets error("Found wrong type during SSmachinery recovery: list=global.processing_machines, item=[D], type=[D?.type]")
// if (istype(SSmachines.power_objects)) global.processing_machines -= D
// power_objects = SSmachines.power_objects for(var/datum/D as anything in global.powernets)
if(!istype(D, /datum/powernet))
error("Found wrong type during SSmachinery recovery: list=global.powernets, item=[D], type=[D?.type]")
global.powernets -= D
for(var/datum/D as anything in global.processing_power_items)
if(!istype(D, /obj/item))
error("Found wrong type during SSmachinery recovery: list=global.processing_power_items, item=[D], type=[D?.type]")
global.processing_power_items -= D
#undef SSMACHINES_PIPENETS #undef SSMACHINES_PIPENETS
#undef SSMACHINES_MACHINERY #undef SSMACHINES_MACHINERY
#undef SSMACHINES_POWERNETS
#undef SSMACHINES_POWER_OBJECTS #undef SSMACHINES_POWER_OBJECTS

View File

@@ -38,7 +38,7 @@
for(var/d in cardinal) for(var/d in cardinal)
var/turf/simulated/target = get_step(src,d) var/turf/simulated/target = get_step(src,d)
var/turf/simulated/origin = get_turf(src) var/turf/simulated/origin = get_turf(src)
if(origin.CanPass(src, target, 0, 0) && target.CanPass(src, origin, 0, 0)) if(origin.CanPass(src, target) && target.CanPass(src, origin))
var/obj/effect/decal/cleanable/liquid_fuel/other_fuel = locate() in target var/obj/effect/decal/cleanable/liquid_fuel/other_fuel = locate() in target
if(other_fuel) if(other_fuel)
other_fuel.amount += amount*0.25 other_fuel.amount += amount*0.25
@@ -73,7 +73,7 @@
var/turf/simulated/O = get_step(S,d) var/turf/simulated/O = get_step(S,d)
if(locate(/obj/effect/decal/cleanable/liquid_fuel/flamethrower_fuel) in O) if(locate(/obj/effect/decal/cleanable/liquid_fuel/flamethrower_fuel) in O)
continue continue
if(O.CanPass(null, S, 0, 0) && S.CanPass(null, O, 0, 0)) if(O.CanPass(src, S) && S.CanPass(src, O))
var/new_pool_amount = amount * 0.25 var/new_pool_amount = amount * 0.25
if(new_pool_amount > 0.1) if(new_pool_amount > 0.1)
var/obj/effect/decal/cleanable/liquid_fuel/flamethrower_fuel/F = new(O, new_pool_amount, d) var/obj/effect/decal/cleanable/liquid_fuel/flamethrower_fuel/F = new(O, new_pool_amount, d)