Lua API: Unify server env checks and fix missing ones (#16457)

A few functions tried to dereference a ServerEnvironment nullptr by
calling 'getEnv()'. This change makes use of a macro where possible.

This also cleans up incorrect macro uses, with no functional difference.
This commit is contained in:
SmallJoker
2025-09-04 19:00:23 +02:00
committed by GitHub
parent d24a7001ab
commit 56bc7814de
6 changed files with 36 additions and 55 deletions

View File

@@ -44,8 +44,11 @@
#define GET_ENV_PTR_NO_MAP_LOCK \
DEBUG_ASSERT_NO_CLIENTAPI; \
ServerEnvironment *env = (ServerEnvironment *)getEnv(L); \
if (env == NULL) \
return 0
if (!env) { \
log_deprecated(L, "Calling this function during script init is disallowed.", 1); \
return 0; \
} \
((void)0)
// Retrieve ServerEnvironment pointer as `env`
#define GET_ENV_PTR \