From 4889b33cea75b2de1367aa0150393c4f8d13f5c4 Mon Sep 17 00:00:00 2001 From: enbyfriend <48869068+enbyfriend@users.noreply.github.com> Date: Wed, 19 Jul 2023 01:45:49 -0500 Subject: [PATCH] SSmachines instancing PR (#9080) * Consistency Pass #1 Power cells of all types are now considered stock parts Went through materials.dm and did some copy+paste work make material definitions consistent across the codebase (eg "steel" = 50 -> MAT_STEEL = 50) * Machines are now instances in SSMachines * Performance improvements by way of instancing all of SSmachines * Fixes the powersink * Revert "Consistency Pass #1" This reverts commit cbeef1b5db76aad8a58f50e8b67a2f7e642090d4. * Update machines.dm Styling changes * Update machines.dm * Update machines.dm forgot to update the doc --- code/ATMOSPHERICS/datum_pipe_network.dm | 4 +- code/ATMOSPHERICS/pipes/pipe_base.dm | 8 +- code/__defines/machinery.dm | 41 +++++---- code/controllers/subsystems/machines.dm | 85 +++++++++++-------- .../subsystems/processing/fastprocess.dm | 3 +- code/game/machinery/camera/presets.dm | 6 +- code/game/machinery/doors/airlock.dm | 6 +- code/game/machinery/machinery.dm | 40 +++++++-- code/game/machinery/syndicatebeacon.dm | 2 +- code/game/objects/items/devices/powersink.dm | 33 ++----- .../mining/machinery/machine_processing.dm | 8 +- .../mining/machinery/machine_stacking.dm | 8 +- .../mining/machinery/machine_unloading.dm | 10 +-- code/modules/power/antimatter/shielding.dm | 4 +- code/modules/power/powernet.dm | 4 +- code/modules/recycling/conveyor2.dm | 8 +- code/modules/xenobio/machinery/processor.dm | 6 +- 17 files changed, 150 insertions(+), 126 deletions(-) diff --git a/code/ATMOSPHERICS/datum_pipe_network.dm b/code/ATMOSPHERICS/datum_pipe_network.dm index a611e30a89..d7993e19f2 100644 --- a/code/ATMOSPHERICS/datum_pipe_network.dm +++ b/code/ATMOSPHERICS/datum_pipe_network.dm @@ -14,7 +14,7 @@ var/global/list/datum/pipe_network/pipe_networks = list() // TODO - Move into SS //var/datum/gas_mixture/air_transient = null /datum/pipe_network/Destroy() - STOP_PROCESSING_PIPENET(src) + STOP_PROCESSING_MACHINERY(src, SSMACHINES_PIPENETS_LIST) for(var/datum/pipeline/line_member in line_members) line_member.network = null for(var/obj/machinery/atmospherics/normal_member in normal_members) @@ -48,7 +48,7 @@ var/global/list/datum/pipe_network/pipe_networks = list() // TODO - Move into SS update_network_gases() if((normal_members.len>0)||(line_members.len>0)) - START_PROCESSING_PIPENET(src) + START_PROCESSING_MACHINERY(src, SSMACHINES_PIPENETS_LIST) else qdel(src) diff --git a/code/ATMOSPHERICS/pipes/pipe_base.dm b/code/ATMOSPHERICS/pipes/pipe_base.dm index 8e8ccb0383..f53bbdee24 100644 --- a/code/ATMOSPHERICS/pipes/pipe_base.dm +++ b/code/ATMOSPHERICS/pipes/pipe_base.dm @@ -35,9 +35,9 @@ /obj/machinery/atmospherics/pipe/proc/set_leaking(var/new_leaking) if(new_leaking && !leaking) if(!speed_process) - START_MACHINE_PROCESSING(src) + begin_processing() else - START_PROCESSING(SSfastprocess, src) + begin_speed_processing() leaking = TRUE if(parent) parent.leaks |= src @@ -45,9 +45,9 @@ parent.network.leaks |= src else if (!new_leaking && leaking) if(!speed_process) - STOP_MACHINE_PROCESSING(src) + end_processing() else - STOP_PROCESSING(SSfastprocess, src) + end_speed_processing() leaking = FALSE if(parent) parent.leaks -= src diff --git a/code/__defines/machinery.dm b/code/__defines/machinery.dm index 57caccc45f..aea27884bf 100644 --- a/code/__defines/machinery.dm +++ b/code/__defines/machinery.dm @@ -17,6 +17,11 @@ var/global/defer_powernet_rebuild = 0 // True if net rebuild will be called #define USE_POWER_IDLE 1 // Machine is using power at its idle power level #define USE_POWER_ACTIVE 2 // Machine is using power at its active power level +/// Bitflags for a machine's preferences on when it should start processing. For use with machinery's `processing_flags` var. +#define START_PROCESSING_ON_INIT (1<<0) /// Indicates the machine will automatically start processing right after it's `Initialize()` is ran. +#define START_PROCESSING_MANUALLY (1<<1) /// Machines with this flag will not start processing when it's spawned. Use this if you want to manually control when a machine starts processing. + + // Channel numbers for power. #define CURRENT_CHANNEL -1 // Passed as an argument this means "use whatever current channel is" #define EQUIP 1 @@ -139,30 +144,22 @@ var/global/list/restricted_camera_networks = list(NETWORK_ERT,NETWORK_MERCENARY, #define SUPERMATTER_EMERGENCY 5 // Integrity < 25% #define SUPERMATTER_DELAMINATING 6 // Pretty obvious. -//wIP - PORT ALL OF THESE TO SUBSYSTEMS AND GET RID OF THE WHOLE LIST PROCESS THING -// Fancy-pants START/STOP_PROCESSING() macros that lets us custom define what the list is. -#define START_PROCESSING_IN_LIST(DATUM, LIST) \ -if (!(DATUM.datum_flags & DF_ISPROCESSING)) {\ - LIST += DATUM;\ - DATUM.datum_flags |= DF_ISPROCESSING\ -} +// SSmachines categories +#define SSMACHINES_MACHINERY_LIST 0 // The default, most things processed by SSmachines are the machinery type +#define SSMACHINES_POWERNETS_LIST 1 // Powernets to be processed +#define SSMACHINES_POWEROBJS_LIST 2 // Power objects to be processed (only powersinks atm) +#define SSMACHINES_PIPENETS_LIST 3 // Pipenets to be worked through -#define STOP_PROCESSING_IN_LIST(DATUM, LIST) LIST.Remove(DATUM);DATUM.datum_flags &= ~DF_ISPROCESSING - -// Note - I would prefer these be defined machines.dm, but some are used prior in file order. ~Leshana -#define START_MACHINE_PROCESSING(Datum) START_PROCESSING_IN_LIST(Datum, global.processing_machines) -#define STOP_MACHINE_PROCESSING(Datum) STOP_PROCESSING_IN_LIST(Datum, global.processing_machines) - -#define START_PROCESSING_PIPENET(Datum) START_PROCESSING_IN_LIST(Datum, global.pipe_networks) -#define STOP_PROCESSING_PIPENET(Datum) STOP_PROCESSING_IN_LIST(Datum, global.pipe_networks) - -#define START_PROCESSING_POWERNET(Datum) START_PROCESSING_IN_LIST(Datum, global.powernets) -#define STOP_PROCESSING_POWERNET(Datum) STOP_PROCESSING_IN_LIST(Datum, global.powernets) - -#define START_PROCESSING_POWER_OBJECT(Datum) START_PROCESSING_IN_LIST(Datum, global.processing_power_items) -#define STOP_PROCESSING_POWER_OBJECT(Datum) STOP_PROCESSING_IN_LIST(Datum, global.processing_power_items) +/// Takes a datum and optionally a flag (`SSMACHINES_MACHINERY_LIST` (default), `SSMACHINES_POWERNETS_LIST`, `SSMACHINES_POWEROJBS_LIST`, `SSMACHINES_PIPENETS_LIST`) and adds that datum +/// to SSmachines +#define START_PROCESSING_MACHINERY(Datum, List) if (!(Datum.datum_flags & DF_ISPROCESSING)) {Datum.datum_flags |= DF_ISPROCESSING;SSmachines.start_processing(Datum, List)} +#define STOP_PROCESSING_MACHINERY(Datum, List) Datum.datum_flags &= ~DF_ISPROCESSING;SSmachines.stop_processing(Datum, List) +/// Takes a datum and optionally a flag (`SSMACHINES_MACHINERY_LIST` (default), `SSMACHINES_POWERNETS_LIST`, `SSMACHINES_POWEROJBS_LIST`, `SSMACHINES_PIPENETS_LIST`) and removes that datum +/// from SSmachines +#define START_SPEED_PROCESSING(Datum) if (!(Datum.datum_flags & DF_ISPROCESSING)) {Datum.datum_flags |= DF_ISPROCESSING;SSfastprocess.processing += Datum} +#define STOP_SPEED_PROCESSING(Datum) Datum.datum_flags &= ~DF_ISPROCESSING;SSfastprocess.processing -= Datum // Computer login types #define LOGIN_TYPE_NORMAL 1 #define LOGIN_TYPE_AI 2 -#define LOGIN_TYPE_ROBOT 3 \ No newline at end of file +#define LOGIN_TYPE_ROBOT 3 diff --git a/code/controllers/subsystems/machines.dm b/code/controllers/subsystems/machines.dm index f50f43fe6e..d84e832191 100644 --- a/code/controllers/subsystems/machines.dm +++ b/code/controllers/subsystems/machines.dm @@ -1,14 +1,7 @@ #define SSMACHINES_PIPENETS 1 #define SSMACHINES_MACHINERY 2 #define SSMACHINES_POWERNETS 3 -#define SSMACHINES_POWER_OBJECTS 4 - -// -// 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. +#define SSMACHINES_POWER_ITEMS 4 SUBSYSTEM_DEF(machines) name = "Machines" @@ -19,18 +12,17 @@ SUBSYSTEM_DEF(machines) var/current_step = SSMACHINES_PIPENETS - var/cost_pipenets = 0 - var/cost_machinery = 0 - var/cost_powernets = 0 - var/cost_power_objects = 0 + var/cost_pipenets = 0 + var/cost_machinery = 0 + var/cost_powernets = 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/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) makepowernets() @@ -41,10 +33,10 @@ SUBSYSTEM_DEF(machines) /datum/controller/subsystem/machines/fire(resumed, no_mc_tick) var/timer = TICK_USAGE - INTERNAL_PROCESS_STEP(SSMACHINES_POWER_OBJECTS,FALSE,process_power_objects,cost_power_objects,SSMACHINES_PIPENETS) // Higher priority, damnit + INTERNAL_PROCESS_STEP(SSMACHINES_POWER_ITEMS,FALSE,process_power_objects,cost_power_objects,SSMACHINES_PIPENETS) // Higher priority, damnit INTERNAL_PROCESS_STEP(SSMACHINES_PIPENETS,TRUE,process_pipenets,cost_pipenets,SSMACHINES_MACHINERY) INTERNAL_PROCESS_STEP(SSMACHINES_MACHINERY,FALSE,process_machinery,cost_machinery,SSMACHINES_POWERNETS) - INTERNAL_PROCESS_STEP(SSMACHINES_POWERNETS,FALSE,process_powernets,cost_powernets,SSMACHINES_POWER_OBJECTS) + INTERNAL_PROCESS_STEP(SSMACHINES_POWERNETS,FALSE,process_powernets,cost_powernets,SSMACHINES_POWER_ITEMS) // rebuild all power networks from scratch - only called at world creation or by the admin verb // The above is a lie. Turbolifts also call this proc. @@ -88,16 +80,16 @@ SUBSYSTEM_DEF(machines) msg += "PN:[round(cost_powernets,1)]|" msg += "PO:[round(cost_power_objects,1)]" msg += "} " - msg += "PI:[global.pipe_networks.len]|" - msg += "MC:[global.processing_machines.len]|" - msg += "PN:[global.powernets.len]|" - msg += "PO:[global.processing_power_items.len]|" - msg += "MC/MS:[round((cost ? global.processing_machines.len/cost_machinery : 0),0.1)]" + msg += "PI:[pipe_networks.len]|" + msg += "MC:[machinery.len]|" + msg += "PN:[powernets.len]|" + msg += "PO:[power_objects.len]|" + msg += "MC/MS:[round((cost ? machinery.len/cost_machinery : 0),0.1)]" ..(jointext(msg, null)) /datum/controller/subsystem/machines/proc/process_pipenets(resumed = 0) if (!resumed) - src.current_run = global.pipe_networks.Copy() + src.current_run = pipe_networks.Copy() //cache for sanic speed (lists are references anyways) var/list/current_run = src.current_run while(current_run.len) @@ -106,7 +98,7 @@ SUBSYSTEM_DEF(machines) if(istype(PN) && !QDELETED(PN)) PN.process(wait) else - global.pipe_networks.Remove(PN) + pipe_networks.Remove(PN) if(!QDELETED(PN)) DISABLE_BITFIELD(PN.datum_flags, DF_ISPROCESSING) if(MC_TICK_CHECK) @@ -114,7 +106,7 @@ SUBSYSTEM_DEF(machines) /datum/controller/subsystem/machines/proc/process_machinery(resumed = 0) if (!resumed) - src.current_run = global.processing_machines.Copy() + src.current_run = machines.Copy() var/list/current_run = src.current_run while(current_run.len) @@ -122,7 +114,7 @@ SUBSYSTEM_DEF(machines) current_run.len-- if(!istype(M) || QDELETED(M) || (M.process(wait) == PROCESS_KILL)) - global.processing_machines.Remove(M) + machines.Remove(M) if(!QDELETED(M)) DISABLE_BITFIELD(M.datum_flags, DF_ISPROCESSING) if(MC_TICK_CHECK) @@ -130,7 +122,7 @@ SUBSYSTEM_DEF(machines) /datum/controller/subsystem/machines/proc/process_powernets(resumed = 0) if (!resumed) - src.current_run = global.powernets.Copy() + src.current_run = powernets.Copy() var/list/current_run = src.current_run while(current_run.len) @@ -139,7 +131,7 @@ SUBSYSTEM_DEF(machines) if(istype(PN) && !QDELETED(PN)) PN.reset(wait) else - global.powernets.Remove(PN) + powernets.Remove(PN) if(!QDELETED(PN)) DISABLE_BITFIELD(PN.datum_flags, DF_ISPROCESSING) if(MC_TICK_CHECK) @@ -149,19 +141,44 @@ SUBSYSTEM_DEF(machines) // Currently only used by powersinks. These items get priority processed before machinery /datum/controller/subsystem/machines/proc/process_power_objects(resumed = 0) if (!resumed) - src.current_run = global.processing_power_items.Copy() + src.current_run = power_objects.Copy() var/list/current_run = src.current_run while(current_run.len) var/obj/item/I = current_run[current_run.len] current_run.len-- if(!I.pwr_drain(wait)) // 0 = Process Kill, remove from processing list. - global.processing_power_items.Remove(I) + power_objects.Remove(I) DISABLE_BITFIELD(I.datum_flags, DF_ISPROCESSING) if(MC_TICK_CHECK) return +/** Adds a datum to this subsystem + * + * `dat` - datum to be added + * + * `list = SSMACHINES_MACHINERY_LIST` - list to be added to, defaults to machines + */ +/datum/controller/subsystem/machines/proc/start_processing(dat, list = SSMACHINES_MACHINERY_LIST) + switch(list) + if(SSMACHINES_MACHINERY_LIST) machinery += dat + if(SSMACHINES_POWERNETS_LIST) powernets += dat + if(SSMACHINES_POWEROBJS_LIST) power_objects += dat + if(SSMACHINES_PIPENETS_LIST) pipenets += dat + +/** Removes a datum from this subsystem + * + * ```dat``` - datum to be removed + * + *```list``` = SSMACHINES_MACHINERY_LIST` - list to be removed from, defaults to machines + */ +/datum/controller/subsystem/machines/proc/stop_processing(dat, list = SSMACHINES_MACHINERY_LIST) + switch(list) + if(SSMACHINES_MACHINERY_LIST) machinery -= dat + if(SSMACHINES_POWERNETS_LIST) powernets -= dat + if(SSMACHINES_POWEROBJS_LIST) power_objects -= dat + if(SSMACHINES_PIPENETS_LIST) pipenets -= dat #undef SSMACHINES_PIPENETS #undef SSMACHINES_MACHINERY -#undef SSMACHINES_POWER_OBJECTS +#undef SSMACHINES_POWER_ITEMS diff --git a/code/controllers/subsystems/processing/fastprocess.dm b/code/controllers/subsystems/processing/fastprocess.dm index 61d28b041a..6cd18b6866 100644 --- a/code/controllers/subsystems/processing/fastprocess.dm +++ b/code/controllers/subsystems/processing/fastprocess.dm @@ -4,6 +4,7 @@ PROCESSING_SUBSYSTEM_DEF(fastprocess) name = "Fast Processing" wait = 0.2 SECONDS stat_tag = "FP" + var/list/machinery = list() /datum/controller/subsystem/processing/fastprocess/Recover() log_debug("[name] subsystem Recover().") @@ -12,4 +13,4 @@ PROCESSING_SUBSYSTEM_DEF(fastprocess) var/list/old_processing = SSfastprocess.processing.Copy() for(var/datum/D in old_processing) if(CHECK_BITFIELD(D.datum_flags, DF_ISPROCESSING)) - processing |= D \ No newline at end of file + processing |= D diff --git a/code/game/machinery/camera/presets.dm b/code/game/machinery/camera/presets.dm index 66d7916200..a56ded6d1c 100644 --- a/code/game/machinery/camera/presets.dm +++ b/code/game/machinery/camera/presets.dm @@ -171,9 +171,9 @@ var/global/list/engineering_networks = list( var/list/my_area = by_area[A.name] my_area += src var/number = my_area.len - + c_tag = "[A.name] #[number]" - + /obj/machinery/camera/autoname/Destroy() var/area/A = get_area(src) if(!A || !by_area || !by_area[A.name]) @@ -215,7 +215,7 @@ var/global/list/engineering_networks = list( return //nooooo assembly.upgrades.Add(new /obj/item/assembly/prox_sensor(assembly)) setPowerUsage() - START_MACHINE_PROCESSING(src) + begin_processing() sense_proximity(callback = /atom/proc/HasProximity) update_coverage() diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index 696fda5bb0..5e963daf08 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -643,7 +643,7 @@ About the new airlock wires panel: backup_power_lost_until = world.time + SecondsToTicks(10) if(main_power_lost_until > 0 || backup_power_lost_until > 0) - START_MACHINE_PROCESSING(src) + begin_processing() // Disable electricity if required if(electrified_until && isAllPowerLoss()) @@ -655,7 +655,7 @@ About the new airlock wires panel: backup_power_lost_until = backupPowerCablesCut() ? -1 : world.time + SecondsToTicks(60) if(backup_power_lost_until > 0) - START_MACHINE_PROCESSING(src) + begin_processing() // Disable electricity if required if(electrified_until && isAllPowerLoss()) @@ -700,7 +700,7 @@ About the new airlock wires panel: src.electrified_until = duration == -1 ? -1 : world.time + SecondsToTicks(duration) if(electrified_until > 0) - START_MACHINE_PROCESSING(src) + begin_processing() if(feedback && message) to_chat(usr,message) diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index a7ca3385ce..58fc408d44 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -113,32 +113,56 @@ Class Procs: var/obj/item/circuitboard/circuit = null var/list/materials = list() //Exclusively used for machines that take materials - lathes, fabricators etc. Honestly overdue for a whole lathe/fab refactor at some point. - var/speed_process = FALSE //If false, SSmachines. If true, SSfastprocess. + // Use the fastprocess subsystem instead of SSMachines? + var/speed_process = FALSE + // The subsystem we will be using + var/subsystem_type = /datum/controller/subsystem/machines required_dexterity = MOB_DEXTERITY_TOUCHSCREENS +/// Helper proc for telling a machine to start processing with the subsystem type that is located in its `subsystem_type` var. +/obj/machinery/proc/begin_processing() + START_PROCESSING_MACHINERY(src, SSMACHINES_MACHINERY_LIST) -/obj/machinery/Initialize(var/ml, d=0) +/// Helper proc for telling a machine to stop processing with the subsystem type that is located in its `subsystem_type` var. +/obj/machinery/proc/end_processing() + STOP_PROCESSING_MACHINERY(src, SSMACHINES_MACHINERY_LIST) + +/// Helper proc for telling a machine to start processing with the subsystem type that is located in its `subsystem_type` var. +/obj/machinery/proc/begin_speed_processing() + end_processing() + START_SPEED_PROCESSING(src) + +/// Helper proc for telling a machine to stop processing with the subsystem type that is located in its `subsystem_type` var. +/obj/machinery/proc/end_speed_processing() + STOP_SPEED_PROCESSING(src) + begin_processing() + + + +/obj/machinery/Initialize(var/ml, direction=0) . = ..() - if(d) - set_dir(d) + + if(direction) + set_dir(direction) + if(ispath(circuit)) circuit = new circuit(src) global.machines += src if(ispath(circuit)) circuit = new circuit(src) if(!speed_process) - START_MACHINE_PROCESSING(src) + START_PROCESSING_MACHINERY(src, SSMACHINES_MACHINERY_LIST) else - START_PROCESSING(SSfastprocess, src) + begin_speed_processing() if(!ml) power_change() /obj/machinery/Destroy() if(!speed_process) - STOP_MACHINE_PROCESSING(src) + STOP_PROCESSING_MACHINERY(src, SSMACHINES_MACHINERY_LIST) else - STOP_PROCESSING(SSfastprocess, src) + end_speed_processing() global.machines -= src if(component_parts) for(var/atom/A in component_parts) diff --git a/code/game/machinery/syndicatebeacon.dm b/code/game/machinery/syndicatebeacon.dm index 672d422091..99671c9c8a 100644 --- a/code/game/machinery/syndicatebeacon.dm +++ b/code/game/machinery/syndicatebeacon.dm @@ -95,7 +95,7 @@ singulo.target = src icon_state = "[icontype]1" active = 1 - START_MACHINE_PROCESSING(src) + begin_processing() if(user) to_chat(user, "You activate the beacon.") diff --git a/code/game/objects/items/devices/powersink.dm b/code/game/objects/items/devices/powersink.dm index f4413a1e3b..6756065cb4 100644 --- a/code/game/objects/items/devices/powersink.dm +++ b/code/game/objects/items/devices/powersink.dm @@ -19,14 +19,12 @@ var/power_drained = 0 // Amount of power drained. var/max_power = 1e9 // Detonation point. var/mode = 0 // 0 = off, 1=clamped (off), 2=operating - var/drained_this_tick = 0 // This is unfortunately necessary to ensure we process powersinks BEFORE other machinery such as APCs. - var/datum/powernet/PN // Our powernet var/obj/structure/cable/attached // the attached cable + /obj/item/powersink/Destroy() - STOP_PROCESSING(SSobj, src) - STOP_PROCESSING_POWER_OBJECT(src) + STOP_PROCESSING_MACHINERY(src, SSMACHINES_POWEROBJS_LIST) ..() /obj/item/powersink/attackby(var/obj/item/I, var/mob/user) @@ -49,8 +47,7 @@ return else if (mode == 2) - STOP_PROCESSING(SSobj, src) // Now the power sink actually stops draining the station's power if you unhook it. --NeoFite - STOP_PROCESSING_POWER_OBJECT(src) + START_PROCESSING_MACHINERY(src, SSMACHINES_POWEROBJS_LIST) anchored = 0 mode = 0 src.visible_message("[user] detaches [src] from the cable!") @@ -73,38 +70,31 @@ src.visible_message("[user] activates [src]!") mode = 2 icon_state = "powersink1" - START_PROCESSING(SSobj, src) - datum_flags &= ~DF_ISPROCESSING // Have to reset this flag so that PROCESSING_POWER_OBJECT can re-add it. It fails if the flag is already present. - Ater - START_PROCESSING_POWER_OBJECT(src) + START_PROCESSING_MACHINERY(src, SSMACHINES_POWEROBJS_LIST) if(2) //This switch option wasn't originally included. It exists now. --NeoFite src.visible_message("[user] deactivates [src]!") mode = 1 set_light(0) icon_state = "powersink0" - STOP_PROCESSING(SSobj, src) - STOP_PROCESSING_POWER_OBJECT(src) + STOP_PROCESSING_MACHINERY(src, SSMACHINES_POWEROBJS_LIST) /obj/item/powersink/pwr_drain() if(!attached) return 0 - if(drained_this_tick) - return 1 - drained_this_tick = 1 - var/drained = 0 - if(!PN) + if(!attached.powernet) return 1 set_light(12) - PN.trigger_warning() + attached.powernet.trigger_warning() // found a powernet, so drain up to max power from it - drained = PN.draw_power(drain_rate) + drained = attached.powernet.draw_power(drain_rate) // if tried to drain more than available on powernet // now look for APCs and drain their cells if(drained < drain_rate) - for(var/obj/machinery/power/terminal/T in PN.nodes) + for(var/obj/machinery/power/terminal/T in attached.powernet.nodes) // Enough power drained this tick, no need to torture more APCs if(drained >= drain_rate) break @@ -120,7 +110,6 @@ /obj/item/powersink/process() - drained_this_tick = 0 power_drained -= min(dissipation_rate, power_drained) if(power_drained > max_power * 0.95) playsound(src, 'sound/effects/screech.ogg', 100, 1, 1) @@ -128,7 +117,3 @@ explosion(src.loc, 3,6,9,12) qdel(src) return - if(attached && attached.powernet) - PN = attached.powernet - else - PN = null diff --git a/code/modules/mining/machinery/machine_processing.dm b/code/modules/mining/machinery/machine_processing.dm index ee6d65c027..30932c2c16 100644 --- a/code/modules/mining/machinery/machine_processing.dm +++ b/code/modules/mining/machinery/machine_processing.dm @@ -215,11 +215,11 @@ else speed_process = !speed_process // switching gears if(speed_process) // high gear - STOP_MACHINE_PROCESSING(src) - START_PROCESSING(SSfastprocess, src) + end_processing() + begin_speed_processing() else // low gear - STOP_PROCESSING(SSfastprocess, src) - START_MACHINE_PROCESSING(src) + end_speed_processing() + begin_processing() for(var/obj/machinery/mineral/unloading_machine/unloader in refinery_area.contents) unloader.toggle_speed() for(var/obj/machinery/conveyor_switch/cswitch in refinery_area.contents) diff --git a/code/modules/mining/machinery/machine_stacking.dm b/code/modules/mining/machinery/machine_stacking.dm index 870302704a..e3d95d78df 100644 --- a/code/modules/mining/machinery/machine_stacking.dm +++ b/code/modules/mining/machinery/machine_stacking.dm @@ -109,11 +109,11 @@ else speed_process = !speed_process // switching gears if(speed_process) // high gear - STOP_MACHINE_PROCESSING(src) - START_PROCESSING(SSfastprocess, src) + end_processing() + begin_speed_processing() else // low gear - STOP_PROCESSING(SSfastprocess, src) - START_MACHINE_PROCESSING(src) + end_speed_processing() + begin_processing() /obj/machinery/mineral/stacking_machine/process() if (src.output && src.input) diff --git a/code/modules/mining/machinery/machine_unloading.dm b/code/modules/mining/machinery/machine_unloading.dm index 04b693f075..2e1c2b4fca 100644 --- a/code/modules/mining/machinery/machine_unloading.dm +++ b/code/modules/mining/machinery/machine_unloading.dm @@ -27,11 +27,11 @@ else speed_process = !speed_process // switching gears if(speed_process) // high gear - STOP_MACHINE_PROCESSING(src) - START_PROCESSING(SSfastprocess, src) + end_processing() + begin_speed_processing() else // low gear - STOP_PROCESSING(SSfastprocess, src) - START_MACHINE_PROCESSING(src) + end_speed_processing() + begin_processing() /obj/machinery/mineral/unloading_machine/process() if (src.output && src.input) @@ -53,4 +53,4 @@ O.loc = src.output.loc else return - return \ No newline at end of file + return diff --git a/code/modules/power/antimatter/shielding.dm b/code/modules/power/antimatter/shielding.dm index cbbf53c134..b8f2bbc51d 100644 --- a/code/modules/power/antimatter/shielding.dm +++ b/code/modules/power/antimatter/shielding.dm @@ -147,7 +147,7 @@ /obj/machinery/am_shielding/proc/setup_core() processing = 1 - START_MACHINE_PROCESSING(src) + begin_processing() if(!control_unit) return control_unit.linked_cores.Add(src) control_unit.reported_core_efficiency += efficiency @@ -199,4 +199,4 @@ qdel(src) return ..() - return \ No newline at end of file + return diff --git a/code/modules/power/powernet.dm b/code/modules/power/powernet.dm index 734d2a8fd2..04d55dea8e 100644 --- a/code/modules/power/powernet.dm +++ b/code/modules/power/powernet.dm @@ -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() - START_PROCESSING_POWERNET(src) + START_PROCESSING_MACHINERY(src, SSMACHINES_POWERNETS_LIST) ..() /datum/powernet/Destroy() @@ -31,7 +31,7 @@ for(var/obj/machinery/power/M in nodes) nodes -= M M.powernet = null - STOP_PROCESSING_POWERNET(src) + STOP_PROCESSING_MACHINERY(src, SSMACHINES_POWERNETS_LIST) return ..() //Returns the amount of excess power (before refunding to SMESs) from last tick. diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm index 7a41ef5206..687d0f81e7 100644 --- a/code/modules/recycling/conveyor2.dm +++ b/code/modules/recycling/conveyor2.dm @@ -46,11 +46,11 @@ else speed_process = !speed_process // switching gears if(speed_process) // high gear - STOP_MACHINE_PROCESSING(src) - START_PROCESSING(SSfastprocess, src) + end_processing() + begin_speed_processing() else // low gear - STOP_PROCESSING(SSfastprocess, src) - START_MACHINE_PROCESSING(src) + end_speed_processing() + begin_processing() /obj/machinery/conveyor/proc/setmove() if(operating == FORWARDS) diff --git a/code/modules/xenobio/machinery/processor.dm b/code/modules/xenobio/machinery/processor.dm index 934bf60d8f..80665fd605 100644 --- a/code/modules/xenobio/machinery/processor.dm +++ b/code/modules/xenobio/machinery/processor.dm @@ -24,7 +24,7 @@ return if(to_be_processed.len) spawn(1) - begin_processing() + start_processing() else to_chat(user, "The processor is empty.") playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 1) @@ -60,7 +60,7 @@ AM.forceMove(src) visible_message("\the [user] places [AM] inside \the [src].") -/obj/machinery/processor/proc/begin_processing() +/obj/machinery/processor/proc/start_processing() if(processing) return // Already doing it. processing = TRUE @@ -115,4 +115,4 @@ /obj/machinery/processor/MouseDrop_T(var/atom/movable/AM, var/mob/living/user) if(user.stat || user.incapacitated(INCAPACITATION_DISABLED) || !istype(user)) return - insert(AM, user) \ No newline at end of file + insert(AM, user)