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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user