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:
@@ -1649,14 +1649,13 @@ int ModApiMapgen::l_generate_decorations(lua_State *L)
|
||||
// create_schematic(p1, p2, probability_list, filename, y_slice_prob_list)
|
||||
int ModApiMapgen::l_create_schematic(lua_State *L)
|
||||
{
|
||||
MAP_LOCK_REQUIRED;
|
||||
GET_ENV_PTR;
|
||||
|
||||
const NodeDefManager *ndef = getServer(L)->getNodeDefManager();
|
||||
|
||||
const char *filename = luaL_checkstring(L, 4);
|
||||
CHECK_SECURE_PATH(L, filename, true);
|
||||
|
||||
Map *map = &(getEnv(L)->getMap());
|
||||
Schematic schem;
|
||||
|
||||
v3s16 p1 = check_v3s16(L, 1);
|
||||
@@ -1694,7 +1693,7 @@ int ModApiMapgen::l_create_schematic(lua_State *L)
|
||||
}
|
||||
}
|
||||
|
||||
if (!schem.getSchematicFromMap(map, p1, p2)) {
|
||||
if (!schem.getSchematicFromMap(&env->getMap(), p1, p2)) {
|
||||
errorstream << "create_schematic: failed to get schematic "
|
||||
"from map" << std::endl;
|
||||
return 0;
|
||||
@@ -1715,8 +1714,6 @@ int ModApiMapgen::l_create_schematic(lua_State *L)
|
||||
// replacements, force_placement, flagstring)
|
||||
int ModApiMapgen::l_place_schematic(lua_State *L)
|
||||
{
|
||||
MAP_LOCK_REQUIRED;
|
||||
|
||||
GET_ENV_PTR;
|
||||
|
||||
ServerMap *map = &(env->getServerMap());
|
||||
|
||||
Reference in New Issue
Block a user