Skip to content

Commit

Permalink
Embed data directly in mapblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
TurkeyMcMac committed Oct 9, 2022
1 parent 8f996e4 commit b3503e7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/mapblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -84,8 +83,6 @@ MapBlock::~MapBlock()
mesh = nullptr;
}
#endif

delete[] data;
}

bool MapBlock::isValidPositionParent(v3s16 p)
Expand Down
4 changes: 2 additions & 2 deletions src/mapblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,6 @@ class MapBlock

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.
Expand Down Expand Up @@ -536,6 +534,8 @@ class MapBlock
the list of blocks to be drawn.
*/
int m_refcount = 0;

MapNode data[nodecount];
};

typedef std::vector<MapBlock*> MapBlockVect;
Expand Down
2 changes: 1 addition & 1 deletion src/mapnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct ContentFeatures;
*/


struct MapNode
struct alignas(u32) MapNode
{
/*
Main content
Expand Down

0 comments on commit b3503e7

Please sign in to comment.