From 94291fb2675bd335b1f25274c4cde37000603afc Mon Sep 17 00:00:00 2001 From: NovaBot <154629622+NovaBot13@users.noreply.github.com> Date: Sat, 27 Apr 2024 23:02:38 -0400 Subject: [PATCH] [MIRROR] Turf weakref persists in changeturf / Fix plasma cutters (#2209) * Turf weakref persists in changeturf / Fix plasma cutters (#82906) ## About The Pull Request Turf references don't change so logically, turf weakrefs wouldn't change if the turf changes. By not doing this this can cause bugs: See #82886 . (This Fixes #82886) (Projectiles hold a list of weakrefs to atoms hit to determine what they have already hit. Because turf weakrefs reset, we could "hit" the same turf twice if it destroyed the turf. Old behavior - this was fine but now that they're weakrefs, we get two weakref datums in the list that point to the same ref.) Less hacky alternative to #82901 . (Closes #82901) ## Changelog :cl: Melbert fix: Plasma cutters work again /:cl: * Turf weakref persists in changeturf / Fix plasma cutters --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- code/game/turfs/change_turf.dm | 4 ++++ code/modules/projectiles/projectile.dm | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/code/game/turfs/change_turf.dm b/code/game/turfs/change_turf.dm index 2c2d5712b46..513bdc3d0b2 100644 --- a/code/game/turfs/change_turf.dm +++ b/code/game/turfs/change_turf.dm @@ -96,6 +96,8 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( var/list/old_baseturfs = baseturfs var/old_type = type + var/datum/weakref/old_ref = weak_reference + weak_reference = null var/list/post_change_callbacks = list() SEND_SIGNAL(src, COMSIG_TURF_CHANGE, path, new_baseturfs, flags, post_change_callbacks) @@ -142,6 +144,8 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( lattice_underneath = old_lattice_underneath + new_turf.weak_reference = old_ref + if(SSlighting.initialized) // Space tiles should never have lighting objects if(!space_lit) diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 6a699f414b3..b32d58b8dd1 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -1205,7 +1205,6 @@ var/turf/startloc = get_turf(src) var/obj/projectile/bullet = new projectile_type(startloc) bullet.starting = startloc - var/list/ignore = list() for (var/atom/thing as anything in ignore_targets) bullet.impacted[WEAKREF(thing)] = TRUE bullet.firer = firer || src