From cfbae07813dcc202bdff9638f434365825e0d6a2 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 6 Oct 2025 22:43:25 -0500 Subject: [PATCH] Fix admin debug gps to be toggable and reset the affected turfs (#93226) ## About The Pull Request This fixes the admin debug gps tool so that it must be turned on to activate. (it spawns off now) Also when it is toggled on/off, it resets the colored turfs to their initial state. ## Why It's Good For The Game When someone would equip the admin outfit, the debug gps would start processing immediately, despite it not being in your hand, or even turned on. This adds some restrictions so that you have to manually activate it and allows the turfs to reset. ## Changelog :cl: fix: The admin debug gps is now turned off by default and toggling it will reset the affected turfs. admin: Equipping the admin outfit will no longer automatically trigger the debug gps effect. /:cl: --- code/datums/components/gps.dm | 48 ++++++++++++++++++++++++-- code/game/objects/items/devices/gps.dm | 38 +++++--------------- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/code/datums/components/gps.dm b/code/datums/components/gps.dm index e1d620222cb..a9e4a3b82f9 100644 --- a/code/datums/components/gps.dm +++ b/code/datums/components/gps.dm @@ -5,11 +5,13 @@ GLOBAL_LIST_EMPTY(GPS_list) var/gpstag = "COM0" var/tracking = TRUE var/emped = FALSE + var/list/turf/tagged -/datum/component/gps/Initialize(_gpstag = "COM0") +/datum/component/gps/Initialize(_gpstag = "COM0", _tracking = TRUE) if(!isatom(parent)) return COMPONENT_INCOMPATIBLE gpstag = _gpstag + tracking = _tracking GLOB.GPS_list += src /datum/component/gps/Destroy() @@ -32,8 +34,9 @@ GLOBAL_LIST_EMPTY(GPS_list) var/global_mode = TRUE //If disabled, only GPS signals of the same Z level are shown /// UI state of GPS, altering when it can be used. var/datum/ui_state/state = null + var/debug_mode = FALSE -/datum/component/gps/item/Initialize(_gpstag = "COM0", emp_proof = FALSE, state = null, overlay_state = "working") +/datum/component/gps/item/Initialize(_gpstag = "COM0", _tracking = TRUE, emp_proof = FALSE, state = null, overlay_state = "working", debug = FALSE) . = ..() if(. == COMPONENT_INCOMPATIBLE || !isitem(parent)) return COMPONENT_INCOMPATIBLE @@ -41,17 +44,28 @@ GLOBAL_LIST_EMPTY(GPS_list) if(isnull(state)) state = GLOB.default_state src.state = state + debug_mode = debug var/atom/A = parent if(overlay_state) A.add_overlay(overlay_state) A.name = "[initial(A.name)] ([gpstag])" RegisterSignal(parent, COMSIG_ITEM_ATTACK_SELF, PROC_REF(interact)) + + if(debug_mode && tracking) + RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(tag_the_floor)) + if(!emp_proof) RegisterSignal(parent, COMSIG_ATOM_EMP_ACT, PROC_REF(on_emp_act)) + RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine)) RegisterSignal(parent, COMSIG_CLICK_ALT, PROC_REF(on_click_alt)) +/datum/component/gps/item/Destroy() + if(tagged) + clear() + return ..() + ///Called on COMSIG_ITEM_ATTACK_SELF /datum/component/gps/item/proc/interact(datum/source, mob/user) SIGNAL_HANDLER @@ -59,6 +73,29 @@ GLOBAL_LIST_EMPTY(GPS_list) if(user) INVOKE_ASYNC(src, PROC_REF(ui_interact), user) +///Called on COMSIG_MOVABLE_MOVED +/datum/component/gps/item/proc/tag_the_floor(atom/movable/mover, turf/old_loc) + SIGNAL_HANDLER + + if(!debug_mode) + return + + var/turf/tagged_turf = get_turf(mover) + if(tagged_turf) + tagged_turf.color = RANDOM_COLOUR + tagged_turf.maptext = MAPTEXT("[tagged_turf.x],[tagged_turf.y],[tagged_turf.z]") + LAZYOR(tagged, tagged_turf) + +///Called on COMSIG_MOVABLE_MOVED +/datum/component/gps/item/proc/clear() + SIGNAL_HANDLER + + while(tagged.len) + var/turf/tagged_turf = pop(tagged) + tagged_turf.color = initial(tagged_turf.color) + tagged_turf.maptext = initial(tagged_turf.maptext) + LAZYNULL(tagged) + ///Called on COMSIG_ATOM_EXAMINE /datum/component/gps/item/proc/on_examine(datum/source, mob/user, list/examine_list) SIGNAL_HANDLER @@ -108,6 +145,13 @@ GLOBAL_LIST_EMPTY(GPS_list) to_chat(user, span_notice("[parent] is now tracking, and visible to other GPS devices.")) tracking = TRUE + if(debug_mode) + if(tracking) + RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(tag_the_floor)) + else + UnregisterSignal(parent, COMSIG_MOVABLE_MOVED) + clear() + /datum/component/gps/item/ui_interact(mob/user, datum/tgui/ui) if(emped) to_chat(user, span_hear("[parent] fizzles weakly.")) diff --git a/code/game/objects/items/devices/gps.dm b/code/game/objects/items/devices/gps.dm index 7b17efb9f79..7b8257d9ede 100644 --- a/code/game/objects/items/devices/gps.dm +++ b/code/game/objects/items/devices/gps.dm @@ -12,6 +12,9 @@ slot_flags = ITEM_SLOT_BELT obj_flags = UNIQUE_RENAME var/gpstag + var/tracking_on = TRUE + var/debug_mode = FALSE + var/overlay_icon = "working" /obj/item/gps/Initialize(mapload) . = ..() @@ -19,7 +22,7 @@ /// Adds the GPS component to this item. /obj/item/gps/proc/add_gps_component() - AddComponent(/datum/component/gps/item, gpstag) + AddComponent(/datum/component/gps/item, gpstag, tracking_on, overlay_state = overlay_icon, debug = debug_mode) /obj/item/gps/spaceruin gpstag = SPACE_SIGNAL_GPSTAG @@ -60,33 +63,8 @@ name = "visible GPS" gpstag = "ADMIN" desc = "This admin-spawn GPS unit leaves the coordinates visible \ - on any turf that it passes over, for debugging. Especially useful \ + on any turf that it passes over while being dragged on the floor. Especially useful \ for marking the area around the transition edges." - var/list/turf/tagged - -/obj/item/gps/visible_debug/Initialize(mapload) - . = ..() - tagged = list() - START_PROCESSING(SSfastprocess, src) - -/obj/item/gps/visible_debug/process() - var/turf/T = get_turf(src) - if(T) - // I assume it's faster to color,tag and OR the turf in, rather - // then checking if its there - T.color = RANDOM_COLOUR - T.maptext = MAPTEXT("[T.x],[T.y],[T.z]") - tagged |= T - -/obj/item/gps/visible_debug/proc/clear() - while(tagged.len) - var/turf/T = pop(tagged) - T.color = initial(T.color) - T.maptext = initial(T.maptext) - -/obj/item/gps/visible_debug/Destroy() - if(tagged) - clear() - tagged = null - STOP_PROCESSING(SSfastprocess, src) - . = ..() + tracking_on = FALSE + debug_mode = TRUE + overlay_icon = FALSE