From 7b46cef07cd930055743904248715d54ac6a631c Mon Sep 17 00:00:00 2001 From: Y0SH1M4S73R Date: Tue, 3 Sep 2024 11:41:17 -0400 Subject: [PATCH] Fixes runtimes caused by dreamluau's absence (#86171) ## About The Pull Request Currently, if dreamluau is absent (which it might be on linux instances that don't automatically download it), every `call_ext` call runtimes, crashing the calling proc. This fixes that by using a flag that skips calling `call_ext` if unset. ## Why It's Good For The Game Apparently this could really bork the garbage collection subsystem, so fixing it is a really good idea. ## Changelog Does this even count as a player-facing change? --- code/__HELPERS/_dreamluau.dm | 8 ++++++-- code/modules/admin/verbs/lua/lua_state.dm | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/code/__HELPERS/_dreamluau.dm b/code/__HELPERS/_dreamluau.dm index 196774d6a88..1e1e315a2ae 100644 --- a/code/__HELPERS/_dreamluau.dm +++ b/code/__HELPERS/_dreamluau.dm @@ -1,8 +1,12 @@ /* This comment bypasses grep checks */ /var/__dreamluau -#define DREAMLUAU (world.system_type == MS_WINDOWS ? "dreamluau.dll" : (__dreamluau || (__dreamluau = __detect_auxtools("dreamluau")))) +/* This comment also bypasses grep checks */ /var/__dreamluau_exists -#define DREAMLUAU_CALL(func) call_ext(DREAMLUAU, "byond:[#func]") +#define DREAMLUAU_EXISTS (__dreamluau_exists ||= fexists(DREAMLUAU)) + +#define DREAMLUAU (world.system_type == MS_WINDOWS ? "dreamluau.dll" : (__dreamluau ||= __detect_auxtools("dreamluau"))) + +#define DREAMLUAU_CALL(func) (!DREAMLUAU_EXISTS) ? null : call_ext(DREAMLUAU, "byond:[#func]") /** * All of the following functions will return a string if the underlying rust code returns an error or a wrapped panic. diff --git a/code/modules/admin/verbs/lua/lua_state.dm b/code/modules/admin/verbs/lua/lua_state.dm index 577b0e365c2..30bc21c83b2 100644 --- a/code/modules/admin/verbs/lua/lua_state.dm +++ b/code/modules/admin/verbs/lua/lua_state.dm @@ -41,7 +41,10 @@ GLOBAL_PROTECT(lua_state_stack) return display_name = _name internal_id = DREAMLUAU_NEW_STATE() - if(!isnum(internal_id)) + if(isnull(internal_id)) + stack_trace("dreamluau is not loaded") + qdel(src) + else if(!isnum(internal_id)) stack_trace(internal_id) qdel(src)