1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

ActiveObjectMgr fixes (#13560)

This commit is contained in:
DS 2023-10-09 17:13:04 +02:00 committed by GitHub
parent 929a13a9a0
commit 11ec75c2ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 204 additions and 153 deletions

View file

@ -611,10 +611,12 @@ int ModApiEnv::l_add_entity(lua_State *L)
const char *name = luaL_checkstring(L, 2);
std::string staticdata = readParam<std::string>(L, 3, "");
ServerActiveObject *obj = new LuaEntitySAO(env, pos, name, staticdata);
int objectid = env->addActiveObject(obj);
std::unique_ptr<ServerActiveObject> obj_u =
std::make_unique<LuaEntitySAO>(env, pos, name, staticdata);
auto obj = obj_u.get();
int objectid = env->addActiveObject(std::move(obj_u));
// If failed to add, return nothing (reads as nil)
if(objectid == 0)
if (objectid == 0)
return 0;
// If already deleted (can happen in on_activate), return nil