diff --git a/code/__defines/dcs/signals.dm b/code/__defines/dcs/signals.dm
index 7c14390b27..65f99f2530 100644
--- a/code/__defines/dcs/signals.dm
+++ b/code/__defines/dcs/signals.dm
@@ -389,6 +389,11 @@
///From /mob/living/proc/updatehealth().
#define COMSIG_UPDATE_HEALTH "update_health"
#define COMSIG_UPDATE_HEALTH_GOD_MODE (1<<0) //If this will set health to 100 and stat to conscious.
+///From /mob/handle_vision().
+#define COMSIG_LIVING_HANDLE_VISION "living_handle_vision"
+///From /mob/handle_regular_hud_updates().
+#define COMSIG_LIVING_HANDLE_HUD "living_handle_hud"
+
// Damage specific signals for /mob/living
///from /mob/living/proc/adjustBrainLoss(amount) and /mob/living/proc/setBrainLoss(amount)
diff --git a/code/controllers/subsystems/tgui.dm b/code/controllers/subsystems/tgui.dm
index 574e9a12ac..2872eb2824 100644
--- a/code/controllers/subsystems/tgui.dm
+++ b/code/controllers/subsystems/tgui.dm
@@ -130,8 +130,6 @@ SUBSYSTEM_DEF(tgui)
for(var/datum/tgui/ui in user.tgui_open_uis)
if(ui.window && ui.window.id == window_id)
ui.close(can_be_suspended = FALSE)
- // Unset machine just to be sure.
- user.unset_machine()
// Close window directly just to be sure.
user << browse(null, "window=[window_id]")
diff --git a/code/datums/components/materials/machine_shim.dm b/code/datums/components/materials/machine_shim.dm
new file mode 100644
index 0000000000..9ca7db3654
--- /dev/null
+++ b/code/datums/components/materials/machine_shim.dm
@@ -0,0 +1,179 @@
+/**
+ * THIS IS A SHIM. IT SHOULD NOT BE INCLUDED IN FUTURE CODE. DEPRECATED, DO NOT USE.
+ *
+ * This is used to replace the machine var in mob, it is a holdover of pre-tgui code.
+ * This component operates similar to how the machine var did previous, but better contained.
+ * Any uses of set_machine() should eventually be removed in favor of tgui handling instead.
+ *
+ * All this does is ensure that the mob releases the machine when they leave it.
+ */
+/datum/component/using_machine_shim
+ var/mob/host_mob
+ var/obj/machinery/linked_machine
+
+/datum/component/using_machine_shim/Initialize(obj/machinery/machine)
+ // Mob
+ host_mob = parent
+ RegisterSignal(host_mob, COMSIG_LIVING_LIFE, PROC_REF(on_mob_action))
+ RegisterSignal(host_mob, COMSIG_LIVING_HANDLE_VISION, PROC_REF(on_mob_vision_update))
+ RegisterSignal(host_mob, COMSIG_OBSERVER_MOVED, PROC_REF(on_mob_action))
+ RegisterSignal(host_mob, COMSIG_MOB_LOGOUT, PROC_REF(on_mob_logout))
+
+ // Machine
+ linked_machine = machine
+ RegisterSignal(linked_machine, COMSIG_QDELETING, PROC_REF(on_machine_qdelete))
+ linked_machine.in_use = TRUE
+ on_mob_vision_update()
+
+ // Lets complain if an object uses TGUI but is still setting the machine.
+ if(length(linked_machine.tgui_data()))
+ log_world("## ERROR [machine.type] implements tgui_data(), and has likely been ported to tgui already. It should no longer use set_machine().")
+ linked_machine.balloon_alert(host_mob,"you start using \the [linked_machine]")
+
+/datum/component/using_machine_shim/Destroy(force)
+ . = ..()
+ linked_machine.balloon_alert(host_mob,"you stop using \the [linked_machine]")
+ // Machine
+ UnregisterSignal(linked_machine, COMSIG_QDELETING)
+ linked_machine.remove_visual(host_mob)
+ linked_machine.in_use = FALSE
+ linked_machine = null
+ // Mob
+ UnregisterSignal(host_mob, COMSIG_OBSERVER_MOVED)
+ UnregisterSignal(host_mob, COMSIG_LIVING_HANDLE_VISION)
+ UnregisterSignal(host_mob, COMSIG_LIVING_LIFE)
+ UnregisterSignal(host_mob, COMSIG_MOB_LOGOUT)
+ host_mob.reset_perspective() // Required, because our machine may have been operating a remote view
+ host_mob = null
+
+/datum/component/using_machine_shim/proc/on_mob_action()
+ SHOULD_NOT_OVERRIDE(TRUE)
+ PRIVATE_PROC(TRUE)
+ SIGNAL_HANDLER
+ if(host_mob.stat == DEAD || !host_mob.client || !host_mob.Adjacent(linked_machine))
+ on_mob_vision_update()
+ qdel(src)
+
+/datum/component/using_machine_shim/proc/on_machine_qdelete()
+ SHOULD_NOT_OVERRIDE(TRUE)
+ PRIVATE_PROC(TRUE)
+ SIGNAL_HANDLER
+ on_mob_vision_update()
+ qdel(src)
+
+/datum/component/using_machine_shim/proc/on_mob_vision_update()
+ SHOULD_NOT_OVERRIDE(TRUE)
+ PRIVATE_PROC(TRUE)
+ SIGNAL_HANDLER
+
+ if(host_mob.stat == DEAD)
+ return
+ var/viewflags = linked_machine.check_eye(host_mob)
+ if(viewflags < 0)
+ return
+ if(host_mob.is_remote_viewing())
+ linked_machine.apply_visual(host_mob)
+ return
+ host_mob.sight |= viewflags
+
+/datum/component/using_machine_shim/proc/on_mob_logout()
+ SHOULD_NOT_OVERRIDE(TRUE)
+ PRIVATE_PROC(TRUE)
+ SIGNAL_HANDLER
+ qdel(src)
+
+/////////////////////////////////////////////////////////////////////////////////
+// To be removed helper procs
+/////////////////////////////////////////////////////////////////////////////////
+/// deprecated, do not use
+/mob/proc/get_current_machine()
+ RETURN_TYPE(/obj)
+ var/datum/component/using_machine_shim/shim = GetComponent(/datum/component/using_machine_shim)
+ if(!shim)
+ return
+ return shim.linked_machine
+
+/// deprecated, do not use
+/mob/proc/check_current_machine(var/obj/checking)
+ var/datum/component/using_machine_shim/shim = GetComponent(/datum/component/using_machine_shim)
+ if(!shim)
+ return FALSE
+ return (shim.linked_machine == checking)
+
+/// deprecated, do not use
+/mob/proc/unset_machine()
+ var/datum/component/using_machine_shim/shim = GetComponent(/datum/component/using_machine_shim)
+ if(shim)
+ qdel(shim)
+
+/// deprecated, do not use
+/mob/proc/set_machine(var/obj/O)
+ var/datum/component/using_machine_shim/shim = GetComponent(/datum/component/using_machine_shim)
+ if(shim)
+ if(shim.linked_machine == O) // Already in use
+ return
+ qdel(shim)
+ return
+ AddComponent(/datum/component/using_machine_shim, O)
+
+/// deprecated, do not use, return flags that should be added to the viewer's sight var. Otherwise return a negative number to indicate that the view should be cancelled.
+/atom/proc/check_eye(user as mob)
+ if (isAI(user)) // WHYYYY
+ return 0
+ return -1
+
+/// deprecated, do not use
+/obj/item/proc/updateSelfDialog()
+ var/mob/M = src.loc
+ if(istype(M) && M.client && M.check_current_machine(src))
+ src.attack_self(M)
+
+/// deprecated, do not use
+/obj/proc/updateUsrDialog(mob/user)
+ if(in_use)
+ var/is_in_use = 0
+ var/list/nearby = viewers(1, src)
+ for(var/mob/M in nearby)
+ if ((M.client && M.check_current_machine(src)))
+ is_in_use = 1
+ src.attack_hand(M)
+ if (isAI(user) || isrobot(user))
+ if (!(user in nearby))
+ if (user.client && user.check_current_machine(src)) // && M.machine == src is omitted because if we triggered this by using the dialog, it doesn't matter if our machine changed in between triggering it and this - the dialog is probably still supposed to refresh.
+ is_in_use = 1
+ src.attack_ai(user)
+
+ // check for TK users
+
+ if (ishuman(user))
+ var/mob/living/carbon/human/H = user
+ if(H.get_type_in_hands(/obj/item/tk_grab))
+ if(!(H in nearby))
+ if(H.client && H.check_current_machine(src))
+ is_in_use = 1
+ src.attack_hand(H)
+ in_use = is_in_use
+
+/// deprecated, do not use
+/obj/proc/updateDialog()
+ // Check that people are actually using the machine. If not, don't update anymore.
+ if(in_use)
+ var/list/nearby = viewers(1, src)
+ var/is_in_use = 0
+ for(var/mob/M in nearby)
+ if ((M.client && M.check_current_machine(src)))
+ is_in_use = 1
+ src.interact(M)
+ var/ai_in_use = AutoUpdateAI(src)
+
+ if(!ai_in_use && !is_in_use)
+ in_use = 0
+
+/// deprecated, do not use
+/obj/machinery/CouldUseTopic(var/mob/user)
+ ..()
+ user.set_machine(src)
+
+/// deprecated, do not use
+/obj/machinery/CouldNotUseTopic(var/mob/user)
+ user.unset_machine()
diff --git a/code/game/atom/_atom.dm b/code/game/atom/_atom.dm
index c6024b39f6..4edbe81809 100644
--- a/code/game/atom/_atom.dm
+++ b/code/game/atom/_atom.dm
@@ -95,12 +95,6 @@
else
return null
-/// return flags that should be added to the viewer's sight var. Otherwise return a negative number to indicate that the view should be cancelled.
-/atom/proc/check_eye(user as mob)
- if (isAI(user)) // WHYYYY
- return 0
- return -1
-
/atom/proc/Bumped(AM as mob|obj)
set waitfor = FALSE
diff --git a/code/game/gamemodes/cult/soulstone.dm b/code/game/gamemodes/cult/soulstone.dm
index c314b22f0d..fa45054e82 100644
--- a/code/game/gamemodes/cult/soulstone.dm
+++ b/code/game/gamemodes/cult/soulstone.dm
@@ -58,7 +58,7 @@
/obj/item/soulstone/Topic(href, href_list)
var/mob/U = usr
- if (!in_range(src, U)||U.machine!=src)
+ if (!in_range(src, U) || !U.check_current_machine(src))
U << browse(null, "window=aicard")
U.unset_machine()
return
diff --git a/code/game/machinery/ai_slipper.dm b/code/game/machinery/ai_slipper.dm
index bbc2638df3..2a4ff071e4 100644
--- a/code/game/machinery/ai_slipper.dm
+++ b/code/game/machinery/ai_slipper.dm
@@ -43,11 +43,11 @@
locked = !locked
to_chat(user, "You [ locked ? "lock" : "unlock"] the device.")
if(locked)
- if(user.machine==src)
+ if(user.check_current_machine(src))
user.unset_machine()
user << browse(null, "window=ai_slipper")
else
- if(user.machine==src)
+ if(user.check_current_machine(src))
attack_hand(user)
else
to_chat(user, span_warning("Access denied."))
diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm
index 314ad84fa9..3ecd960dde 100644
--- a/code/game/machinery/autolathe.dm
+++ b/code/game/machinery/autolathe.dm
@@ -150,14 +150,12 @@
return ..()
/obj/machinery/autolathe/attack_hand(mob/user as mob)
- user.set_machine(src)
interact(user)
/obj/machinery/autolathe/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
if(..())
return TRUE
- ui.user.set_machine(src)
add_fingerprint(ui.user)
if(busy)
diff --git a/code/game/machinery/computer/arcade.dm b/code/game/machinery/computer/arcade.dm
index 78302073a3..e751969f17 100644
--- a/code/game/machinery/computer/arcade.dm
+++ b/code/game/machinery/computer/arcade.dm
@@ -124,7 +124,6 @@
/obj/machinery/computer/arcade/battle/attack_hand(mob/user as mob)
if(..())
return
- user.set_machine(src)
tgui_interact(user)
/obj/machinery/computer/arcade/battle/tgui_interact(mob/user, datum/tgui/ui)
diff --git a/code/game/machinery/computer/cloning.dm b/code/game/machinery/computer/cloning.dm
index 380440c4b9..298f608b31 100644
--- a/code/game/machinery/computer/cloning.dm
+++ b/code/game/machinery/computer/cloning.dm
@@ -116,7 +116,6 @@
return attack_hand(user)
/obj/machinery/computer/cloning/attack_hand(mob/user as mob)
- user.set_machine(src)
add_fingerprint(user)
if(stat & (BROKEN|NOPOWER))
diff --git a/code/game/machinery/computer/guestpass.dm b/code/game/machinery/computer/guestpass.dm
index e3a38eeb41..50f3789014 100644
--- a/code/game/machinery/computer/guestpass.dm
+++ b/code/game/machinery/computer/guestpass.dm
@@ -150,7 +150,6 @@
if(..())
return
- user.set_machine(src)
tgui_interact(user)
/obj/machinery/computer/guestpass/tgui_interact(mob/user, datum/tgui/ui)
diff --git a/code/game/machinery/computer/specops_shuttle.dm b/code/game/machinery/computer/specops_shuttle.dm
index 5537e5688d..a212586552 100644
--- a/code/game/machinery/computer/specops_shuttle.dm
+++ b/code/game/machinery/computer/specops_shuttle.dm
@@ -260,7 +260,7 @@ var/specops_shuttle_timeleft = 0
if(..())
return
- user.machine = src
+ user.set_machine(src)
var/dat
if (temp)
dat = temp
@@ -279,7 +279,7 @@ var/specops_shuttle_timeleft = 0
return 1
if ((usr.contents.Find(src) || (in_range(src, usr) && istype(loc, /turf))) || (istype(usr, /mob/living/silicon)))
- usr.machine = src
+ usr.set_machine(src)
if (href_list["sendtodock"])
if(!specops_shuttle_at_station|| specops_shuttle_moving_to_station || specops_shuttle_moving_to_centcom) return
diff --git a/code/game/machinery/computer/supply.dm b/code/game/machinery/computer/supply.dm
index 7eb44947fb..1b9b9d6066 100644
--- a/code/game/machinery/computer/supply.dm
+++ b/code/game/machinery/computer/supply.dm
@@ -36,7 +36,6 @@
if(!allowed(user))
to_chat(user, span_warning("You don't have the required access to use this console."))
return
- user.set_machine(src)
tgui_interact(user)
return
diff --git a/code/game/machinery/computer/timeclock_vr.dm b/code/game/machinery/computer/timeclock_vr.dm
index ca390d5bd3..7d96d4f07b 100644
--- a/code/game/machinery/computer/timeclock_vr.dm
+++ b/code/game/machinery/computer/timeclock_vr.dm
@@ -65,7 +65,6 @@
/obj/machinery/computer/timeclock/attack_hand(var/mob/user as mob)
if(..())
return
- user.set_machine(src)
tgui_interact(user)
/obj/machinery/computer/timeclock/tgui_interact(mob/user, datum/tgui/ui)
diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm
index 2b96ae81e8..eab16209e8 100644
--- a/code/game/machinery/doors/airlock.dm
+++ b/code/game/machinery/doors/airlock.dm
@@ -498,7 +498,6 @@ About the new airlock wires panel:
return
if(p_open)
- user.set_machine(src)
wires.Interact(user)
return
diff --git a/code/game/machinery/fire_alarm.dm b/code/game/machinery/fire_alarm.dm
index b52d1e7285..289620d120 100644
--- a/code/game/machinery/fire_alarm.dm
+++ b/code/game/machinery/fire_alarm.dm
@@ -228,7 +228,7 @@ Just a object used in constructing fire alarms
if(user.stat || stat & (NOPOWER|BROKEN))
return
- user.machine = src
+ user.set_machine(src)
var/area/A = get_area(src)
ASSERT(isarea(A))
var/d1
@@ -285,7 +285,7 @@ Just a object used in constructing fire alarms
if(usr.stat || stat & (BROKEN|NOPOWER))
return
if((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(loc, /turf))) || (isAI(usr)))
- usr.machine = src
+ usr.set_machine(src)
if(href_list["reset"])
reset()
else if(href_list["alarm"])
diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm
index 13a9226af4..93ba213686 100644
--- a/code/game/machinery/machinery.dm
+++ b/code/game/machinery/machinery.dm
@@ -225,13 +225,6 @@ Class Procs:
return STATUS_CLOSE
return ..()
-/obj/machinery/CouldUseTopic(var/mob/user)
- ..()
- user.set_machine(src)
-
-/obj/machinery/CouldNotUseTopic(var/mob/user)
- user.unset_machine()
-
////////////////////////////////////////////////////////////////////////////////////////////
/obj/machinery/attack_ai(mob/user as mob)
diff --git a/code/game/machinery/nuclear_bomb.dm b/code/game/machinery/nuclear_bomb.dm
index 972a73f7f6..bf67d74390 100644
--- a/code/game/machinery/nuclear_bomb.dm
+++ b/code/game/machinery/nuclear_bomb.dm
@@ -50,7 +50,7 @@ GLOBAL_VAR(bomb_set)
if(timeleft <= 0)
explode()
for(var/mob/M in viewers(1, src))
- if((M.client && M.machine == src))
+ if((M.client && M.check_current_machine(src)))
attack_hand(M)
return ..()
@@ -348,7 +348,7 @@ GLOBAL_VAR(bomb_set)
add_fingerprint(usr)
for(var/mob/M in viewers(1, src))
- if((M.client && M.machine == src))
+ if((M.client && M.check_current_machine(src)))
attack_hand(M)
else
usr << browse(null, "window=nuclearbomb")
diff --git a/code/game/machinery/petrification.dm b/code/game/machinery/petrification.dm
index 645db260c7..b057ac18e5 100644
--- a/code/game/machinery/petrification.dm
+++ b/code/game/machinery/petrification.dm
@@ -142,7 +142,6 @@
/obj/machinery/petrification/attack_hand(var/mob/user as mob)
if(..())
return
- user.set_machine(src)
tgui_interact(user)
/obj/machinery/petrification/tgui_interact(mob/user, datum/tgui/ui = null)
diff --git a/code/game/machinery/pipe/pipe_dispenser.dm b/code/game/machinery/pipe/pipe_dispenser.dm
index 70a10bea87..5794fd4f6b 100644
--- a/code/game/machinery/pipe/pipe_dispenser.dm
+++ b/code/game/machinery/pipe/pipe_dispenser.dm
@@ -128,7 +128,7 @@
src.anchored = FALSE
src.stat |= MAINT
src.unwrenched = 1
- if (user.machine==src)
+ if (user.check_current_machine(src))
user << browse(null, "window=pipedispenser")
else /*if (unwrenched==1)*/
playsound(src, W.usesound, 50, 1)
diff --git a/code/game/machinery/robot_fabricator.dm b/code/game/machinery/robot_fabricator.dm
index 57ba629d6c..c93b1a4d06 100644
--- a/code/game/machinery/robot_fabricator.dm
+++ b/code/game/machinery/robot_fabricator.dm
@@ -135,5 +135,5 @@ Please wait until completion...
return
for (var/mob/M in viewers(1, src))
- if(M.client && M.machine == src)
+ if(M.client && M.check_current_machine(src))
attack_hand(M)
diff --git a/code/game/machinery/spaceheater.dm b/code/game/machinery/spaceheater.dm
index 06c2d1ccf9..a360455f3f 100644
--- a/code/game/machinery/spaceheater.dm
+++ b/code/game/machinery/spaceheater.dm
@@ -124,7 +124,7 @@
playsound(src, I.usesound, 50, 1)
user.visible_message(span_notice("[user] [panel_open ? "opens" : "closes"] the hatch on the [src]."), span_notice("You [panel_open ? "open" : "close"] the hatch on the [src]."))
update_icon()
- if(!panel_open && user.machine == src)
+ if(!panel_open && user.check_current_machine(src))
user << browse(null, "window=spaceheater")
user.unset_machine()
else
diff --git a/code/game/machinery/telecomms/traffic_control.dm b/code/game/machinery/telecomms/traffic_control.dm
index 9cc662b739..de4fde2ac5 100644
--- a/code/game/machinery/telecomms/traffic_control.dm
+++ b/code/game/machinery/telecomms/traffic_control.dm
@@ -39,7 +39,7 @@
winset(editingcode, "tcscode", "is-disabled=false")
// If the player's not manning the keyboard anymore, adjust everything
- if( (!(editingcode in range(1, src)) && !issilicon(editingcode)) || (editingcode.machine != src && !issilicon(editingcode)))
+ if( (!(editingcode in range(1, src)) && !issilicon(editingcode)) || (!editingcode.check_current_machine(src) && !issilicon(editingcode)))
if(editingcode)
winshow(editingcode, "Telecomms IDE", 0) // hide the window!
editingcode = null
@@ -55,7 +55,7 @@
for(var/mob/M in viewingcode)
- if( (M.machine == src && (M in view(1, src)) ) || issilicon(M))
+ if( (M.check_current_machine(src) && (M in view(1, src)) ) || issilicon(M))
winset(M, "tcscode", "is-disabled=true")
winset(M, "tcscode", "text=\"[showcode]\"")
else
diff --git a/code/game/machinery/wishgranter.dm b/code/game/machinery/wishgranter.dm
index 37637ebd99..71b9041ee5 100644
--- a/code/game/machinery/wishgranter.dm
+++ b/code/game/machinery/wishgranter.dm
@@ -12,8 +12,6 @@
var/insistinga = 0
/obj/machinery/wish_granter/attack_hand(var/mob/living/carbon/human/user as mob)
- user.set_machine(src)
-
if(chargesa <= 0)
to_chat(user, span_infoplain("The Wish Granter lies silent."))
return
diff --git a/code/game/objects/effects/mines.dm b/code/game/objects/effects/mines.dm
index 0672e916a2..2764416930 100644
--- a/code/game/objects/effects/mines.dm
+++ b/code/game/objects/effects/mines.dm
@@ -123,7 +123,6 @@
/obj/effect/mine/interact(mob/living/user as mob)
if(!panel_open || isAI(user))
return
- user.set_machine(src)
wires.Interact(user)
/obj/effect/mine/camo
diff --git a/code/game/objects/items/devices/radio/headset.dm b/code/game/objects/items/devices/radio/headset.dm
index 5dd4d5b080..663124552b 100644
--- a/code/game/objects/items/devices/radio/headset.dm
+++ b/code/game/objects/items/devices/radio/headset.dm
@@ -87,7 +87,6 @@
/obj/item/radio/headset/attackby(obj/item/W as obj, mob/user as mob)
// ..()
- user.set_machine(src)
if(!(W.has_tool_quality(TOOL_SCREWDRIVER) || istype(W, /obj/item/encryptionkey)))
return
diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm
index 2602e2637c..389e553779 100644
--- a/code/game/objects/items/devices/radio/radio.dm
+++ b/code/game/objects/items/devices/radio/radio.dm
@@ -116,7 +116,6 @@
return
/obj/item/radio/attack_self(mob/user as mob)
- user.set_machine(src)
interact(user)
/obj/item/radio/interact(mob/user)
@@ -588,7 +587,6 @@ GLOBAL_DATUM(autospeaker, /mob/living/silicon/ai/announcer)
/obj/item/radio/attackby(obj/item/W as obj, mob/user as mob)
..()
- user.set_machine(src)
if (!W.has_tool_quality(TOOL_SCREWDRIVER))
return
b_stat = !( b_stat )
@@ -643,7 +641,6 @@ GLOBAL_DATUM(autospeaker, /mob/living/silicon/ai/announcer)
/obj/item/radio/borg/attackby(obj/item/W as obj, mob/user as mob)
// ..()
- user.set_machine(src)
if (!(W.has_tool_quality(TOOL_SCREWDRIVER) || istype(W, /obj/item/encryptionkey)))
return
diff --git a/code/game/objects/items/devices/tvcamera.dm b/code/game/objects/items/devices/tvcamera.dm
index 2abb18cad1..e5f6ba46be 100644
--- a/code/game/objects/items/devices/tvcamera.dm
+++ b/code/game/objects/items/devices/tvcamera.dm
@@ -123,7 +123,7 @@
if(camera.status && !isturf(target))
show_tvs(target)
user.visible_message(span_infoplain(span_bold("[user]") + " aims [src] at [target]."), span_info("You aim [src] at [target]."))
- if(user.machine == src)
+ if(user.check_current_machine(src))
show_ui(user) // refresh the UI
/obj/item/tvcamera/process()
diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm
index b9c47b4cfd..75560e11f5 100644
--- a/code/game/objects/items/stacks/stack.dm
+++ b/code/game/objects/items/stacks/stack.dm
@@ -48,7 +48,7 @@
AddElement(/datum/element/sellable/material_stack)
/obj/item/stack/Destroy()
- if (src && usr && usr.machine == src)
+ if (src && usr && usr.check_current_machine(src))
usr << browse(null, "window=stack")
if(islist(synths))
synths.Cut()
@@ -423,7 +423,7 @@
src.add_fingerprint(user)
F.add_fingerprint(user)
spawn(0)
- if (src && user.machine==src)
+ if (src && user.check_current_machine(src))
src.interact(user)
else
..()
@@ -439,9 +439,9 @@
src.transfer_to(S)
spawn(0) //give the stacks a chance to delete themselves if necessary
- if (S && user.machine==S)
+ if (S && user.check_current_machine(S))
S.interact(user)
- if (src && user.machine==src)
+ if (src && user.check_current_machine(src))
src.interact(user)
else
return ..()
diff --git a/code/game/objects/items/weapons/implants/implantchair.dm b/code/game/objects/items/weapons/implants/implantchair.dm
index dee1107999..73332b56a5 100644
--- a/code/game/objects/items/weapons/implants/implantchair.dm
+++ b/code/game/objects/items/weapons/implants/implantchair.dm
@@ -8,6 +8,7 @@
density = TRUE
opacity = 0
anchored = TRUE
+ flags = REMOTEVIEW_ON_ENTER
var/ready = 1
var/malfunction = 0
@@ -41,7 +42,6 @@
dat += span_bold("Implants:") + " [src.implant_list.len ? "[implant_list.len]" : "Replenish"]
"
if(src.occupant)
dat += "[src.ready ? "Implant" : "Recharging"]
"
- user.set_machine(src)
var/datum/browser/popup = new(user, "implant", "Implant")
popup.set_content(dat)
diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm
index 5110e22bb6..81ee1e0b25 100644
--- a/code/game/objects/objs.dm
+++ b/code/game/objects/objs.dm
@@ -99,65 +99,10 @@
else
return null
-/obj/proc/updateUsrDialog(mob/user)
- if(in_use)
- var/is_in_use = 0
- var/list/nearby = viewers(1, src)
- for(var/mob/M in nearby)
- if ((M.client && M.machine == src))
- is_in_use = 1
- src.attack_hand(M)
- if (isAI(user) || isrobot(user))
- if (!(user in nearby))
- if (user.client && user.machine==src) // && M.machine == src is omitted because if we triggered this by using the dialog, it doesn't matter if our machine changed in between triggering it and this - the dialog is probably still supposed to refresh.
- is_in_use = 1
- src.attack_ai(user)
-
- // check for TK users
-
- if (ishuman(user))
- var/mob/living/carbon/human/H = user
- if(H.get_type_in_hands(/obj/item/tk_grab))
- if(!(H in nearby))
- if(H.client && H.machine==src)
- is_in_use = 1
- src.attack_hand(H)
- in_use = is_in_use
-
-/obj/proc/updateDialog()
- // Check that people are actually using the machine. If not, don't update anymore.
- if(in_use)
- var/list/nearby = viewers(1, src)
- var/is_in_use = 0
- for(var/mob/M in nearby)
- if ((M.client && M.machine == src))
- is_in_use = 1
- src.interact(M)
- var/ai_in_use = AutoUpdateAI(src)
-
- if(!ai_in_use && !is_in_use)
- in_use = 0
-
/obj/attack_ghost(mob/user)
tgui_interact(user)
..()
-/mob/proc/unset_machine()
- machine?.remove_visual(src)
- src.machine = null
-
-/mob/proc/set_machine(var/obj/O)
- if(src.machine)
- unset_machine()
- src.machine = O
- if(istype(O))
- O.in_use = 1
-
-/obj/item/proc/updateSelfDialog()
- var/mob/M = src.loc
- if(istype(M) && M.client && M.machine == src)
- src.attack_self(M)
-
/obj/proc/hide(h)
return
diff --git a/code/modules/clothing/spacesuits/rig/rig.dm b/code/modules/clothing/spacesuits/rig/rig.dm
index f474964801..40c449d770 100644
--- a/code/modules/clothing/spacesuits/rig/rig.dm
+++ b/code/modules/clothing/spacesuits/rig/rig.dm
@@ -987,8 +987,8 @@
wearer_move_delay = world.time
return wearer.buckled.relaymove(wearer, direction)
- if(istype(wearer.machine, /obj/machinery))
- if(wearer.machine.relaymove(wearer, direction))
+ if(istype(wearer.get_current_machine(), /obj/machinery))
+ if(wearer.get_current_machine().relaymove(wearer, direction))
return
if(wearer.pulledby || wearer.buckled) // Wheelchair driving!
diff --git a/code/modules/food/kitchen/microwave.dm b/code/modules/food/kitchen/microwave.dm
index ce92e8df2c..dd209278d7 100644
--- a/code/modules/food/kitchen/microwave.dm
+++ b/code/modules/food/kitchen/microwave.dm
@@ -235,7 +235,6 @@
if(paicard)
ejectpai(user)
return
- user.set_machine(src)
tgui_interact(user)
/*******************
diff --git a/code/modules/holodeck/HolodeckControl.dm b/code/modules/holodeck/HolodeckControl.dm
index 0cfd967fd8..2fb3de64de 100644
--- a/code/modules/holodeck/HolodeckControl.dm
+++ b/code/modules/holodeck/HolodeckControl.dm
@@ -82,8 +82,6 @@
/obj/machinery/computer/HolodeckControl/attack_hand(var/mob/user as mob)
if(..())
return
- user.set_machine(src)
-
tgui_interact(user)
/**
diff --git a/code/modules/hydroponics/seed_machines.dm b/code/modules/hydroponics/seed_machines.dm
index 19ec930941..46b628eeed 100644
--- a/code/modules/hydroponics/seed_machines.dm
+++ b/code/modules/hydroponics/seed_machines.dm
@@ -175,7 +175,6 @@
if(..())
return TRUE
- ui.user.set_machine(src)
add_fingerprint(ui.user)
switch(action)
diff --git a/code/modules/hydroponics/seed_storage.dm b/code/modules/hydroponics/seed_storage.dm
index c10fedadb0..2f98970deb 100644
--- a/code/modules/hydroponics/seed_storage.dm
+++ b/code/modules/hydroponics/seed_storage.dm
@@ -216,7 +216,6 @@
wires.Interact(user)
if(lockdown)
return
- user.set_machine(src)
tgui_interact(user)
/obj/machinery/seed_storage/tgui_interact(mob/user, datum/tgui/ui)
diff --git a/code/modules/mob/living/bot/cleanbot.dm b/code/modules/mob/living/bot/cleanbot.dm
index c0970b2194..610aeb5958 100644
--- a/code/modules/mob/living/bot/cleanbot.dm
+++ b/code/modules/mob/living/bot/cleanbot.dm
@@ -201,7 +201,6 @@
/mob/living/bot/cleanbot/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
if(..())
return TRUE
- ui.user.set_machine(src)
add_fingerprint(ui.user)
switch(action)
if("start")
diff --git a/code/modules/mob/living/bot/medbot.dm b/code/modules/mob/living/bot/medbot.dm
index e0573433eb..4bdc7865b6 100644
--- a/code/modules/mob/living/bot/medbot.dm
+++ b/code/modules/mob/living/bot/medbot.dm
@@ -269,7 +269,6 @@
if(..())
return TRUE
- ui.user.set_machine(src)
add_fingerprint(ui.user)
. = TRUE
diff --git a/code/modules/mob/living/carbon/alien/life.dm b/code/modules/mob/living/carbon/alien/life.dm
index 368643b4b4..2f1d861de7 100644
--- a/code/modules/mob/living/carbon/alien/life.dm
+++ b/code/modules/mob/living/carbon/alien/life.dm
@@ -89,8 +89,7 @@
return 1
-/mob/living/carbon/alien/handle_regular_hud_updates()
-
+/mob/living/carbon/alien/handle_vision()
if (stat == 2 || (XRAY in src.mutations))
sight |= SEE_TURFS
sight |= SEE_MOBS
@@ -104,6 +103,14 @@
see_in_dark = 2
see_invisible = SEE_INVISIBLE_LIVING
+ // Call parent to handle signals
+ ..()
+
+/mob/living/carbon/alien/handle_regular_hud_updates()
+ . = ..()
+ if(!.)
+ return
+
if (healths)
if (stat != 2)
switch(health)
@@ -124,8 +131,7 @@
else
healths.icon_state = "health7"
- if (client)
- client.screen.Remove(GLOB.global_hud.blurry,GLOB.global_hud.druggy,GLOB.global_hud.vimpaired)
+ client.screen.Remove(GLOB.global_hud.blurry,GLOB.global_hud.druggy,GLOB.global_hud.vimpaired)
if ( stat != 2)
if ((blinded))
@@ -135,10 +141,6 @@
set_fullscreen(disabilities & NEARSIGHTED, "impaired", /atom/movable/screen/fullscreen/impaired, 1)
set_fullscreen(eye_blurry, "blurry", /atom/movable/screen/fullscreen/blurry)
set_fullscreen(druggy, "high", /atom/movable/screen/fullscreen/high)
- if(machine && machine.check_eye(src) < 0)
- reset_perspective()
-
- return 1
/mob/living/carbon/alien/handle_environment(var/datum/gas_mixture/environment)
// Both alien subtypes survive in vaccum and suffer in high temperatures,
diff --git a/code/modules/mob/living/carbon/brain/life.dm b/code/modules/mob/living/carbon/brain/life.dm
index 09594845f7..3969b924d8 100644
--- a/code/modules/mob/living/carbon/brain/life.dm
+++ b/code/modules/mob/living/carbon/brain/life.dm
@@ -152,22 +152,30 @@
return 1
-/mob/living/carbon/brain/handle_regular_hud_updates()
- if (stat == 2 || (XRAY in src.mutations))
+/mob/living/carbon/brain/handle_vision()
+ if (stat == DEAD || (XRAY in src.mutations))
sight |= SEE_TURFS
sight |= SEE_MOBS
sight |= SEE_OBJS
see_in_dark = 8
see_invisible = SEE_INVISIBLE_LEVEL_TWO
- else if (stat != 2)
+ else if (stat != DEAD)
sight &= ~SEE_TURFS
sight &= ~SEE_MOBS
sight &= ~SEE_OBJS
see_in_dark = 2
see_invisible = SEE_INVISIBLE_LIVING
+ // Call parent to handle signals
+ ..()
+
+/mob/living/carbon/brain/handle_regular_hud_updates()
+ . = ..()
+ if(!.)
+ return
+
if (healths)
- if (stat != 2)
+ if (stat != DEAD)
switch(health)
if(100 to INFINITY)
healths.icon_state = "health0"
@@ -186,22 +194,9 @@
else
healths.icon_state = "health7"
- if (stat == 2 || (XRAY in src.mutations))
- sight |= SEE_TURFS
- sight |= SEE_MOBS
- sight |= SEE_OBJS
- see_in_dark = 8
- see_invisible = SEE_INVISIBLE_LEVEL_TWO
- else if (stat != 2)
- sight &= ~SEE_TURFS
- sight &= ~SEE_MOBS
- sight &= ~SEE_OBJS
- see_in_dark = 2
- see_invisible = SEE_INVISIBLE_LIVING
- if (client)
- client.screen.Remove(GLOB.global_hud.blurry,GLOB.global_hud.druggy,GLOB.global_hud.vimpaired)
+ client.screen.Remove(GLOB.global_hud.blurry,GLOB.global_hud.druggy,GLOB.global_hud.vimpaired)
- if (stat != 2)
+ if (stat != DEAD)
if ((blinded))
overlay_fullscreen("blind", /atom/movable/screen/fullscreen/blind)
else
@@ -209,8 +204,3 @@
set_fullscreen(disabilities & NEARSIGHTED, "impaired", /atom/movable/screen/fullscreen/impaired, 1)
set_fullscreen(eye_blurry, "blurry", /atom/movable/screen/fullscreen/blurry)
set_fullscreen(druggy, "high", /atom/movable/screen/fullscreen/high)
-
- if (machine && machine.check_eye(src) < 0)
- reset_perspective()
-
- return 1
diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm
index 11fc681073..b6c2e76662 100644
--- a/code/modules/mob/living/carbon/human/life.dm
+++ b/code/modules/mob/living/carbon/human/life.dm
@@ -1431,11 +1431,9 @@
handle_hud_list()
// now handle what we see on our screen
-
- if(!client)
- return 0
-
- ..()
+ . = ..()
+ if(!.)
+ return
client.screen.Remove(GLOB.global_hud.blurry, GLOB.global_hud.druggy, GLOB.global_hud.vimpaired, GLOB.global_hud.darkMask, GLOB.global_hud.nvg, GLOB.global_hud.thermal, GLOB.global_hud.meson, GLOB.global_hud.science, GLOB.global_hud.material, GLOB.global_hud.whitense)
@@ -1730,17 +1728,11 @@
if(!seer && !glasses_processed && seedarkness)
see_invisible = see_invisible_default
- if(machine)
- var/viewflags = machine.check_eye(src)
- if(viewflags < 0)
- reset_perspective()
- else if(viewflags && !is_remote_viewing())
- sight |= viewflags
- else
- machine.apply_visual(src)
- else if(eyeobj && eyeobj.owner != src)
+ if(!get_current_machine() && eyeobj && eyeobj.owner != src)
reset_perspective()
- return 1
+
+ // Call parent to handle signals
+ ..()
/mob/living/carbon/human/proc/process_glasses(var/obj/item/clothing/glasses/G)
. = FALSE
diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm
index b61258a88f..3929eb5e74 100644
--- a/code/modules/mob/living/life.dm
+++ b/code/modules/mob/living/life.dm
@@ -232,15 +232,12 @@
adjustEarDamage(-0.05,-1)
/mob/living/handle_regular_hud_updates()
- if(!client)
- return 0
- ..()
-
+ . = ..()
+ if(!.)
+ return
handle_darksight()
handle_hud_icons()
- return 1
-
/mob/living/proc/update_sight()
if(!seedarkness)
see_invisible = SEE_INVISIBLE_NOLIGHTING
diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm
index 2069113bb0..07eea4cb83 100644
--- a/code/modules/mob/living/silicon/ai/ai.dm
+++ b/code/modules/mob/living/silicon/ai/ai.dm
@@ -34,7 +34,7 @@ var/list/ai_verbs_default = list(
var/is_in_use = 0
if (subject!=null)
for(var/mob/living/silicon/ai/M as anything in GLOB.ai_list)
- if ((M.client && M.machine == subject))
+ if ((M.client && M.check_current_machine(subject)))
is_in_use = 1
subject.attack_ai(M)
return is_in_use
diff --git a/code/modules/mob/living/silicon/pai/pai_hud.dm b/code/modules/mob/living/silicon/pai/pai_hud.dm
index 5034400300..9465275b3a 100644
--- a/code/modules/mob/living/silicon/pai/pai_hud.dm
+++ b/code/modules/mob/living/silicon/pai/pai_hud.dm
@@ -390,6 +390,9 @@
/mob/living/silicon/pai/handle_regular_hud_updates()
. = ..()
+ if(!.)
+ return
+
if(healths)
if(stat != DEAD)
var/heal_per = (health / getMaxHealth()) * 100
diff --git a/code/modules/mob/living/silicon/robot/life.dm b/code/modules/mob/living/silicon/robot/life.dm
index 55df95dd3e..9b42a3f671 100644
--- a/code/modules/mob/living/silicon/robot/life.dm
+++ b/code/modules/mob/living/silicon/robot/life.dm
@@ -149,9 +149,10 @@
else
blinded = 1
- return 1
+ // Call parent to handle signals
+ . = ..()
-/mob/living/silicon/robot/handle_regular_hud_updates()
+/mob/living/silicon/robot/handle_vision()
var/fullbright = FALSE
var/seemeson = FALSE
var/seejanhud = sight_mode & BORGJAN
@@ -211,8 +212,14 @@
plane_holder.set_vis(VIS_MESONS,seemeson)
plane_holder.set_vis(VIS_JANHUD,seejanhud)
+ // Call parent to handle signals
..()
+/mob/living/silicon/robot/handle_regular_hud_updates()
+ . = ..()
+ if(!.)
+ return
+
if (healths)
if (stat != 2)
if(istype(src,/mob/living/silicon/robot/drone))
@@ -249,7 +256,7 @@
else
healths.icon_state = "health7"
- if (syndicate && client)
+ if (syndicate)
for(var/datum/mind/tra in traitors.current_antagonists)
if(tra.current)
// TODO: Update to new antagonist system.
@@ -292,16 +299,11 @@
set_fullscreen(eye_blurry, "blurry", /atom/movable/screen/fullscreen/blurry)
set_fullscreen(druggy, "high", /atom/movable/screen/fullscreen/high)
- if (machine && machine.check_eye(src) < 0)
- reset_perspective()
-
if(emagged)
throw_alert("hacked", /atom/movable/screen/alert/hacked)
else
clear_alert("hacked")
- return 1
-
/mob/living/silicon/robot/proc/update_cell()
if(cell)
var/cellcharge = cell.charge/cell.maxcharge
diff --git a/code/modules/mob/living/simple_mob/subtypes/animal/borer/borer.dm b/code/modules/mob/living/simple_mob/subtypes/animal/borer/borer.dm
index 55357fe97e..28a71d1338 100644
--- a/code/modules/mob/living/simple_mob/subtypes/animal/borer/borer.dm
+++ b/code/modules/mob/living/simple_mob/subtypes/animal/borer/borer.dm
@@ -171,7 +171,7 @@
forceMove(get_turf(host))
- machine = null
+ unset_machine()
if(ishuman(host))
var/mob/living/carbon/human/H = host
@@ -179,7 +179,7 @@
if(head)
head.implants -= src
- host.machine = null
+ host.unset_machine()
host = null
/mob/living/simple_mob/animal/borer/proc/request_player()
diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm
index 14e673ee57..ff5cf908b0 100644
--- a/code/modules/mob/mob_defines.dm
+++ b/code/modules/mob/mob_defines.dm
@@ -69,7 +69,6 @@
var/list/logging = list()
var/already_placed = 0.0
- var/obj/machinery/machine = null
var/other_mobs = null
var/memory = ""
var/poll_answer = 0.0
diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm
index d2dabb6ac6..739d0f249b 100644
--- a/code/modules/mob/mob_helpers.dm
+++ b/code/modules/mob/mob_helpers.dm
@@ -555,7 +555,7 @@ var/list/intents = list(I_HELP,I_DISARM,I_GRAB,I_HURT)
say_dead_direct(span_name("[name]") + " no longer [pick("skulks","lurks","prowls","creeps","stalks")] in the realm of the dead. [message]")
/mob/proc/switch_to_camera(var/obj/machinery/camera/C)
- if (!C.can_use() || stat || (get_dist(C, src) > 1 || machine != src || blinded || !canmove))
+ if (!C.can_use() || stat || (get_dist(C, src) > 1 || !check_current_machine(src) || blinded || !canmove))
return 0
check_eye(src)
return 1
@@ -712,13 +712,18 @@ var/list/global/organ_rel_size = list(
/mob/proc/recalculate_vis()
return
-//General HUD updates done regularly (health puppet things, etc)
+/// General HUD updates done regularly (health puppet things, etc). Returns true if the mob has a client.
/mob/proc/handle_regular_hud_updates()
- return
+ SHOULD_CALL_PARENT(TRUE)
+ if(!client)
+ return FALSE
+ SEND_SIGNAL(src,COMSIG_LIVING_HANDLE_HUD)
+ return TRUE
-//Handle eye things like the Byond SEE_TURFS, SEE_OBJS, etc.
+/// Handle eye things like the Byond SEE_TURFS, SEE_OBJS, etc.
/mob/proc/handle_vision()
- return
+ SHOULD_CALL_PARENT(TRUE)
+ SEND_SIGNAL(src,COMSIG_LIVING_HANDLE_VISION)
//Icon is used to occlude things like huds from the faulty byond context menu.
// http://www.byond.com/forum/?post=2336679
diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm
index bbca519801..d410289f56 100644
--- a/code/modules/mob/mob_movement.dm
+++ b/code/modules/mob/mob_movement.dm
@@ -214,8 +214,9 @@
return
// Relaymove could handle it
- if(my_mob.machine)
- var/result = my_mob.machine.relaymove(my_mob, direct)
+ var/obj/machine = my_mob.get_current_machine()
+ if(machine)
+ var/result = machine.relaymove(my_mob, direct)
if(result)
return result
diff --git a/code/modules/overmap/ships/computers/ship.dm b/code/modules/overmap/ships/computers/ship.dm
index 98527adc84..b173e1c750 100644
--- a/code/modules/overmap/ships/computers/ship.dm
+++ b/code/modules/overmap/ships/computers/ship.dm
@@ -93,7 +93,7 @@ somewhere on that shuttle. Subtypes of these can be then used to perform ship ov
user.reset_perspective()
/obj/machinery/computer/ship/check_eye(var/mob/user)
- if(!get_dist(user, src) > 1 || user.blinded || !linked)
+ if(user.blinded || !linked)
user.reset_perspective()
return -1
else
diff --git a/code/modules/paperwork/faxmachine.dm b/code/modules/paperwork/faxmachine.dm
index d79e7a7782..eae9dc2e6e 100644
--- a/code/modules/paperwork/faxmachine.dm
+++ b/code/modules/paperwork/faxmachine.dm
@@ -36,8 +36,6 @@ GLOBAL_LIST_EMPTY(adminfaxes) //cache for faxes that have been sent to admins
GLOB.alldepartments |= department
/obj/machinery/photocopier/faxmachine/attack_hand(mob/user as mob)
- user.set_machine(src)
-
tgui_interact(user)
/obj/machinery/photocopier/faxmachine/verb/remove_card()
diff --git a/code/modules/paperwork/photocopier.dm b/code/modules/paperwork/photocopier.dm
index 69a789c006..b9e69b5f6a 100644
--- a/code/modules/paperwork/photocopier.dm
+++ b/code/modules/paperwork/photocopier.dm
@@ -31,8 +31,6 @@
return attack_hand(user)
/obj/machinery/photocopier/attack_hand(mob/user as mob)
- user.set_machine(src)
-
tgui_interact(user)
/obj/machinery/photocopier/tgui_interact(mob/user, datum/tgui/ui, datum/tgui/parent_ui)
diff --git a/code/modules/pda/pda.dm b/code/modules/pda/pda.dm
index f686235c5f..4ee3eaf470 100644
--- a/code/modules/pda/pda.dm
+++ b/code/modules/pda/pda.dm
@@ -432,9 +432,7 @@
if(id_check(user, 2))
to_chat(user, span_notice("You put the ID into \the [src]'s slot."))
add_overlay("pda-id")
- updateSelfDialog()//Update self dialog on success.
return //Return in case of failed check or when successful.
- updateSelfDialog()//For the non-input related code.
else if(istype(C, /obj/item/paicard) && !src.pai)
user.drop_item(src)
pai = C
diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm
index 145f00d5f1..05b56f21bd 100644
--- a/code/modules/power/cable.dm
+++ b/code/modules/power/cable.dm
@@ -991,7 +991,7 @@ GLOBAL_LIST_INIT(possible_cable_coil_colours, list(
src.add_fingerprint(user)
CC.add_fingerprint(user)
spawn(0)
- if (src && user.machine==src)
+ if (src && user.check_current_machine(src))
src.interact(user)
else
return
diff --git a/code/modules/reagents/machinery/chem_master.dm b/code/modules/reagents/machinery/chem_master.dm
index 4205f4ad37..7cb9695f81 100644
--- a/code/modules/reagents/machinery/chem_master.dm
+++ b/code/modules/reagents/machinery/chem_master.dm
@@ -79,7 +79,6 @@
/obj/machinery/chem_master/attack_hand(mob/user as mob)
if(stat & BROKEN)
return
- user.set_machine(src)
tgui_interact(user)
/obj/machinery/chem_master/ui_assets(mob/user)
@@ -396,7 +395,6 @@
return TRUE
add_fingerprint(ui.user)
- ui.user.set_machine(src)
. = TRUE
switch(action)
diff --git a/code/modules/refinery/equipment/smart_centrifuge.dm b/code/modules/refinery/equipment/smart_centrifuge.dm
index 159d638517..53581b8394 100644
--- a/code/modules/refinery/equipment/smart_centrifuge.dm
+++ b/code/modules/refinery/equipment/smart_centrifuge.dm
@@ -16,7 +16,7 @@
default_apply_parts()
/obj/machinery/smart_centrifuge/attackby(var/obj/item/O as obj, var/mob/user as mob)
- if(in_use)
+ if(working)
to_chat(user, "\The [src] is still spinning.")
return
if(default_deconstruction_screwdriver(user, O))
diff --git a/code/modules/resleeving/computers.dm b/code/modules/resleeving/computers.dm
index 2bd70a4c60..5c16d397b2 100644
--- a/code/modules/resleeving/computers.dm
+++ b/code/modules/resleeving/computers.dm
@@ -117,7 +117,6 @@
return attack_hand(user)
/obj/machinery/computer/transhuman/resleeving/attack_hand(mob/user as mob)
- user.set_machine(src)
add_fingerprint(user)
if(stat & (BROKEN|NOPOWER))
diff --git a/code/modules/scripting/IDE.dm b/code/modules/scripting/IDE.dm
index 6f79ee65c3..e1da8421ba 100644
--- a/code/modules/scripting/IDE.dm
+++ b/code/modules/scripting/IDE.dm
@@ -1,8 +1,9 @@
/client/verb/tcssave()
set hidden = 1
- if(mob.machine || issilicon(mob))
- if((istype(mob.machine, /obj/machinery/computer/telecomms/traffic) && (mob.machine in view(1, mob))) || issilicon(mob))
- var/obj/machinery/computer/telecomms/traffic/Machine = mob.machine
+ var/obj/machine = mob.get_current_machine()
+ if(machine || issilicon(mob))
+ if((istype(machine, /obj/machinery/computer/telecomms/traffic) && (machine in view(1, mob))) || issilicon(mob))
+ var/obj/machinery/computer/telecomms/traffic/Machine = machine
if(Machine.editingcode != mob)
return
@@ -27,9 +28,10 @@
/client/verb/tcscompile()
set hidden = 1
- if(mob.machine || issilicon(mob))
- if((istype(mob.machine, /obj/machinery/computer/telecomms/traffic) && (mob.machine in view(1, mob))) || (issilicon(mob) && istype(mob.machine, /obj/machinery/computer/telecomms/traffic) ))
- var/obj/machinery/computer/telecomms/traffic/Machine = mob.machine
+ var/obj/machine = mob.get_current_machine()
+ if(machine || issilicon(mob))
+ if((istype(machine, /obj/machinery/computer/telecomms/traffic) && (machine in view(1, mob))) || (issilicon(mob) && istype(machine, /obj/machinery/computer/telecomms/traffic) ))
+ var/obj/machinery/computer/telecomms/traffic/Machine = machine
if(Machine.editingcode != mob)
return
@@ -78,9 +80,10 @@
/client/verb/tcsrun()
set hidden = 1
- if(mob.machine || issilicon(mob))
- if((istype(mob.machine, /obj/machinery/computer/telecomms/traffic) && (mob.machine in view(1, mob))) || (issilicon(mob) && istype(mob.machine, /obj/machinery/computer/telecomms/traffic) ))
- var/obj/machinery/computer/telecomms/traffic/Machine = mob.machine
+ var/obj/machine = mob.get_current_machine()
+ if(machine || issilicon(mob))
+ if((istype(machine, /obj/machinery/computer/telecomms/traffic) && (machine in view(1, mob))) || (issilicon(mob) && istype(machine, /obj/machinery/computer/telecomms/traffic) ))
+ var/obj/machinery/computer/telecomms/traffic/Machine = machine
if(Machine.editingcode != mob)
return
@@ -144,9 +147,10 @@
/client/verb/exittcs()
set hidden = 1
- if(mob.machine || issilicon(mob))
- if((istype(mob.machine, /obj/machinery/computer/telecomms/traffic) && (mob.machine in view(1, mob))) || (issilicon(mob) && istype(mob.machine, /obj/machinery/computer/telecomms/traffic) ))
- var/obj/machinery/computer/telecomms/traffic/Machine = mob.machine
+ var/obj/machine = mob.get_current_machine()
+ if(machine || issilicon(mob))
+ if((istype(machine, /obj/machinery/computer/telecomms/traffic) && (machine in view(1, mob))) || (issilicon(mob) && istype(machine, /obj/machinery/computer/telecomms/traffic) ))
+ var/obj/machinery/computer/telecomms/traffic/Machine = machine
if(Machine.editingcode == mob)
Machine.storedcode = "[winget(mob, "tcscode", "text")]"
Machine.editingcode = null
@@ -156,9 +160,10 @@
/client/verb/tcsrevert()
set hidden = 1
- if(mob.machine || issilicon(mob))
- if((istype(mob.machine, /obj/machinery/computer/telecomms/traffic) && (mob.machine in view(1, mob))) || (issilicon(mob) && istype(mob.machine, /obj/machinery/computer/telecomms/traffic) ))
- var/obj/machinery/computer/telecomms/traffic/Machine = mob.machine
+ var/obj/machine = mob.get_current_machine()
+ if(machine || issilicon(mob))
+ if((istype(machine, /obj/machinery/computer/telecomms/traffic) && (machine in view(1, mob))) || (issilicon(mob) && istype(machine, /obj/machinery/computer/telecomms/traffic) ))
+ var/obj/machinery/computer/telecomms/traffic/Machine = machine
if(Machine.editingcode != mob)
return
@@ -185,9 +190,10 @@
/client/verb/tcsclearmem()
set hidden = 1
- if(mob.machine || issilicon(mob))
- if((istype(mob.machine, /obj/machinery/computer/telecomms/traffic) && (mob.machine in view(1, mob))) || (issilicon(mob) && istype(mob.machine, /obj/machinery/computer/telecomms/traffic) ))
- var/obj/machinery/computer/telecomms/traffic/Machine = mob.machine
+ var/obj/machine = mob.get_current_machine()
+ if(machine || issilicon(mob))
+ if((istype(machine, /obj/machinery/computer/telecomms/traffic) && (machine in view(1, mob))) || (issilicon(mob) && istype(machine, /obj/machinery/computer/telecomms/traffic) ))
+ var/obj/machinery/computer/telecomms/traffic/Machine = machine
if(Machine.editingcode != mob)
return
diff --git a/code/modules/stockmarket/computer.dm b/code/modules/stockmarket/computer.dm
index 90d6c3553d..3ff014f13e 100644
--- a/code/modules/stockmarket/computer.dm
+++ b/code/modules/stockmarket/computer.dm
@@ -342,7 +342,7 @@
return 1
if (!usr || (!(usr in range(1, src)) && iscarbon(usr)))
- usr.machine = src
+ usr.set_machine(src)
src.add_fingerprint(usr)
src.updateUsrDialog(usr)
diff --git a/code/modules/tgui/modules/ntos-only/uav.dm b/code/modules/tgui/modules/ntos-only/uav.dm
index d1c1b8533d..c24ca726ed 100644
--- a/code/modules/tgui/modules/ntos-only/uav.dm
+++ b/code/modules/tgui/modules/ntos-only/uav.dm
@@ -177,7 +177,7 @@
if(!current_uav)
return
- if(user.machine != tgui_host())
+ if(!user.check_current_machine(tgui_host()))
user.set_machine(tgui_host())
current_uav.add_master(user)
LAZYDISTINCTADD(viewers, WEAKREF(user))
diff --git a/code/modules/tgui/modules/overmap.dm b/code/modules/tgui/modules/overmap.dm
index f9fca8daa0..7e93efadc5 100644
--- a/code/modules/tgui/modules/overmap.dm
+++ b/code/modules/tgui/modules/overmap.dm
@@ -31,7 +31,7 @@
/datum/tgui_module/ship/tgui_status(mob/user)
. = ..()
- if(viewing_overmap(user) && (user.machine != src))
+ if(viewing_overmap(user) && (!user.check_current_machine(src)))
user.reset_perspective()
/datum/tgui_module/ship/tgui_close(mob/user)
diff --git a/code/modules/tgui/tgui.dm b/code/modules/tgui/tgui.dm
index 51627b227a..a788a7d947 100644
--- a/code/modules/tgui/tgui.dm
+++ b/code/modules/tgui/tgui.dm
@@ -175,6 +175,9 @@
if(user.client)
terminate_byondui_elements()
+ // Unset machine just to be sure.
+ user.unset_machine()
+
state = null
if(parent_ui)
parent_ui.children -= src
diff --git a/code/modules/xenoarcheaology/tools/artifact_harvester.dm b/code/modules/xenoarcheaology/tools/artifact_harvester.dm
index 2ceb69d098..0f4c77684f 100644
--- a/code/modules/xenoarcheaology/tools/artifact_harvester.dm
+++ b/code/modules/xenoarcheaology/tools/artifact_harvester.dm
@@ -285,7 +285,7 @@
if(inserted_battery.battery_effect.effect == EFFECT_TOUCH)
var/list/nearby = viewers(1, src)
for(var/mob/M in nearby)
- if(M.machine == src)
+ if(M.check_current_machine(src))
inserted_battery.battery_effect.DoEffectTouch(M)
//if there's no charge left, finish
diff --git a/vorestation.dme b/vorestation.dme
index d3caec512f..ac16658c02 100644
--- a/vorestation.dme
+++ b/vorestation.dme
@@ -643,6 +643,7 @@
#include "code\datums\components\disabilities\rotting.dm"
#include "code\datums\components\disabilities\tourettes.dm"
#include "code\datums\components\machinery\disposal_connection.dm"
+#include "code\datums\components\materials\machine_shim.dm"
#include "code\datums\components\materials\material_container.dm"
#include "code\datums\components\materials\remote_materials.dm"
#include "code\datums\components\reagent_hose\connector.dm"