Skip to content

Commit

Permalink
Merge pull request Baystation12#35044 from SierraKomodo/bugfix/turf-c…
Browse files Browse the repository at this point in the history
…hange-debug-spam

Fix debug log spam when turfs change
  • Loading branch information
SierraKomodo authored Jan 11, 2025
2 parents fc84316 + 1c89a25 commit 828410f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions code/datums/proximity_trigger/proximity_trigger.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ var/global/const/PROXIMITY_EXCLUDE_HOLDER_TURF = 1 // When acquiring turfs to mo

for(var/t in (turfs_in_range - new_turfs))
GLOB.opacity_set_event.unregister(t, src, /datum/proximity_trigger/proc/on_turf_visibility_changed)
GLOB.destroyed_event.unregister(t, src, /datum/proximity_trigger/proc/on_turf_destroyed)
for(var/t in (new_turfs - turfs_in_range))
GLOB.opacity_set_event.register(t, src, /datum/proximity_trigger/proc/on_turf_visibility_changed)
GLOB.destroyed_event.register(t, src, /datum/proximity_trigger/proc/on_turf_destroyed)

turfs_in_range = new_turfs
on_turf_visibility_changed()
Expand All @@ -97,14 +99,23 @@ var/global/const/PROXIMITY_EXCLUDE_HOLDER_TURF = 1 // When acquiring turfs to mo

for(var/t in turfs_in_range)
GLOB.opacity_set_event.unregister(t, src, /datum/proximity_trigger/proc/on_turf_visibility_changed)
GLOB.destroyed_event.unregister(t, src, /datum/proximity_trigger/proc/on_turf_destroyed)
for(var/t in seen_turfs_)
GLOB.entered_event.unregister(t, src, /datum/proximity_trigger/proc/on_turf_entered)
GLOB.destroyed_event.unregister(t, src, /datum/proximity_trigger/proc/on_turf_destroyed)

call(proc_owner, on_turfs_changed)(seen_turfs_.Copy(), list())

turfs_in_range.Cut()
seen_turfs_.Cut()

/datum/proximity_trigger/proc/on_turf_destroyed(turf/destroyed)
GLOB.opacity_set_event.unregister(destroyed, src, /datum/proximity_trigger/proc/on_turf_visibility_changed)
GLOB.entered_event.unregister(destroyed, src, /datum/proximity_trigger/proc/on_turf_entered)
GLOB.destroyed_event.unregister(destroyed, src, /datum/proximity_trigger/proc/on_turf_destroyed)
// The cycle of when things run mean this is one of the only ways to make sure we don't encounter the debug log spam
addtimer(new Callback(src, .proc/register_turfs), 1, TIMER_UNIQUE | TIMER_OVERRIDE)

/datum/proximity_trigger/proc/on_turf_visibility_changed()
var/list/new_seen_turfs_ = get_seen_turfs()
if(listequal(seen_turfs_, new_seen_turfs_))
Expand Down

0 comments on commit 828410f

Please sign in to comment.