Fix runtimes with REMOVE_TRAITS_IN (#89344)

## About The Pull Request

ok so `REMOVE_TRAITS_IN` would sometimes run with like `type mismatch:
null -= /list (/list)`

credit to @RikuTheKiller for actually figuring this out and fixing it,
here's their explaination on what caused the issue:
> okay so
> its due to linked traits
> like knocked out which adds other traits
> when knocked out is removed, it sends a removed signal
> but sending that signal modifies the list mid for loop
> so now when it tries to index it on the next iteration with a trait
key thats already gone
> it returns null, and tries to remove a list from a null
> and it runtimes

## Why It's Good For The Game

`REMOVE_TRAITS_IN` is a handy macro, and it'd be nice if it reliably
worked

## Changelog

no user-facing changes
This commit is contained in:
Lucy
2025-02-05 14:06:11 -05:00
committed by GitHub
parent 25eb08420a
commit e7efdddf48

View File

@@ -74,7 +74,9 @@
var/list/_S = sources; \
if (_L) { \
for (var/_T in _L) { \
_L[_T] &= _S;\
if (_L[_T]) { \
_L[_T] &= _S; \
}; \
if (!length(_L[_T])) { \
_L -= _T; \
SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(_T), _T); \
@@ -97,7 +99,9 @@
}; \
if (_L) { \
for (var/_T in _L) { \
_L[_T] -= _S;\
if (_L[_T]) { \
_L[_T] -= _S; \
}; \
if (!length(_L[_T])) { \
_L -= _T; \
SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(_T)); \