mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 05:30:05 +01:00
Fixes lua breaking when registering signals on turfs (#83018)
## About The Pull Request Signals don't get removed on turfs when they're deleted. This fixes that so that it is reflected in lua as well. ## Why It's Good For The Game Lua bugfixes ## Changelog 🆑 fix: Fixed lua scripts breaking when turfs with registered signals get deleted. /🆑 --------- Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>
This commit is contained in:
co-authored by
Watermelon914
parent
0ca5dcb61b
commit
cc1df2405e
+7
-1
@@ -100,7 +100,8 @@ function SS13.register_signal(datum, signal, func)
|
||||
callback:call_proc("RegisterSignal", datum, signal, "Invoke")
|
||||
local path = { "__SS13_signal_handlers", datumWeakRef, signal, callbackWeakRef, "func" }
|
||||
callback.vars.arguments = { path }
|
||||
if not __SS13_signal_handlers[datumWeakRef]._cleanup then
|
||||
-- Turfs don't remove their signals on deletion.
|
||||
if not __SS13_signal_handlers[datumWeakRef]._cleanup and not SS13.istype(datum, "/turf") then
|
||||
local cleanupCallback = SS13.new("/datum/callback", SS13.state, "call_function_return_first")
|
||||
local cleanupPath = { "__SS13_signal_handlers", datumWeakRef, "_cleanup"}
|
||||
cleanupCallback.vars.arguments = { cleanupPath }
|
||||
@@ -134,6 +135,11 @@ function SS13.unregister_signal(datum, signal, callback)
|
||||
local callbackWeakRef = dm.global_proc("WEAKREF", handler_callback)
|
||||
if not SS13.istype(datum, "/datum/weakref") then
|
||||
handler_callback:call_proc("UnregisterSignal", datum, signal)
|
||||
else
|
||||
local actualDatum = datum:call_proc("hard_resolve")
|
||||
if SS13.is_valid(actualDatum) then
|
||||
handler_callback:call_proc("UnregisterSignal", actualDatum, signal)
|
||||
end
|
||||
end
|
||||
SS13.stop_tracking(handler_callback)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user