Skip to content

Commit

Permalink
Fix connect_loc runtiming for multiple turfs (#58269)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mothblocks authored and Gboster-0 committed Oct 20, 2023
1 parent f62d42a commit b50713c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion code/datums/elements/connect_loc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
RegisterSignal(target.loc, COMSIG_TURF_CHANGE, .proc/on_turf_change)

/datum/element/connect_loc/proc/unregister_signals(atom/movable/target, atom/old_loc)
LAZYREMOVE(targets[old_loc], target)
targets[old_loc] -= target
if (length(targets[old_loc]) == 0)
targets -= old_loc

for (var/signal in connections)
target.UnregisterSignal(old_loc, signal)
Expand Down
10 changes: 10 additions & 0 deletions code/modules/unit_tests/connect_loc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
run_loc_floor_bottom_left.ChangeTurf(old_turf_type)
return ..()

/// Tests that multiple objects can have connect_loc on the same turf without runtimes.
/datum/unit_test/connect_loc_multiple_on_turf

/datum/unit_test/connect_loc_multiple_on_turf/Run()
var/obj/item/watches_mock_calls/watcher_one = allocate(/obj/item/watches_mock_calls, run_loc_floor_bottom_left)
qdel(watcher_one)

var/obj/item/watches_mock_calls/watcher_two = allocate(/obj/item/watches_mock_calls, run_loc_floor_bottom_left)
qdel(watcher_two)

/obj/item/watches_mock_calls
var/times_called

Expand Down

0 comments on commit b50713c

Please sign in to comment.