1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

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
This commit is contained in:
Loïc Blot 2017-06-17 19:11:28 +02:00 committed by GitHub
parent 76be103a91
commit 8f7785771b
59 changed files with 326 additions and 639 deletions

View file

@ -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");