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

@@ -15,14 +15,8 @@
// common start: ensure auth db
AuthDatabase *ModApiAuth::getAuthDb(lua_State *L)
{
ServerEnvironment *server_environment =
dynamic_cast<ServerEnvironment *>(getEnv(L));
if (!server_environment) {
luaL_error(L, "Attempt to access an auth function but the auth"
" system is yet not initialized. This causes bugs.");
return nullptr;
}
return server_environment->getAuthDatabase();
GET_ENV_PTR_NO_MAP_LOCK;
return env->getAuthDatabase();
}
void ModApiAuth::pushAuthEntry(lua_State *L, const AuthEntry &authEntry)