Fixes Multitool Buffer Clearing and Adds Multitool Linking Balloon Alerts (#78309)

## About The Pull Request
I was working on a feature that required the buffer of a multitool to be
cleared out after linking two devices, when I noticed it wasn't possible
to clear the multitool's buffer. The change to multitools in #77639 made
it impossible to set the buffer of a multitool to null without
destroying the stored object, yet many objects still tried to have the
multitool clear it's buffer after a successful linkage. This creates a
new proc, clear_buffer() dedicated just to clearing the buffer of a
multitool.

Also made all of the multitool linkage messages balloon alerts.

If there's any issues or things I can improve please let me know, I'm a
bit new to BYOND and DM but I'm working on learning so I can make some
more ambitious projects! _(I think I got the signaling right)_
## Why It's Good For The Game
Some objects aren't meant to be saved in the multitool's buffer after
the initial linking, this should fix that.
Also balloon alerts are nice.
## Changelog
🆑
fix: Nanotrasen has finally recalled their faulty multitools and
replaced them with working ones! The multitool's buffer now properly
clears itself.
qol: Moved multitool link messages to balloon alerts
/🆑

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
Moose1002
2023-09-18 18:18:06 +00:00
committed by GitHub
co-authored by Ghom
parent 439b1dcdc0
commit 8464ef9727
17 changed files with 35 additions and 23 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
return
var/obj/item/multitool/multitool = tool
multitool.set_buffer(src)
to_chat(user, span_notice("You save the data in the [multitool.name]'s buffer."))
balloon_alert(user, "saved to multitool buffer")
return TOOL_ACT_TOOLTYPE_SUCCESS
+1 -1
View File
@@ -78,7 +78,7 @@
return
var/obj/item/multitool/M = I
M.set_buffer(src)
to_chat(user, span_notice("You save the data in the [I.name]'s buffer."))
balloon_alert(user, "saved to multitool buffer")
return 1
if(default_deconstruction_crowbar(I))
+1 -1
View File
@@ -37,7 +37,7 @@
return
var/obj/item/multitool/multitool = tool
multitool.set_buffer(src)
to_chat(user, span_notice("You save the data in the [multitool.name]'s buffer."))
balloon_alert(user, "saved to multitool buffer")
return TRUE
/obj/machinery/mechpad/wirecutter_act(mob/living/user, obj/item/tool)
@@ -351,7 +351,7 @@ DEFINE_BITFIELD(turret_flags, list(
return
var/obj/item/multitool/M = I
M.set_buffer(src)
to_chat(user, span_notice("You add [src] to multitool buffer."))
balloon_alert(user, "saved to multitool buffer")
else
return ..()
@@ -66,7 +66,7 @@
return
var/obj/item/multitool/M = I
M.set_buffer(parent_turret)
to_chat(user, span_notice("You add [parent_turret] to multitool buffer."))
balloon_alert(user, "saved to multitool buffer")
return
return ..()
+4 -3
View File
@@ -63,6 +63,7 @@
return
var/obj/item/multitool/M = I
M.set_buffer(src)
balloon_alert(user, "saved to multitool buffer")
to_chat(user, span_notice("You save the data in [I]'s buffer. It can now be saved to pads with closed panels."))
return TRUE
else if(I.tool_behaviour == TOOL_MULTITOOL)
@@ -71,14 +72,14 @@
var/obj/item/multitool/M = I
if(istype(M.buffer, /obj/machinery/quantumpad))
if(M.buffer == src)
to_chat(user, span_warning("You cannot link a pad to itself!"))
balloon_alert(user, "cannot link to self!")
return TRUE
else
linked_pad = M.buffer
to_chat(user, span_notice("You link [src] to the one in [I]'s buffer."))
balloon_alert(user, "data uploaded from buffer")
return TRUE
else
to_chat(user, span_warning("There is no quantum pad data saved in [I]'s buffer!"))
balloon_alert(user, "no quantum pad data found!")
return TRUE
else if(istype(I, /obj/item/quantum_keycard))
+2 -2
View File
@@ -166,13 +166,13 @@
var/obj/item/multitool/M = W
if(panel_open)
M.set_buffer(src)
to_chat(user, span_notice("You download the data to the [W.name]'s buffer."))
balloon_alert(user, "saved to multitool buffer")
else
if(M.buffer && istype(M.buffer, /obj/machinery/teleport/station) && M.buffer != src)
if(linked_stations.len < efficiency)
linked_stations.Add(M.buffer)
M.set_buffer(null)
to_chat(user, span_notice("You upload the data from the [W.name]'s buffer."))
balloon_alert(user, "data uploaded from buffer")
else
to_chat(user, span_alert("This station can't hold more information, try to use better parts."))
return
+14 -3
View File
@@ -41,14 +41,25 @@
user.visible_message(span_suicide("[user] puts the [src] to [user.p_their()] chest. It looks like [user.p_theyre()] trying to pulse [user.p_their()] heart off!"))
return OXYLOSS//theres a reason it wasn't recommended by doctors
/**
* Sets the multitool internal object buffer
*
* Arguments:
* * buffer - the new object to assign to the multitool's buffer
*/
/obj/item/multitool/proc/set_buffer(datum/buffer)
if(src.buffer)
UnregisterSignal(src.buffer, COMSIG_QDELETING)
if(QDELETED(buffer))
return
src.buffer = buffer
RegisterSignal(buffer, COMSIG_QDELETING, PROC_REF(on_buffer_del))
if(!QDELETED(buffer))
RegisterSignal(buffer, COMSIG_QDELETING, PROC_REF(on_buffer_del))
/**
* Called when the buffer's stored object is deleted
*
* This proc does not clear the buffer of the multitool, it is here to
* handle the deletion of the object the buffer references
*/
/obj/item/multitool/proc/on_buffer_del(datum/source)
SIGNAL_HANDLER
buffer = null
@@ -183,8 +183,8 @@
/obj/machinery/piratepad/multitool_act(mob/living/user, obj/item/multitool/I)
. = ..()
if (istype(I))
to_chat(user, span_notice("You register [src] in [I]s buffer."))
I.set_buffer(src)
balloon_alert(user, "saved to multitool buffer")
return TRUE
/obj/machinery/piratepad/screwdriver_act_secondary(mob/living/user, obj/item/screwdriver/screw)
@@ -123,7 +123,7 @@ GLOBAL_LIST_EMPTY_TYPED(bluespace_senders, /obj/machinery/atmospherics/component
/obj/machinery/atmospherics/components/unary/bluespace_sender/multitool_act(mob/living/user, obj/item/item)
var/obj/item/multitool/multitool = item
multitool.set_buffer(src)
to_chat(user, span_notice("You store linkage information in [item]'s buffer."))
balloon_alert(user, "saved to multitool buffer")
return TRUE
/obj/machinery/atmospherics/components/unary/bluespace_sender/wrench_act(mob/living/user, obj/item/tool)
@@ -98,6 +98,6 @@ GLOBAL_LIST_EMPTY(monkey_recyclers)
/obj/machinery/monkey_recycler/multitool_act(mob/living/user, obj/item/multitool/I)
. = ..()
if(istype(I))
to_chat(user, span_notice("You log [src] in the multitool's buffer."))
I.set_buffer(src)
balloon_alert(user, "saved to multitool buffer")
return TRUE
+1 -1
View File
@@ -165,8 +165,8 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
/obj/machinery/ore_silo/multitool_act(mob/living/user, obj/item/multitool/I)
. = ..()
if (istype(I))
to_chat(user, span_notice("You log [src] in the multitool's buffer."))
I.set_buffer(src)
balloon_alert(user, "saved to multitool buffer")
return TRUE
/**
+1 -1
View File
@@ -27,7 +27,7 @@
return
var/obj/item/multitool/M = I
M.set_buffer(src)
to_chat(user, span_notice("You store linkage information in [I]'s buffer."))
balloon_alert(user, "saved to multitool buffer")
return TRUE
/obj/machinery/mineral/stacking_unit_console/ui_interact(mob/user, datum/tgui/ui)
+1 -1
View File
@@ -56,7 +56,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
return
var/obj/item/multitool/M = I
M.set_buffer(src)
to_chat(user, span_notice("You store linkage information in [I]'s buffer."))
balloon_alert(user, "saved to multitool buffer")
return TRUE
/obj/machinery/ticket_machine/emag_act(mob/user, obj/item/card/emag/emag_card) //Emag the ticket machine to dispense burning tickets, as well as randomize its number to destroy the HoP's mind.
+1 -1
View File
@@ -73,7 +73,7 @@
var/obj/item/multitool/M = I
M.set_buffer(src)
to_chat(user, span_notice("You store linkage information in [I]'s buffer."))
balloon_alert(user, "saved to multitool buffer")
return TRUE
/obj/machinery/plumbing/receiver/process(seconds_per_tick)
+1 -1
View File
@@ -109,7 +109,7 @@
if(!stored_research)
return
tool.set_buffer(stored_research)
to_chat(user, span_notice("Stored [src]'s techweb information in [tool]."))
balloon_alert(user, "saved to multitool buffer")
return TRUE
/// Master R&D server. As long as this still exists and still holds the HDD for the theft objective, research points generate at normal speed. Destroy it or an antag steals the HDD? Half research speed.
+2 -2
View File
@@ -55,7 +55,7 @@ GLOBAL_VAR_INIT(bsa_unlock, FALSE)
return
var/obj/item/multitool/M = I
M.set_buffer(src)
to_chat(user, span_notice("You store linkage information in [I]'s buffer."))
balloon_alert(user, "saved to multitool buffer")
return TRUE
/obj/machinery/bsa/front
@@ -72,7 +72,7 @@ GLOBAL_VAR_INIT(bsa_unlock, FALSE)
return
var/obj/item/multitool/M = I
M.set_buffer(src)
to_chat(user, span_notice("You store linkage information in [I]'s buffer."))
balloon_alert(user, "saved to multitool buffer")
return TRUE
/obj/machinery/bsa/middle