Skip to content

Commit

Permalink
[MIRROR] Turf weakref persists in changeturf / Fix plasma cutters (#2209
Browse files Browse the repository at this point in the history
)

* 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 <[email protected]>
  • Loading branch information
2 people authored and StealsThePRs committed Apr 28, 2024
1 parent f7f0a72 commit 94291fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions code/game/turfs/change_turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 94291fb

Please sign in to comment.