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

Simplify AreaStore ID management

This commit is contained in:
ShadowNinja 2015-10-29 23:08:32 -04:00
parent 725cb4eb07
commit 095db16990
5 changed files with 45 additions and 86 deletions

View file

@ -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;