summaryrefslogtreecommitdiff
path: root/src/resources/map
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-06 23:34:34 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-07 19:23:40 +0300
commit36ba43d6ea38062b17f7e63ef659962bfc51c64d (patch)
tree190156cb88b13a38a6d13c69ee0742cc078065a1 /src/resources/map
parentf1518dd8476c968a43fa57cfb06198e290a4f77a (diff)
downloadplus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz
plus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2
plus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz
plus-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/resources/map')
-rw-r--r--src/resources/map/map.cpp119
-rw-r--r--src/resources/map/mapitem.cpp6
-rw-r--r--src/resources/map/maplayer.cpp24
-rw-r--r--src/resources/map/objectslayer.cpp4
-rw-r--r--src/resources/map/speciallayer.cpp12
-rw-r--r--src/resources/map/tileanimation.cpp4
6 files changed, 85 insertions, 84 deletions
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index f0092c448..f2c8f4636 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -83,7 +83,7 @@ class ActorFunctuator final
bool operator()(const Actor *const a,
const Actor *const b) const
{
- if (!a || !b)
+ if ((a == nullptr) || (b == nullptr))
return false;
return a->getSortPixelY() < b->getSortPixelY();
}
@@ -174,7 +174,7 @@ Map::~Map()
config.removeListeners(this);
CHECKLISTENERS
- if (mWalkLayer)
+ if (mWalkLayer != nullptr)
{
mWalkLayer->decRef();
mWalkLayer = nullptr;
@@ -189,7 +189,7 @@ Map::~Map()
delete2(mTempLayer);
delete2(mObjects);
delete_all(mMapPortals);
- if (mAtlas)
+ if (mAtlas != nullptr)
{
mAtlas->decRef();
mAtlas = nullptr;
@@ -244,10 +244,10 @@ void Map::initializeAmbientLayers() restrict2
Image *restrict const img = Loader::getImage(
getProperty(name + "image"));
- if (img)
+ if (img != nullptr)
{
int mask = atoi(getProperty(name + "mask").c_str());
- if (!mask)
+ if (mask == 0)
mask = 1;
const float parallax = getFloatProperty(name + "parallax");
mForegrounds.push_back(new AmbientLayer(
@@ -275,10 +275,10 @@ void Map::initializeAmbientLayers() restrict2
Image *restrict const img = Loader::getImage(
getProperty(name + "image"));
- if (img)
+ if (img != nullptr)
{
int mask = atoi(getProperty(name + "mask").c_str());
- if (!mask)
+ if (mask == 0)
mask = 1;
const float parallax = getFloatProperty(name + "parallax");
@@ -303,7 +303,7 @@ void Map::initializeAmbientLayers() restrict2
void Map::addLayer(MapLayer *const layer) restrict2
{
mLayers.push_back(layer);
- if (layer->isFringeLayer() && !mFringeLayer)
+ if (layer->isFringeLayer() && (mFringeLayer == nullptr))
mFringeLayer = layer;
}
@@ -321,7 +321,7 @@ void Map::update(const int ticks) restrict2
FOR_EACH (TileAnimationMapCIter, iAni, mTileAnimations)
{
TileAnimation *restrict const tileAni = iAni->second;
- if (tileAni && tileAni->update(ticks))
+ if ((tileAni != nullptr) && tileAni->update(ticks))
mRedrawMap = true;
}
}
@@ -329,7 +329,7 @@ void Map::update(const int ticks) restrict2
void Map::draw(Graphics *restrict const graphics,
int scrollX, int scrollY) restrict2
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
BLOCK_START("Map::draw")
@@ -357,7 +357,7 @@ void Map::draw(Graphics *restrict const graphics,
MapLayerPosition::BACKGROUND_LAYERS,
mOverlayDetail);
- if (mDrawLayersFlags == MapType::BLACKWHITE && userPalette)
+ if (mDrawLayersFlags == MapType::BLACKWHITE && (userPalette != nullptr))
{
graphics->setColor(userPalette->getColorWithAlpha(
UserColorId::WALKABLE_HIGHLIGHT));
@@ -395,7 +395,7 @@ void Map::draw(Graphics *restrict const graphics,
if (mDrawOnlyFringe)
{
- if (mFringeLayer)
+ if (mFringeLayer != nullptr)
{
mFringeLayer->setSpecialLayer(mSpecialLayer);
mFringeLayer->setTempLayer(mTempLayer);
@@ -411,7 +411,7 @@ void Map::draw(Graphics *restrict const graphics,
#ifdef USE_OPENGL
if (mCachedDraw)
{
- if (updateFlag)
+ if (updateFlag != 0)
{
FOR_EACH (Layers::iterator, it, mDrawUnderLayers)
{
@@ -432,7 +432,7 @@ void Map::draw(Graphics *restrict const graphics,
FOR_EACH (Layers::iterator, it, mDrawUnderLayers)
(*it)->drawOGL(graphics);
- if (mFringeLayer)
+ if (mFringeLayer != nullptr)
{
mFringeLayer->setSpecialLayer(mSpecialLayer);
mFringeLayer->setTempLayer(mTempLayer);
@@ -457,7 +457,7 @@ void Map::draw(Graphics *restrict const graphics,
scrollX, scrollY);
}
- if (mFringeLayer)
+ if (mFringeLayer != nullptr)
{
mFringeLayer->setSpecialLayer(mSpecialLayer);
mFringeLayer->setTempLayer(mTempLayer);
@@ -626,14 +626,14 @@ void Map::updateAmbientLayers(const float scrollX,
FOR_EACH (AmbientLayerVectorIter, i, mBackgrounds)
{
AmbientLayer *const layer = *i;
- if (layer && (layer->mMask & mMask))
+ if ((layer != nullptr) && ((layer->mMask & mMask) != 0))
layer->update(timePassed, dx, dy);
}
FOR_EACH (AmbientLayerVectorIter, i, mForegrounds)
{
AmbientLayer *const layer = *i;
- if (layer && (layer->mMask & mMask))
+ if ((layer != nullptr) && ((layer->mMask & mMask) != 0))
layer->update(timePassed, dx, dy);
}
@@ -674,7 +674,7 @@ void Map::drawAmbientLayers(Graphics *restrict const graphics,
{
const AmbientLayer *restrict const layer = *i;
// need check mask to draw or not to draw
- if (layer && (layer->mMask & mMask))
+ if ((layer != nullptr) && ((layer->mMask & mMask) != 0))
(layer)->draw(graphics, graphics->mWidth, graphics->mHeight);
// Detail 1: only one overlay, higher: all overlays
@@ -778,7 +778,7 @@ bool Map::getWalk(const int x, const int y,
return false;
// Check if the tile is walkable
- return !(mMetaTiles[x + y * mWidth].blockmask & blockWalkMask);
+ return (mMetaTiles[x + y * mWidth].blockmask & blockWalkMask) == 0;
}
unsigned char Map::getBlockMask(const int x,
@@ -877,7 +877,7 @@ Path Map::findPath(const int startX, const int startY,
// Reset starting tile's G cost to 0
MetaTile *const startTile = &mMetaTiles[startX + startY * mWidth];
- if (!startTile)
+ if (startTile == nullptr)
{
BLOCK_END("Map::findPath")
return path;
@@ -941,9 +941,9 @@ Path Map::findPath(const int startX, const int startY,
// can be removed. It left here only for protect from
// walk on wall in any case
if (newTile->whichList == mOnClosedList ||
- ((newTile->blockmask & blockWalkMask)
+ (((newTile->blockmask & blockWalkMask) != 0)
&& !(x == destX && y == destY))
- || (newTile->blockmask & BlockMask::WALL))
+ || ((newTile->blockmask & BlockMask::WALL) != 0))
{
continue;
}
@@ -958,7 +958,7 @@ Path Map::findPath(const int startX, const int startY,
dx + curWidth];
// on player abilities.
- if (((t1->blockmask | t2->blockmask) & blockWalkMask))
+ if (((t1->blockmask | t2->blockmask) & blockWalkMask) != 0)
continue;
}
@@ -1096,7 +1096,7 @@ void Map::addParticleEffect(const std::string &effectFile,
void Map::initializeParticleEffects() const restrict2
{
BLOCK_START("Map::initializeParticleEffects")
- if (!particleEngine)
+ if (particleEngine == nullptr)
{
BLOCK_END("Map::initializeParticleEffects")
return;
@@ -1113,7 +1113,7 @@ void Map::initializeParticleEffects() const restrict2
i->file,
i->x,
i->y);
- if (p &&
+ if ((p != nullptr) &&
i->w > 0 &&
i->h > 0)
{
@@ -1127,7 +1127,7 @@ void Map::initializeParticleEffects() const restrict2
void Map::addExtraLayer() restrict2
{
BLOCK_START("Map::addExtraLayer")
- if (!mSpecialLayer)
+ if (mSpecialLayer == nullptr)
{
logger->log1("No special layer");
BLOCK_END("Map::addExtraLayer")
@@ -1137,7 +1137,8 @@ void Map::addExtraLayer() restrict2
"extralayer.txt");
logger->log("loading extra layer: " + mapFileName);
struct stat statbuf;
- if (!stat(mapFileName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode))
+ if (stat(mapFileName.c_str(), &statbuf) == 0 &&
+ S_ISREG(statbuf.st_mode))
{
std::ifstream mapFile;
mapFile.open(mapFileName.c_str(), std::ios::in);
@@ -1201,7 +1202,7 @@ void Map::addExtraLayer() restrict2
void Map::saveExtraLayer() const restrict2
{
- if (!mSpecialLayer)
+ if (mSpecialLayer == nullptr)
{
logger->log1("No special layer");
return;
@@ -1210,7 +1211,7 @@ void Map::saveExtraLayer() const restrict2
"extralayer.txt");
logger->log("saving extra layer: " + mapFileName);
- if (mkdir_r(getUserMapDirectory().c_str()))
+ if (mkdir_r(getUserMapDirectory().c_str()) != 0)
{
logger->log(strprintf("%s doesn't exist and can't be created! "
"Exiting.", getUserMapDirectory().c_str()));
@@ -1234,7 +1235,7 @@ void Map::saveExtraLayer() const restrict2
for (int y = 0; y < height; y ++)
{
const MapItem *restrict const item = mSpecialLayer->getTile(x, y);
- if (item && item->mType != MapItemType::EMPTY
+ if ((item != nullptr) && item->mType != MapItemType::EMPTY
&& item->mType != MapItemType::HOME)
{
mapFile << x << " " << y << " "
@@ -1257,7 +1258,7 @@ void Map::addRange(const std::string &restrict name,
const int x, const int y,
const int dx, const int dy) restrict2
{
- if (!mObjects)
+ if (mObjects == nullptr)
return;
mObjects->addObject(name, type, x / mapTileSize, y / mapTileSize,
@@ -1277,7 +1278,7 @@ void Map::addPortalTile(const std::string &restrict name,
const int type,
const int x, const int y) restrict2
{
- if (mSpecialLayer)
+ if (mSpecialLayer != nullptr)
{
mSpecialLayer->setTile(x, y, new MapItem(type, name, x, y));
mSpecialLayer->updateCache();
@@ -1292,13 +1293,13 @@ void Map::updatePortalTile(const std::string &restrict name,
const bool addNew) restrict2
{
MapItem *restrict item = findPortalXY(x, y);
- if (item)
+ if (item != nullptr)
{
item->mComment = name;
item->setType(type);
item->mX = x;
item->mY = y;
- if (mSpecialLayer)
+ if (mSpecialLayer != nullptr)
{
item = new MapItem(type, name, x, y);
mSpecialLayer->setTile(x, y, item);
@@ -1315,7 +1316,7 @@ MapItem *Map::findPortalXY(const int x, const int y) const restrict2
{
FOR_EACH (std::vector<MapItem*>::const_iterator, it, mMapPortals)
{
- if (!*it)
+ if (*it == nullptr)
continue;
MapItem *restrict const item = *it;
@@ -1338,12 +1339,12 @@ void Map::setPvpMode(const int mode) restrict2
{
const int oldMode = mPvp;
- if (!mode)
+ if (mode == 0)
mPvp = 0;
else
mPvp |= mode;
- if (mPvp != oldMode && localPlayer)
+ if (mPvp != oldMode && (localPlayer != nullptr))
{
switch (mPvp)
{
@@ -1369,11 +1370,11 @@ void Map::setPvpMode(const int mode) restrict2
std::string Map::getObjectData(const unsigned x, const unsigned y,
const int type) const restrict2
{
- if (!mObjects)
+ if (mObjects == nullptr)
return "";
MapObjectList *restrict const list = mObjects->getAt(x, y);
- if (!list)
+ if (list == nullptr)
return "";
std::vector<MapObject>::const_iterator it = list->objects.begin();
@@ -1400,14 +1401,14 @@ void Map::indexTilesets() restrict2
FOR_EACH (Tilesets::const_iterator, it, mTilesets)
{
const size_t sz = (*it)->size();
- if (!s || CAST_SIZE(s->getFirstGid()) + sSz
+ if ((s == nullptr) || CAST_SIZE(s->getFirstGid()) + sSz
< CAST_SIZE((*it)->getFirstGid()) + sz)
{
s = *it;
sSz = sz;
}
}
- if (!s)
+ if (s == nullptr)
{
mIndexedTilesetsSize = 0;
mIndexedTilesets = nullptr;
@@ -1423,7 +1424,7 @@ void Map::indexTilesets() restrict2
FOR_EACH (Tilesets::const_iterator, it, mTilesets)
{
Tileset *restrict const s2 = *it;
- if (s2)
+ if (s2 != nullptr)
{
const int start = s2->getFirstGid();
const int end = start + CAST_S32(s2->size());
@@ -1452,7 +1453,7 @@ void Map::reduce() restrict2
return;
#else // USE_SDL2
- if (!mFringeLayer ||
+ if ((mFringeLayer == nullptr) ||
mOpenGL != RENDER_SOFTWARE ||
!config.getBoolValue("enableMapReduce"))
{
@@ -1479,7 +1480,7 @@ void Map::reduce() restrict2
Image *restrict const img =
layer->mTiles[x + y * layer->mWidth].image;
- if (img)
+ if (img != nullptr)
{
if (img->hasAlphaChannel() && img->isAlphaCalculated())
{
@@ -1505,7 +1506,7 @@ void Map::reduce() restrict2
{
const uint8_t *restrict const arr =
img->SDLgetAlphaChannel();
- if (!arr)
+ if (arr == nullptr)
continue;
bool bad(false);
@@ -1513,7 +1514,7 @@ void Map::reduce() restrict2
int width;
const SubImage *restrict const subImg
= dynamic_cast<SubImage*>(img);
- if (subImg)
+ if (subImg != nullptr)
width = subImg->mInternalBounds.w;
else
width = img->mBounds.w;
@@ -1570,7 +1571,7 @@ void Map::reduce() restrict2
const Image *restrict img =
layer->mTiles[x + y * layer->mWidth].image;
- if (img && !img->isAlphaVisible())
+ if ((img != nullptr) && !img->isAlphaVisible())
{ // removing all down tiles
++ ri;
while (ri != mLayers.rend())
@@ -1585,7 +1586,7 @@ void Map::reduce() restrict2
const size_t pos = CAST_SIZE(
x + y * layer2->mWidth);
img = layer2->mTiles[pos].image;
- if (img)
+ if (img != nullptr)
{
layer2->mTiles[pos].image = nullptr;
cnt ++;
@@ -1610,7 +1611,7 @@ void Map::addHeights(const MapHeights *restrict const heights) restrict2
uint8_t Map::getHeightOffset(const int x, const int y) const restrict2
{
- if (!mHeights)
+ if (mHeights == nullptr)
return 0;
return mHeights->getHeight(x, y);
}
@@ -1628,7 +1629,7 @@ void Map::updateDrawLayersList() restrict2
for (; layers != layers_end; ++ layers)
{
MapLayer *const layer = *layers;
- if (!(layer->mMask & mMask))
+ if ((layer->mMask & mMask) == 0)
continue;
if (layer->isFringeLayer())
@@ -1646,7 +1647,7 @@ void Map::updateDrawLayersList() restrict2
for (; layers != layers_end; ++ layers)
{
MapLayer *const layer = *layers;
- if (!(layer->mMask & mMask))
+ if ((layer->mMask & mMask) == 0)
continue;
mDrawOverLayers.push_back(layer);
@@ -1705,7 +1706,7 @@ void Map::setActorsFix(const int x, const int y) restrict2
{
mActorFixX = x;
mActorFixY = y;
- if (mFringeLayer)
+ if (mFringeLayer != nullptr)
mFringeLayer->setActorsFix(y);
}
@@ -1716,7 +1717,7 @@ void Map::updateConditionLayers() restrict2
FOR_EACH (LayersCIter, it, mLayers)
{
MapLayer *restrict const layer = *it;
- if (!layer || layer->mTileCondition == -1)
+ if ((layer == nullptr) || layer->mTileCondition == -1)
continue;
layer->updateConditionTiles(mMetaTiles,
mWidth, mHeight);
@@ -1728,7 +1729,7 @@ void Map::preCacheLayers() restrict2
FOR_EACH (LayersCIter, it, mLayers)
{
MapLayer *restrict const layer = *it;
- if (layer)
+ if (layer != nullptr)
layer->updateCache(mWidth, mHeight);
}
}
@@ -1755,7 +1756,7 @@ int Map::calcMemoryChilds(const int level) const
{
int sz = 0;
- if (mWalkLayer)
+ if (mWalkLayer != nullptr)
sz += mWalkLayer->calcMemory(level + 1);
FOR_EACH (LayersCIter, it, mLayers)
{
@@ -1773,13 +1774,13 @@ int Map::calcMemoryChilds(const int level) const
{
sz += (*it)->calcMemory(level + 1);
}
- if (mSpecialLayer)
+ if (mSpecialLayer != nullptr)
mSpecialLayer->calcMemory(level + 1);
- if (mTempLayer)
+ if (mTempLayer != nullptr)
mTempLayer->calcMemory(level + 1);
- if (mObjects)
+ if (mObjects != nullptr)
mObjects->calcMemory(level + 1);
- if (mHeights)
+ if (mHeights != nullptr)
mHeights->calcMemory(level + 1);
return sz;
}
diff --git a/src/resources/map/mapitem.cpp b/src/resources/map/mapitem.cpp
index eeca6cbf5..ce9e38fec 100644
--- a/src/resources/map/mapitem.cpp
+++ b/src/resources/map/mapitem.cpp
@@ -82,7 +82,7 @@ MapItem::MapItem(const int type, std::string comment,
MapItem::~MapItem()
{
- if (mImage)
+ if (mImage != nullptr)
{
mImage->decRef();
mImage = nullptr;
@@ -93,7 +93,7 @@ void MapItem::setType(const int type)
{
std::string name;
mType = type;
- if (mImage)
+ if (mImage != nullptr)
mImage->decRef();
switch (type)
@@ -130,7 +130,7 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y,
const int dx, const int dy) const
{
BLOCK_START("MapItem::draw")
- if (mImage)
+ if (mImage != nullptr)
graphics->drawImage(mImage, x, y);
switch (mType)
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp
index 4c6fe3a1e..2598b029c 100644
--- a/src/resources/map/maplayer.cpp
+++ b/src/resources/map/maplayer.cpp
@@ -316,7 +316,7 @@ void MapLayer::updateOGL(Graphics *const graphics,
if (mSpecialFlag ||
img->mBounds.h <= mapTileSize)
{
- if (!lastImage ||
+ if ((lastImage == nullptr) ||
lastImage->mGLImage != imgGlImage)
{
if (img->mBounds.w > mapTileSize)
@@ -328,7 +328,7 @@ void MapLayer::updateOGL(Graphics *const graphics,
}
else
{
- if (lastImage)
+ if (lastImage != nullptr)
imgSet[lastImage->mGLImage] = imgVert;
imgVert = new ImageVertexes;
imgVert->ogl.init();
@@ -387,7 +387,7 @@ void MapLayer::drawSpecialLayer(Graphics *const graphics,
endX1 = 0;
int x0 = startX;
const MapItem *item0 = mSpecialLayer->mTiles[ptr + startX];
- if (!item0 || item0->mType == MapItemType::EMPTY)
+ if ((item0 == nullptr) || item0->mType == MapItemType::EMPTY)
{
x0 += mSpecialLayer->mCache[ptr + startX] + 1;
}
@@ -395,7 +395,7 @@ void MapLayer::drawSpecialLayer(Graphics *const graphics,
{
const int px1 = x * mapTileSize - scrollX;
const MapItem *const item = mSpecialLayer->mTiles[ptr + x];
- if (item)
+ if (item != nullptr)
{
item->draw(graphics, px1, py1,
mapTileSize, mapTileSize);
@@ -410,7 +410,7 @@ void MapLayer::drawSpecialLayer(Graphics *const graphics,
if (endX1 > specialWidth)
endX1 = specialWidth;
item0 = mTempLayer->mTiles[ptr + startX];
- if (!item0 || item0->mType == MapItemType::EMPTY)
+ if ((item0 == nullptr) || item0->mType == MapItemType::EMPTY)
{
x0 += mTempLayer->mCache[ptr + startX] + 1;
}
@@ -434,9 +434,9 @@ void MapLayer::drawFringe(Graphics *const graphics,
const Actors &actors) const restrict
{
BLOCK_START("MapLayer::drawFringe")
- if (!localPlayer ||
- !mSpecialLayer ||
- !mTempLayer)
+ if ((localPlayer == nullptr) ||
+ (mSpecialLayer == nullptr) ||
+ (mTempLayer == nullptr))
{
BLOCK_END("MapLayer::drawFringe")
return;
@@ -684,7 +684,7 @@ void MapLayer::drawFringe(Graphics *const graphics,
h += mapTileSize;
}
- if (userPalette)
+ if (userPalette != nullptr)
{
graphics->setColor(userPalette->getColorWithAlpha(
UserColorId::ATTACK_RANGE));
@@ -783,7 +783,7 @@ void MapLayer::updateConditionTiles(const MetaTile *const metaTiles,
for (int x = mX; x < width1; x ++, metaPtr ++, tilePtr ++)
{
if (tilePtr->image != nullptr &&
- (metaPtr->blockmask & mTileCondition ||
+ (((metaPtr->blockmask & mTileCondition) != 0) ||
(metaPtr->blockmask == 0 &&
mTileCondition == BlockMask::GROUND)))
{
@@ -841,9 +841,9 @@ int MapLayer::calcMemoryLocal() const
int MapLayer::calcMemoryChilds(const int level) const
{
int sz = 0;
- if (mSpecialLayer)
+ if (mSpecialLayer != nullptr)
sz += mSpecialLayer->calcMemory(level + 1);
- if (mTempLayer)
+ if (mTempLayer != nullptr)
sz += mTempLayer->calcMemory(level + 1);
return sz;
}
diff --git a/src/resources/map/objectslayer.cpp b/src/resources/map/objectslayer.cpp
index a100b2c7d..3224da0e6 100644
--- a/src/resources/map/objectslayer.cpp
+++ b/src/resources/map/objectslayer.cpp
@@ -48,7 +48,7 @@ void ObjectsLayer::addObject(const std::string &name, const int type,
const unsigned x, const unsigned y,
unsigned dx, unsigned dy)
{
- if (!mTiles)
+ if (mTiles == nullptr)
return;
if (x + dx > mWidth)
@@ -63,7 +63,7 @@ void ObjectsLayer::addObject(const std::string &name, const int type,
for (unsigned i = idx1; i < idx2; i ++)
{
- if (!mTiles[i])
+ if (mTiles[i] == nullptr)
mTiles[i] = new MapObjectList;
mTiles[i]->objects.push_back(MapObject(type, name));
}
diff --git a/src/resources/map/speciallayer.cpp b/src/resources/map/speciallayer.cpp
index 4e826dc42..75b56be28 100644
--- a/src/resources/map/speciallayer.cpp
+++ b/src/resources/map/speciallayer.cpp
@@ -72,7 +72,7 @@ void SpecialLayer::setTile(const int x, const int y, MapItem *const item)
const int idx = x + y * mWidth;
delete mTiles[idx];
- if (item)
+ if (item != nullptr)
item->setPos(x, y);
mTiles[idx] = item;
}
@@ -87,7 +87,7 @@ void SpecialLayer::setTile(const int x, const int y, const int type)
const int idx = x + y * mWidth;
MapItem *const tile = mTiles[idx];
- if (tile)
+ if (tile != nullptr)
{
tile->setType(type);
tile->setPos(x, y);
@@ -105,7 +105,7 @@ void SpecialLayer::addRoad(const Path &road)
{
const Position &pos = (*i);
MapItem *const item = getTile(pos.x, pos.y);
- if (!item)
+ if (item == nullptr)
setTile(pos.x, pos.y, new MapItem(MapItemType::ROAD));
else
item->setType(MapItemType::ROAD);
@@ -115,13 +115,13 @@ void SpecialLayer::addRoad(const Path &road)
void SpecialLayer::clean()
{
- if (!mTiles)
+ if (mTiles == nullptr)
return;
for (int f = 0; f < mWidth * mHeight; f ++)
{
MapItem *const item = mTiles[f];
- if (item)
+ if (item != nullptr)
item->setType(MapItemType::EMPTY);
}
updateCache();
@@ -148,7 +148,7 @@ void SpecialLayer::draw(Graphics *const graphics, int startX, int startY,
for (int x = startX; x < endX; x ++)
{
const MapItem *const item = mTiles[x + y2];
- if (item)
+ if (item != nullptr)
{
item->draw(graphics, x * mapTileSize - scrollX, py,
mapTileSize, mapTileSize);
diff --git a/src/resources/map/tileanimation.cpp b/src/resources/map/tileanimation.cpp
index 03a6ff1f4..c8ce52a70 100644
--- a/src/resources/map/tileanimation.cpp
+++ b/src/resources/map/tileanimation.cpp
@@ -44,7 +44,7 @@ TileAnimation::~TileAnimation()
bool TileAnimation::update(const int ticks)
{
- if (!mAnimation)
+ if (mAnimation == nullptr)
return false;
// update animation
@@ -57,7 +57,7 @@ bool TileAnimation::update(const int ticks)
{
FOR_EACH (TilePairVectorCIter, i, mAffected)
{
- if (i->first)
+ if (i->first != nullptr)
i->first->setTile(i->second, img);
}
mLastImage = img;