diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-06-17 19:11:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-17 19:11:28 +0200 |
commit | 8f7785771b9e02b1a1daf7a252550d78ea93053d (patch) | |
tree | 7a4e4b524dbc63fed3dac99a3844b634cc621d0d /src/mapblock.cpp | |
parent | 76be103a91d6987527af19e87d93007be8ba8a67 (diff) | |
download | minetest-8f7785771b9e02b1a1daf7a252550d78ea93053d.tar.gz minetest-8f7785771b9e02b1a1daf7a252550d78ea93053d.tar.bz2 minetest-8f7785771b9e02b1a1daf7a252550d78ea93053d.zip |
Cpp11 initializers 2 (#5999)
* C++11 patchset 10: continue cleanup on constructors
* Drop obsolete bool MainMenuData::enable_public (setting is called with cURL in server loop)
* More classes cleanup
* More classes cleanup + change NULL tests to boolean tests
Diffstat (limited to 'src/mapblock.cpp')
-rw-r--r-- | src/mapblock.cpp | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp index f36117059..631e9db65 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -69,36 +69,18 @@ MapBlock::MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy): m_parent(parent), m_pos(pos), m_pos_relative(pos * MAP_BLOCKSIZE), - m_gamedef(gamedef), - m_modified(MOD_STATE_WRITE_NEEDED), - m_modified_reason(MOD_REASON_INITIAL), - is_underground(false), - m_lighting_complete(0xFFFF), - m_day_night_differs(false), - m_day_night_differs_expired(true), - m_generated(false), - m_timestamp(BLOCK_TIMESTAMP_UNDEFINED), - m_disk_timestamp(BLOCK_TIMESTAMP_UNDEFINED), - m_usage_timer(0), - m_refcount(0) + m_gamedef(gamedef) { - data = NULL; if(dummy == false) reallocate(); - -#ifndef SERVER - mesh = NULL; -#endif } MapBlock::~MapBlock() { #ifndef SERVER { - //MutexAutoLock lock(mesh_mutex); - delete mesh; - mesh = NULL; + mesh = nullptr; } #endif @@ -121,7 +103,7 @@ MapNode MapBlock::getNodeParent(v3s16 p, bool *is_valid_position) if (isValidPosition(p) == false) return m_parent->getNodeNoEx(getPosRelative() + p, is_valid_position); - if (data == NULL) { + if (!data) { if (is_valid_position) *is_valid_position = false; return MapNode(CONTENT_IGNORE); @@ -374,7 +356,7 @@ void MapBlock::actuallyUpdateDayNightDiff() // Running this function un-expires m_day_night_differs m_day_night_differs_expired = false; - if (data == NULL) { + if (!data) { m_day_night_differs = false; return; } @@ -415,9 +397,7 @@ void MapBlock::actuallyUpdateDayNightDiff() void MapBlock::expireDayNightDiff() { - //INodeDefManager *nodemgr = m_gamedef->ndef(); - - if(data == NULL){ + if (!data) { m_day_night_differs = false; m_day_night_differs_expired = false; return; @@ -554,10 +534,8 @@ void MapBlock::serialize(std::ostream &os, u8 version, bool disk) if(!ser_ver_supported(version)) throw VersionMismatchException("ERROR: MapBlock format not supported"); - if(data == NULL) - { + if (!data) throw SerializationError("ERROR: Not writing dummy block."); - } FATAL_ERROR_IF(version < SER_FMT_VER_LOWEST_WRITE, "Serialisation version error"); |