summaryrefslogtreecommitdiff
path: root/src/util/areastore.cpp
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2015-10-30 20:38:22 -0400
committerShadowNinja <shadowninja@minetest.net>2016-03-07 16:33:20 -0500
commit3ce6642a26d43fd368c24cdfc5460557258fb44f (patch)
tree3f84e8a4491abc6c9bc4a615dea018fdd8cf0697 /src/util/areastore.cpp
parent821551a2669123ac9a476894d65b5efe10026040 (diff)
downloadminetest-3ce6642a26d43fd368c24cdfc5460557258fb44f.tar.gz
minetest-3ce6642a26d43fd368c24cdfc5460557258fb44f.tar.bz2
minetest-3ce6642a26d43fd368c24cdfc5460557258fb44f.zip
Add AreaStore custom ID API
Diffstat (limited to 'src/util/areastore.cpp')
-rw-r--r--src/util/areastore.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/util/areastore.cpp b/src/util/areastore.cpp
index 17addb3af..58f08a8c2 100644
--- a/src/util/areastore.cpp
+++ b/src/util/areastore.cpp
@@ -160,7 +160,8 @@ void AreaStore::getAreasForPos(std::vector<Area *> *result, v3s16 pos)
bool VectorAreaStore::insertArea(Area *a)
{
- a->id = getNextId();
+ if (a->id == U32_MAX)
+ a->id = getNextId();
std::pair<AreaMap::iterator, bool> res =
areas_map.insert(std::make_pair(a->id, *a));
if (!res.second)
@@ -232,7 +233,8 @@ static inline SpatialIndex::Point get_spatial_point(const v3s16 pos)
bool SpatialAreaStore::insertArea(Area *a)
{
- a->id = getNextId();
+ if (a->id == U32_MAX)
+ a->id = getNextId();
if (!areas_map.insert(std::make_pair(a->id, *a)).second)
// ID is not unique
return false;