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

@@ -1158,7 +1158,6 @@ int ModApiEnv::l_raycast(lua_State *L)
int ModApiEnv::l_load_area(lua_State *L)
{
GET_ENV_PTR;
MAP_LOCK_REQUIRED;
Map *map = &(env->getMap());
v3s16 bp1 = getNodeBlockPos(check_v3s16(L, 1));
@@ -1373,7 +1372,8 @@ int ModApiEnv::l_forceload_free_block(lua_State *L)
// get_translated_string(lang_code, string)
int ModApiEnv::l_get_translated_string(lua_State * L)
{
GET_ENV_PTR;
NO_MAP_LOCK_REQUIRED;
std::string lang_code = luaL_checkstring(L, 1);
std::string string = luaL_checkstring(L, 2);