Embed data directly in mapblocks

This commit is contained in:
Jude Melton-Houghton 2022-10-09 11:55:07 -04:00
parent 8f996e4a7c
commit b3503e7853
3 changed files with 4 additions and 7 deletions

@ -70,8 +70,7 @@ MapBlock::MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef):
m_parent(parent), m_parent(parent),
m_pos(pos), m_pos(pos),
m_pos_relative(pos * MAP_BLOCKSIZE), m_pos_relative(pos * MAP_BLOCKSIZE),
m_gamedef(gamedef), m_gamedef(gamedef)
data(new MapNode[nodecount])
{ {
reallocate(); reallocate();
} }
@ -84,8 +83,6 @@ MapBlock::~MapBlock()
mesh = nullptr; mesh = nullptr;
} }
#endif #endif
delete[] data;
} }
bool MapBlock::isValidPositionParent(v3s16 p) bool MapBlock::isValidPositionParent(v3s16 p)

@ -481,8 +481,6 @@ private:
IGameDef *m_gamedef; IGameDef *m_gamedef;
MapNode *const data;
/* /*
- On the server, this is used for telling whether the - On the server, this is used for telling whether the
block has been modified from the one on disk. block has been modified from the one on disk.
@ -536,6 +534,8 @@ private:
the list of blocks to be drawn. the list of blocks to be drawn.
*/ */
int m_refcount = 0; int m_refcount = 0;
MapNode data[nodecount];
}; };
typedef std::vector<MapBlock*> MapBlockVect; typedef std::vector<MapBlock*> MapBlockVect;

@ -135,7 +135,7 @@ struct ContentFeatures;
*/ */
struct MapNode struct alignas(u32) MapNode
{ {
/* /*
Main content Main content