diff options
author | ShadowNinja <shadowninja@minetest.net> | 2015-10-29 23:08:32 -0400 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2016-03-07 16:33:20 -0500 |
commit | 095db16990eea878ce01b29c1eb85a128f98381a (patch) | |
tree | 9845f990ebdb7c78c1ecf487cfa91eb29fd2b7db /src/script/lua_api | |
parent | 725cb4eb0743a382851e011fb7de1b7d443ce51f (diff) | |
download | minetest-095db16990eea878ce01b29c1eb85a128f98381a.tar.gz minetest-095db16990eea878ce01b29c1eb85a128f98381a.tar.bz2 minetest-095db16990eea878ce01b29c1eb85a128f98381a.zip |
Simplify AreaStore ID management
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_areastore.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
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; |