From 36cd64c012e856b263217b66b28b76b97e6366a2 Mon Sep 17 00:00:00 2001 From: moocowswag <62126254+moocowswag@users.noreply.github.com> Date: Mon, 26 May 2025 09:00:13 -0400 Subject: [PATCH] Fixes conveyors staying off when recieving power. (#91291) ## About The Pull Request Fixes a bug where after a conveyor loses and regains power it remains off even though the switch connected to it is still on https://github.com/user-attachments/assets/56ec0a67-36cd-4343-a47a-b33e87b58649 Also fixes wiremode on conveyors literally not turning themselves back on when receiving power after not having power (similar bug but it comes before the logic of conveyors remembering that they should be running when they lose power, basically once a conveyor loses power its machine stat stays as nopower permanently until something else updates its power state) ## Why It's Good For The Game Makes conveyors more consistent / reliable, currently they actually take a deceptively large amount of upkeep because you have to constantly turn them back on if power in a room is lost, or in the case of wire mode they will turn off constantly and need to be retriggered with multi tool because they rely on only excess power (which very often can fluctuate to 0) ## Changelog :cl: fix: conveyors now remember what they should be doing after losing and regaining power. /:cl: --- code/modules/recycling/conveyor.dm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/code/modules/recycling/conveyor.dm b/code/modules/recycling/conveyor.dm index 49d072c8101..c6c413837fa 100644 --- a/code/modules/recycling/conveyor.dm +++ b/code/modules/recycling/conveyor.dm @@ -16,8 +16,10 @@ GLOBAL_LIST_EMPTY(conveyors_by_id) desc = "A conveyor belt." layer = BELOW_OPEN_DOOR_LAYER processing_flags = NONE - /// The current state of the switch. + /// The current state of the conveyor. var/operating = CONVEYOR_OFF + /// The state a switch last told us to be in + var/last_command = CONVEYOR_OFF /// This is the default (forward) direction, set by the map dir. var/forwards /// The opposite of forwards. It's set in a special var for corner belts, which aren't using the opposite direction when in reverse. @@ -40,6 +42,8 @@ GLOBAL_LIST_EMPTY(conveyors_by_id) var/wire_mode = FALSE /// weakref to attached cable if wire mode var/datum/weakref/attached_wire_ref + /// remembers if a wire is powering us or not + var/powered_wire = FALSE /obj/machinery/conveyor/Initialize(mapload, new_dir, new_id) . = ..() @@ -111,6 +115,7 @@ GLOBAL_LIST_EMPTY(conveyors_by_id) processing_flags = START_PROCESSING_ON_INIT /obj/machinery/conveyor/auto/Initialize(mapload, newdir) + last_command = CONVEYOR_FORWARD . = ..() set_operating(TRUE) @@ -242,7 +247,8 @@ GLOBAL_LIST_EMPTY(conveyors_by_id) if(machine_stat & NOPOWER) set_operating(FALSE) return FALSE - + if(operating != last_command) + set_operating(last_command) update_appearance() // If we're on, start conveying so moveloops on our tile can be refreshed if they stopped for some reason if(operating != CONVEYOR_OFF) @@ -386,8 +392,12 @@ GLOBAL_LIST_EMPTY(conveyors_by_id) return if(powered()) powernet.load += active_power_usage + if(!powered_wire) + powered_wire = TRUE + power_change() else power_change() + powered_wire = FALSE /obj/machinery/conveyor/proc/update_cable() @@ -488,6 +498,7 @@ GLOBAL_LIST_EMPTY(conveyors_by_id) /// Updates all conveyor belts that are linked to this switch, and tells them to start processing. /obj/machinery/conveyor_switch/proc/update_linked_conveyors() for(var/obj/machinery/conveyor/belt in GLOB.conveyors_by_id[id]) + belt.last_command = position belt.set_operating(position) belt.speed = conveyor_speed CHECK_TICK