From 095db16990eea878ce01b29c1eb85a128f98381a Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Thu, 29 Oct 2015 23:08:32 -0400 Subject: Simplify AreaStore ID management --- src/script/lua_api/l_areastore.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/script/lua_api/l_areastore.cpp') diff --git a/src/script/lua_api/l_areastore.cpp b/src/script/lua_api/l_areastore.cpp index 4148780a1..ff6abbd9f 100644 --- a/src/script/lua_api/l_areastore.cpp +++ b/src/script/lua_api/l_areastore.cpp @@ -159,26 +159,15 @@ int LuaAreaStore::l_insert_area(lua_State *L) LuaAreaStore *o = checkobject(L, 1); AreaStore *ast = o->as; - Area a; - - a.minedge = check_v3s16(L, 2); - a.maxedge = check_v3s16(L, 3); - - a.extremifyEdges(); - a.id = ast->getFreeId(a.minedge, a.maxedge); - - if (a.id == AREA_ID_INVALID) { - // couldn't get free id - lua_pushnil(L); - return 1; - } + Area a(check_v3s16(L, 2), check_v3s16(L, 3)); size_t d_len; const char *data = luaL_checklstring(L, 4, &d_len); a.data = std::string(data, d_len); - ast->insertArea(a); + if (!ast->insertArea(&a)) + return 0; lua_pushnumber(L, a.id); return 1; -- cgit v1.2.3