[MIRROR] Fixes SS13.register_signal throwing unclear errors when called on deleted datums (#27293)

* Cleans up the SS13_base lua file and adds a new lua file for easily handling multiple signals on different objects. (#82458)

## About The Pull Request
Cleaned up the SS13.register_signal and SS13.unregister_signal, removing
the weird list shifting.
Also adds a new lua file that can be included for the use of registering
different signals on various datums and being able to clear them all in
1 function.
Removed the make_easy_clear_function option when registering a signal
via lua because I don't think it's used by anyone and it lacks any sort
of versatility. Users can just create their own function for clearing
signals from a datum.

Also updates the documentation for HARDDELETES.md as
COMSIG_PARENT_QDELETING was renamed to COMSIG_QDELETING

## Why It's Good For The Game
New handler file makes registering signals in batches a lot easier if
you want to clear them in one go without clearing unrelated callbacks on
the same datum. The list shifting in SS13.register_signal had pretty
significant performance problems, so removing that will make registering
and unregistering signals faster.

## Changelog
🆑
admin: LUA - Adds a new library called handler_group. Include it in your
files by doing require('handler_group')
/🆑

---------

Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>

* Fixes SS13.register_signal throwing unclear errors when called on deleted datums (#82597)

## About The Pull Request
See title

## Why It's Good For The Game
More descriptive error message

## Changelog
🆑
fix: LUA: Registering a signal on a deleted datum will throw a more
descriptive error message.
/🆑

---------

Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>

---------

Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com>
Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>
This commit is contained in:
SkyratBot
2024-04-18 10:21:35 +02:00
committed by GitHub
parent 909dbec657
commit 7d0d702ec7
6 changed files with 189 additions and 80 deletions
+6 -4
View File
@@ -1,6 +1,8 @@
local SS13 = require("SS13_base")
local state = require("state")
local Timer = {}
local SSlua = dm.global_vars:get_var("SSlua")
__Timer_timers = __Timer_timers or {}
__Timer_callbacks = __Timer_callbacks or {}
@@ -35,7 +37,7 @@ function __stop_internal_timer(func)
end
__Timer_timer_processing = __Timer_timer_processing or false
SS13.state:set_var("timer_enabled", 1)
state.state:set_var("timer_enabled", 1)
__Timer_timer_process = function(seconds_per_tick)
if __Timer_timer_processing then
return 0
@@ -50,7 +52,7 @@ __Timer_timer_process = function(seconds_per_tick)
sleep()
end
if time >= timeData.executeTime then
SS13.state:get_var("functions_to_execute"):add(func)
state.state:get_var("functions_to_execute"):add(func)
timeData.executing = true
end
end
@@ -61,7 +63,7 @@ end
function Timer.wait(time)
local next_yield_index = __next_yield_index
__add_internal_timer(function()
SS13.SSlua:call_proc("queue_resume", SS13.state, next_yield_index)
SSlua:call_proc("queue_resume", state.state, next_yield_index)
end, time * 10, false)
coroutine.yield()
end