summaryrefslogtreecommitdiff
path: root/src/mapblock.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-18 18:18:25 +0200
committerGitHub <noreply@github.com>2017-08-18 18:18:25 +0200
commitc42753338924bb29c61081c9f269772f89bcd808 (patch)
tree3ccbf49ad802c57a1288ea978268315b68d8e65f /src/mapblock.cpp
parentfb196be8cf8606cfab144e2fe62d9c9d1f50932f (diff)
downloadminetest-c42753338924bb29c61081c9f269772f89bcd808.tar.gz
minetest-c42753338924bb29c61081c9f269772f89bcd808.tar.bz2
minetest-c42753338924bb29c61081c9f269772f89bcd808.zip
Modernize various files (src/m*) (#6267)
* Modernize various files (src/m*) * range-based for loops * code style * C++ headers instead of C headers * Default operators * empty function Thanks to clang-tidy
Diffstat (limited to 'src/mapblock.cpp')
-rw-r--r--src/mapblock.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp
index ca5894794..48b7c1915 100644
--- a/src/mapblock.cpp
+++ b/src/mapblock.cpp
@@ -71,7 +71,7 @@ MapBlock::MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy):
m_pos_relative(pos * MAP_BLOCKSIZE),
m_gamedef(gamedef)
{
- if(dummy == false)
+ if (!dummy)
reallocate();
}
@@ -89,24 +89,22 @@ MapBlock::~MapBlock()
bool MapBlock::isValidPositionParent(v3s16 p)
{
- if(isValidPosition(p))
- {
+ if (isValidPosition(p)) {
return true;
}
- else{
- return m_parent->isValidPosition(getPosRelative() + p);
- }
+
+ return m_parent->isValidPosition(getPosRelative() + p);
}
MapNode MapBlock::getNodeParent(v3s16 p, bool *is_valid_position)
{
- if (isValidPosition(p) == false)
+ if (!isValidPosition(p))
return m_parent->getNodeNoEx(getPosRelative() + p, is_valid_position);
if (!data) {
if (is_valid_position)
*is_valid_position = false;
- return MapNode(CONTENT_IGNORE);
+ return {CONTENT_IGNORE};
}
if (is_valid_position)
*is_valid_position = true;
@@ -201,8 +199,7 @@ bool MapBlock::propagateSunlight(std::set<v3s16> & light_sources,
else
{
MapNode n = getNodeNoEx(v3s16(x, MAP_BLOCKSIZE-1, z));
- if(m_gamedef->ndef()->get(n).sunlight_propagates == false)
- {
+ if (!m_gamedef->ndef()->get(n).sunlight_propagates) {
no_sunlight = true;
}
}
@@ -423,12 +420,11 @@ s16 MapBlock::getGroundLevel(v2s16 p2d)
for(; y>=0; y--)
{
MapNode n = getNodeRef(p2d.X, y, p2d.Y);
- if(m_gamedef->ndef()->get(n).walkable)
- {
+ if (m_gamedef->ndef()->get(n).walkable) {
if(y == MAP_BLOCKSIZE-1)
return -2;
- else
- return y;
+
+ return y;
}
}
return -1;
@@ -481,11 +477,9 @@ static void getBlockNodeIdMapping(NameIdMapping *nimap, MapNode *nodes,
// Update the MapNode
nodes[i].setContent(id);
}
- for(std::set<content_t>::const_iterator
- i = unknown_contents.begin();
- i != unknown_contents.end(); ++i){
- errorstream<<"getBlockNodeIdMapping(): IGNORING ERROR: "
- <<"Name for node id "<<(*i)<<" not known"<<std::endl;
+ for (u16 unknown_content : unknown_contents) {
+ errorstream << "getBlockNodeIdMapping(): IGNORING ERROR: "
+ << "Name for node id " << unknown_content << " not known" << std::endl;
}
}
// Correct ids in the block to match nodedef based on names.