diff options
author | Jude Melton-Houghton <jwmhjwmh@gmail.com> | 2022-10-09 11:55:07 -0400 |
---|---|---|
committer | Jude Melton-Houghton <jwmhjwmh@gmail.com> | 2022-10-09 13:43:48 -0400 |
commit | b3503e7853a52a8c16431f6b983e30c9d25951bc (patch) | |
tree | 277c1f55bf6523bc37529a68f7b7107d82cb00ed /src | |
parent | 8f996e4a7cf7b1fa1ca683cbc37327a790e09ddc (diff) | |
download | minetest-b3503e7853a52a8c16431f6b983e30c9d25951bc.tar.xz |
Embed data directly in mapblocks
Diffstat (limited to 'src')
-rw-r--r-- | src/mapblock.cpp | 5 | ||||
-rw-r--r-- | src/mapblock.h | 4 | ||||
-rw-r--r-- | src/mapnode.h | 2 |
3 files changed, 4 insertions, 7 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 6d61508fa..ca2145cef 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -70,8 +70,7 @@ MapBlock::MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef): m_parent(parent), m_pos(pos), m_pos_relative(pos * MAP_BLOCKSIZE), - m_gamedef(gamedef), - data(new MapNode[nodecount]) + m_gamedef(gamedef) { reallocate(); } @@ -84,8 +83,6 @@ MapBlock::~MapBlock() mesh = nullptr; } #endif - - delete[] data; } bool MapBlock::isValidPositionParent(v3s16 p) diff --git a/src/mapblock.h b/src/mapblock.h index 0aa0139c6..1ab0ce80c 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -481,8 +481,6 @@ private: IGameDef *m_gamedef; - MapNode *const data; - /* - On the server, this is used for telling whether the block has been modified from the one on disk. @@ -536,6 +534,8 @@ private: the list of blocks to be drawn. */ int m_refcount = 0; + + MapNode data[nodecount]; }; typedef std::vector<MapBlock*> MapBlockVect; diff --git a/src/mapnode.h b/src/mapnode.h index 43ce7e621..c3137bbcb 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -135,7 +135,7 @@ struct ContentFeatures; */ -struct MapNode +struct alignas(u32) MapNode { /* Main content |