diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-09-21 17:54:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-21 17:54:52 +0200 |
commit | fec30e37ac1d160a942777b05a7717b5395c4d99 (patch) | |
tree | bd0fcdf9778bfbea6be5f10dba6936780259c1fd /src/util/areastore.h | |
parent | 5fa614d97e13af64be490336392abe2a54fdcbc1 (diff) | |
download | minetest-fec30e37ac1d160a942777b05a7717b5395c4d99.tar.gz minetest-fec30e37ac1d160a942777b05a7717b5395c4d99.tar.bz2 minetest-fec30e37ac1d160a942777b05a7717b5395c4d99.zip |
Fix AreaStore's IDs persistence (#8888)
Improve documentation
Read old formats
Fix free ID function. Return first gap in map
Diffstat (limited to 'src/util/areastore.h')
-rw-r--r-- | src/util/areastore.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/util/areastore.h b/src/util/areastore.h index 24840210e..150a043db 100644 --- a/src/util/areastore.h +++ b/src/util/areastore.h @@ -37,15 +37,15 @@ with this program; if not, write to the Free Software Foundation, Inc., struct Area { - Area() = default; + Area(u32 area_id) : id(area_id) {} - Area(const v3s16 &mine, const v3s16 &maxe) : - minedge(mine), maxedge(maxe) + Area(const v3s16 &mine, const v3s16 &maxe, u32 area_id = U32_MAX) : + id(area_id), minedge(mine), maxedge(maxe) { sortBoxVerticies(minedge, maxedge); } - u32 id = U32_MAX; + u32 id; v3s16 minedge, maxedge; std::string data; }; @@ -109,7 +109,7 @@ protected: virtual void getAreasForPosImpl(std::vector<Area *> *result, v3s16 pos) = 0; /// Returns the next area ID and increments it. - u32 getNextId() { return m_next_id++; } + u32 getNextId() const; // Note: This can't be an unordered_map, since all // references would be invalidated on rehash. @@ -125,8 +125,6 @@ private: /// If you modify this, call invalidateCache() u8 m_cacheblock_radius = 64; LRUCache<v3s16, std::vector<Area *> > m_res_cache; - - u32 m_next_id = 0; }; |