mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Get rid of parent pointer in MapBlock
This commit is contained in:
parent
c6cf90f67b
commit
f5b35a074f
6 changed files with 15 additions and 50 deletions
10
src/map.cpp
10
src/map.cpp
|
@ -164,11 +164,11 @@ MapNode Map::getNode(v3s16 p, bool *is_valid_position)
|
|||
return node;
|
||||
}
|
||||
|
||||
static void set_node_in_block(MapBlock *block, v3s16 relpos, MapNode n)
|
||||
static void set_node_in_block(const NodeDefManager *nodedef, MapBlock *block,
|
||||
v3s16 relpos, MapNode n)
|
||||
{
|
||||
// Never allow placing CONTENT_IGNORE, it causes problems
|
||||
if(n.getContent() == CONTENT_IGNORE){
|
||||
const NodeDefManager *nodedef = block->getParent()->getNodeDefManager();
|
||||
v3s16 blockpos = block->getPos();
|
||||
v3s16 p = blockpos * MAP_BLOCKSIZE + relpos;
|
||||
errorstream<<"Not allowing to place CONTENT_IGNORE"
|
||||
|
@ -186,7 +186,7 @@ void Map::setNode(v3s16 p, MapNode n)
|
|||
v3s16 blockpos = getNodeBlockPos(p);
|
||||
MapBlock *block = getBlockNoCreate(blockpos);
|
||||
v3s16 relpos = p - blockpos*MAP_BLOCKSIZE;
|
||||
set_node_in_block(block, relpos, n);
|
||||
set_node_in_block(m_gamedef->ndef(), block, relpos, n);
|
||||
}
|
||||
|
||||
void Map::addNodeAndUpdate(v3s16 p, MapNode n,
|
||||
|
@ -215,14 +215,14 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
|
|||
// No light update needed, just copy over the old light.
|
||||
n.setLight(LIGHTBANK_DAY, oldnode.getLightRaw(LIGHTBANK_DAY, oldf), f);
|
||||
n.setLight(LIGHTBANK_NIGHT, oldnode.getLightRaw(LIGHTBANK_NIGHT, oldf), f);
|
||||
set_node_in_block(block, relpos, n);
|
||||
set_node_in_block(m_gamedef->ndef(), block, relpos, n);
|
||||
|
||||
modified_blocks[blockpos] = block;
|
||||
} else {
|
||||
// Ignore light (because calling voxalgo::update_lighting_nodes)
|
||||
n.setLight(LIGHTBANK_DAY, 0, f);
|
||||
n.setLight(LIGHTBANK_NIGHT, 0, f);
|
||||
set_node_in_block(block, relpos, n);
|
||||
set_node_in_block(m_gamedef->ndef(), block, relpos, n);
|
||||
|
||||
// Update lighting
|
||||
std::vector<std::pair<v3s16, MapNode> > oldnodes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue