Fixes machine using power from the area it was created in, rather than using the area it is in (#23188)

* Update machine area when power_change() is called.

* Do not attempt to unregister from null powernet

* Move to wrench and update wrench_acts

* Remove accidental pseudocode

---------

Co-authored-by: Adrer <adrermail@gmail.com>
This commit is contained in:
Adrer
2023-11-20 14:10:23 -05:00
committed by GitHub
co-authored by Adrer
parent 5ac1cc817d
commit 39005bea2b
17 changed files with 21 additions and 87 deletions
+1 -7
View File
@@ -101,13 +101,7 @@
if(charging)
to_chat(user, "<span class='warning'>Remove the cell first!</span>")
return
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
anchored = !anchored
if(anchored)
WRENCH_ANCHOR_MESSAGE
else
WRENCH_UNANCHOR_MESSAGE
default_unfasten_wrench(user, I, 0)
/obj/machinery/cell_charger/proc/removecell()
charging.update_icon()
-2
View File
@@ -205,8 +205,6 @@
/obj/structure/AIcore/wrench_act(mob/living/user, obj/item/I)
. = TRUE
if(!I.tool_use_check(user, 0))
return
default_unfasten_wrench(user, I, 20)
/obj/structure/AIcore/update_icon_state()
@@ -632,15 +632,7 @@
/obj/structure/computerframe/wrench_act(mob/living/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 2 SECONDS, volume = I.tool_volume))
return
if(anchored)
to_chat(user, "<span class='notice'>You unfasten the frame.</span>")
anchored = FALSE
else
to_chat(user, "<span class='notice'>You wrench the frame into place.</span>")
anchored = TRUE
default_unfasten_wrench(user, I, 2 SECONDS)
/obj/structure/computerframe/crowbar_act(mob/living/user, obj/item/I)
. = TRUE
+1 -8
View File
@@ -47,15 +47,8 @@ GLOBAL_LIST_EMPTY(doppler_arrays)
/obj/machinery/doppler_array/wrench_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
if(!default_unfasten_wrench(user, I, 0))
return
if(!anchored && !isinspace())
anchored = TRUE
WRENCH_ANCHOR_MESSAGE
else if(anchored)
anchored = FALSE
WRENCH_UNANCHOR_MESSAGE
power_change()
update_icon(UPDATE_ICON_STATE)
/obj/machinery/doppler_array/attack_hand(mob/user)
+9
View File
@@ -131,6 +131,14 @@
stat |= NOPOWER
return old_stat != stat //performance saving for machines that use power_change() to update icons!
/obj/machinery/proc/reregister_machine()
if(machine_powernet?.powernet_area != get_area(src))
var/area/machine_area = get_area(src)
if(machine_area)
machine_powernet?.unregister_machine(src)
machine_powernet = machine_area.powernet
machine_powernet.register_machine(src)
/// Helper proc to change the machines power usage mode, automatically adjusts static power usage to maintain perfect parity
/obj/machinery/proc/change_power_mode(use_type = IDLE_POWER_USE)
if(isnull(use_type) || use_type == power_state || !machine_powernet || !power_channel) //if there is no powernet/channel, just end it here
@@ -320,6 +328,7 @@
/obj/machinery/default_unfasten_wrench(mob/user, obj/item/I, time)
. = ..()
if(.)
reregister_machine()
power_change()
/obj/machinery/attackby(obj/item/O, mob/user, params)
+1 -7
View File
@@ -97,13 +97,7 @@
if(charging)
to_chat(user, "<span class='warning'>Remove the charging item first!</span>")
return
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
anchored = !anchored
if(anchored)
WRENCH_ANCHOR_MESSAGE
else
WRENCH_UNANCHOR_MESSAGE
default_unfasten_wrench(user, I, 0)
/obj/machinery/recharger/attack_hand(mob/user)
if(issilicon(user))
+1 -1
View File
@@ -54,7 +54,7 @@
/obj/machinery/snow_machine/wrench_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
if(!default_unfasten_wrench(user, I, 0))
return
anchored = !anchored
to_chat(user, "<span class='notice'>You [anchored ? "tighten" : "loosen"] [src]'s wheels.</span>")
@@ -202,10 +202,7 @@
if(on)
to_chat(user, "<span class='warning'>Turn it off first!</span>")
return
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
anchored = !anchored
to_chat(user, "<span class='notice'>You [anchored ? "wrench" : "unwrench"] [src].</span>")
default_unfasten_wrench(user, I, 4 SECONDS)
/obj/machinery/atmospherics/portable/scrubber/huge/stationary
name = "Stationary Air Scrubber"
@@ -86,13 +86,7 @@
/obj/machinery/bottler/wrench_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
anchored = !anchored
if(anchored)
WRENCH_ANCHOR_MESSAGE
else
WRENCH_UNANCHOR_MESSAGE
default_unfasten_wrench(user, I, 0)
/obj/machinery/bottler/proc/insert_item(obj/item/O, mob/user)
if(!O || !user)
@@ -203,6 +203,4 @@
/obj/machinery/cooker/deepfryer/wrench_act(mob/user, obj/item/I)
. = TRUE
if(!I.tool_use_check(user, 0))
return
default_unfasten_wrench(user, I, 30)
@@ -263,7 +263,5 @@
/obj/machinery/icemachine/wrench_act(mob/user, obj/item/I)
. = TRUE
if(!I.tool_use_check(user, 0))
return
default_unfasten_wrench(user, I, 30)
@@ -129,12 +129,7 @@
if(operating)
return
I.play_tool_sound(src)
if(anchored)
to_chat(user, "<span class='alert'>[src] can now be moved.</span>")
else
to_chat(user, "<span class='alert'>[src] is now secured.</span>")
anchored = !anchored
default_unfasten_wrench(user, I, 0)
return TRUE
/obj/machinery/kitchen_machine/proc/add_item(obj/item/I, mob/user)
@@ -158,8 +158,6 @@
/obj/machinery/smartfridge/wrench_act(mob/living/user, obj/item/I)
. = default_unfasten_wrench(user, I, time = 4 SECONDS)
if(.)
power_change()
/obj/machinery/smartfridge/crowbar_act(mob/living/user, obj/item/I)
. = default_deconstruction_crowbar(user, I)
+1 -18
View File
@@ -901,24 +901,7 @@
if(using_irrigation)
to_chat(user, "<span class='warning'>Disconnect the hoses first!</span>")
return
if(!anchored && !isinspace())
user.visible_message("[user] begins to wrench [src] into place.", "<span class='notice'>You begin to wrench [src] in place...</span>")
if(I.use_tool(src, user, 20, volume = I.tool_volume))
if(anchored)
return
anchored = TRUE
user.visible_message("[user] wrenches [src] into place.", \
"<span class='notice'>You wrench [src] in place.</span>")
else if(anchored)
user.visible_message("[user] begins to unwrench [src].", \
"<span class='notice'>You begin to unwrench [src]...</span>")
if(I.use_tool(src, user, 20, volume = I.tool_volume))
if(!anchored)
return
anchored = FALSE
user.visible_message("[user] unwrenches [src].", \
"<span class='notice'>You unwrench [src].</span>")
default_unfasten_wrench(user, I)
/obj/machinery/hydroponics/attack_hand(mob/user)
if(issilicon(user)) //How does AI know what plant is?
@@ -191,7 +191,7 @@
/obj/machinery/power/teg/wrench_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
if(!default_unfasten_wrench(user, I, 0))
return
anchored = !anchored
if(!anchored)
@@ -294,14 +294,7 @@
/obj/machinery/chem_dispenser/wrench_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 4 SECONDS, volume = I.tool_volume))
return
if(anchored)
anchored = FALSE
WRENCH_UNANCHOR_MESSAGE
else if(!anchored)
anchored = TRUE
WRENCH_ANCHOR_MESSAGE
default_unfasten_wrench(user, I, 4 SECONDS)
/obj/machinery/chem_dispenser/attack_ai(mob/user)
return attack_hand(user)
@@ -148,9 +148,7 @@
/obj/machinery/chem_master/wrench_act(mob/user, obj/item/I)
if(panel_open)
return
if(default_unfasten_wrench(user, I, time = 4 SECONDS))
power_change()
return TRUE
default_unfasten_wrench(user, I, 4 SECONDS)
/obj/machinery/chem_master/ui_act(action, params, datum/tgui/ui, datum/ui_state/state)
if(..())