summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
Diffstat (limited to 'src/being')
-rw-r--r--src/being/actor.cpp16
-rw-r--r--src/being/actorsprite.cpp41
-rw-r--r--src/being/being.cpp572
-rw-r--r--src/being/being.h15
-rw-r--r--src/being/castingeffect.cpp12
-rw-r--r--src/being/compoundsprite.cpp50
-rw-r--r--src/being/crazymoves.cpp52
-rw-r--r--src/being/flooritem.cpp8
-rw-r--r--src/being/localplayer.cpp332
-rw-r--r--src/being/localplayer.h4
-rw-r--r--src/being/playerinfo.cpp76
-rw-r--r--src/being/playerrelations.cpp89
12 files changed, 669 insertions, 598 deletions
diff --git a/src/being/actor.cpp b/src/being/actor.cpp
index 9039c0128..a881c005e 100644
--- a/src/being/actor.cpp
+++ b/src/being/actor.cpp
@@ -37,7 +37,7 @@ Actor::Actor() :
Actor::~Actor()
{
- if (mMap)
+ if (mMap != nullptr)
{
mMap->removeActor(mMapActor);
mMap = nullptr;
@@ -47,28 +47,34 @@ Actor::~Actor()
void Actor::setMap(Map *const map)
{
// Remove Actor from potential previous map
- if (mMap)
+ if (mMap != nullptr)
mMap->removeActor(mMapActor);
mMap = map;
// Add Actor to potential new map
- if (mMap)
+ if (mMap != nullptr)
mMapActor = mMap->addActor(this);
}
int Actor::getTileX() const
{
- if (!mMap || !mMap->getTileWidth())
+ if (mMap == nullptr ||
+ mMap->getTileWidth() == 0)
+ {
return 0;
+ }
return getPixelX() / mMap->getTileWidth();
}
int Actor::getTileY() const
{
- if (!mMap || !mMap->getTileHeight())
+ if (mMap == nullptr ||
+ mMap->getTileHeight() == 0)
+ {
return 0;
+ }
return getPixelY() / mMap->getTileHeight();
}
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index fc4850e32..71970b7ff 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -93,8 +93,12 @@ ActorSprite::~ActorSprite()
mUsedTargetCursor = nullptr;
- if (localPlayer && localPlayer != this && localPlayer->getTarget() == this)
+ if (localPlayer != nullptr &&
+ localPlayer != this &&
+ localPlayer->getTarget() == this)
+ {
localPlayer->setTarget(nullptr);
+ }
// Notify listeners of the destruction.
FOR_EACH (ActorSpriteListenerIterator, iter, mActorSpriteListeners)
@@ -118,7 +122,8 @@ void ActorSprite::logic()
{
const StatusEffect *const effect
= StatusEffectDB::getStatusEffect(*it, Enable_true);
- if (effect && effect->mIsPersistent)
+ if (effect != nullptr &&
+ effect->mIsPersistent)
{
updateStatusEffect(*it,
Enable_true,
@@ -143,7 +148,7 @@ void ActorSprite::setMap(Map *const map)
void ActorSprite::controlAutoParticle(Particle *const particle)
{
- if (particle)
+ if (particle != nullptr)
{
particle->setActor(mId);
mChildParticleEffects.addLocally(particle);
@@ -152,7 +157,7 @@ void ActorSprite::controlAutoParticle(Particle *const particle)
void ActorSprite::controlCustomParticle(Particle *const particle)
{
- if (particle)
+ if (particle != nullptr)
{
// The effect may not die without the beings permission or we segfault
particle->disableAutoDelete();
@@ -162,7 +167,7 @@ void ActorSprite::controlCustomParticle(Particle *const particle)
void ActorSprite::controlParticleDeleted(const Particle *const particle)
{
- if (particle)
+ if (particle != nullptr)
mChildParticleEffects.removeLocally(particle);
}
@@ -176,7 +181,7 @@ void ActorSprite::setTargetType(const TargetCursorTypeT type)
{
const size_t sz = CAST_SIZE(getTargetCursorSize());
mUsedTargetCursor = targetCursor[CAST_S32(type)][sz];
- if (mUsedTargetCursor)
+ if (mUsedTargetCursor != nullptr)
{
static const int targetWidths[CAST_SIZE(
TargetCursorSize::NUM_TC)]
@@ -264,7 +269,8 @@ static void applyEffectByOption(ActorSprite *const actor,
enable,
IsStart_false);
}
- if (option && config.getBoolValue("unimplimentedLog"))
+ if (option != 0U &&
+ config.getBoolValue("unimplimentedLog"))
{
const std::string str = strprintf(
"Error: unknown effect by %s. "
@@ -299,7 +305,8 @@ static void applyEffectByOption1(ActorSprite *const actor,
IsStart_false);
}
}
- if (option && config.getBoolValue("unimplimentedLog"))
+ if (option != 0 &&
+ config.getBoolValue("unimplimentedLog"))
{
const std::string str = strprintf(
"Error: unknown effect by %s. "
@@ -385,7 +392,7 @@ void ActorSprite::updateStatusEffect(const int32_t index,
{
StatusEffect *const effect = StatusEffectDB::getStatusEffect(
index, newStatus);
- if (!effect)
+ if (effect == nullptr)
return;
if (effect->mIsPoison && getType() == ActorType::Player)
setPoison(newStatus == Enable_true);
@@ -415,9 +422,9 @@ void ActorSprite::handleStatusEffect(const StatusEffect *const effect,
Particle *particle = nullptr;
if (start == IsStart_true)
particle = effect->getStartParticle();
- if (!particle)
+ if (particle == nullptr)
particle = effect->getParticle();
- if (particle)
+ if (particle != nullptr)
mStatusParticleEffects.setLocally(effectId, particle);
}
}
@@ -436,7 +443,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
FOR_EACH (SpriteRefs, it, display.sprites)
{
- if (!*it)
+ if (*it == nullptr)
continue;
const std::string file = pathJoin(paths.getStringValue("sprites"),
combineDye3((*it)->sprite, color));
@@ -472,11 +479,11 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
imagePath = combineDye2(imagePath, color);
Image *img = Loader::getImage(imagePath);
- if (!img)
+ if (img == nullptr)
img = Theme::getImageFromTheme("unknown-item.png");
addSprite(new ImageSprite(img));
- if (img)
+ if (img != nullptr)
img->decRef();
}
}
@@ -484,7 +491,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
mChildParticleEffects.clear();
// setup particle effects
- if (ParticleEngine::enabled && particleEngine)
+ if (ParticleEngine::enabled && (particleEngine != nullptr))
{
FOR_EACH (StringVectCIter, itr, display.particles)
{
@@ -575,7 +582,7 @@ void ActorSprite::cleanupTargetCursors()
{
for_each_cursors()
{
- if (targetCursor[type][size])
+ if (targetCursor[type][size] != nullptr)
delete2(targetCursor[type][size])
}
end_foreach
@@ -592,7 +599,7 @@ std::string ActorSprite::getStatusEffectsString() const
StatusEffectDB::getStatusEffect(
*it,
Enable_true);
- if (!effect)
+ if (effect == nullptr)
continue;
if (!effectsStr.empty())
effectsStr.append(", ");
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 4082f6f07..4db35b3c3 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -203,8 +203,10 @@ Being::Being(const BeingId id,
mIsGM(false),
mType(type),
mSpeechBubble(nullptr),
- mWalkSpeed(playerHandler ? playerHandler->getDefaultWalkSpeed() : 1),
- mSpeed(playerHandler ? playerHandler->getDefaultWalkSpeed() : 1),
+ mWalkSpeed(playerHandler != nullptr ?
+ playerHandler->getDefaultWalkSpeed() : 1),
+ mSpeed(playerHandler != nullptr ?
+ playerHandler->getDefaultWalkSpeed() : 1),
mIp(),
mSpriteRemap(new int[20]),
mSpriteHide(new int[20]),
@@ -358,7 +360,7 @@ void Being::createSpeechBubble() restrict2
void Being::setSubtype(const BeingTypeId subtype,
const uint16_t look) restrict2
{
- if (!mInfo)
+ if (mInfo == nullptr)
return;
if (subtype == mSubType && mLook == look)
@@ -371,7 +373,7 @@ void Being::setSubtype(const BeingTypeId subtype,
{
case ActorType::Monster:
mInfo = MonsterDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -383,7 +385,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Pet:
mInfo = PETDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -395,7 +397,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Mercenary:
mInfo = MercenaryDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -407,7 +409,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Homunculus:
mInfo = HomunculusDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -419,7 +421,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::SkillUnit:
mInfo = SkillUnitDb::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -431,7 +433,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Elemental:
mInfo = ElementalDb::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay(),
@@ -443,7 +445,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Npc:
mInfo = NPCDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
{
setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
mYDiff = mInfo->getSortOffsetY();
@@ -451,7 +453,7 @@ void Being::setSubtype(const BeingTypeId subtype,
break;
case ActorType::Avatar:
mInfo = AvatarDB::get(mSubType);
- if (mInfo)
+ if (mInfo != nullptr)
setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
break;
case ActorType::Player:
@@ -463,7 +465,7 @@ void Being::setSubtype(const BeingTypeId subtype,
id = -100;
// TRANSLATORS: default race name
setRaceName(_("Human"));
- if (charServerHandler)
+ if (charServerHandler != nullptr)
{
setSpriteId(charServerHandler->baseSprite(),
id);
@@ -473,7 +475,7 @@ void Being::setSubtype(const BeingTypeId subtype,
{
const ItemInfo &restrict info = ItemDB::get(id);
setRaceName(info.getName());
- if (charServerHandler)
+ if (charServerHandler != nullptr)
{
setSpriteColor(charServerHandler->baseSprite(),
id,
@@ -495,7 +497,7 @@ void Being::setSubtype(const BeingTypeId subtype,
TargetCursorSizeT Being::getTargetCursorSize() const restrict2
{
- if (!mInfo)
+ if (mInfo == nullptr)
return TargetCursorSize::SMALL;
return mInfo->getTargetCursorSize();
@@ -507,7 +509,7 @@ void Being::setPixelPositionF(const Vector &restrict pos) restrict2
updateCoords();
- if (mText)
+ if (mText != nullptr)
{
mText->adviseXY(CAST_S32(pos.x),
CAST_S32(pos.y) - getHeight() - mText->getHeight() - 9,
@@ -518,7 +520,7 @@ void Being::setPixelPositionF(const Vector &restrict pos) restrict2
void Being::setDestination(const int dstX,
const int dstY) restrict2
{
- if (!mMap)
+ if (mMap == nullptr)
return;
setPath(mMap->findPath(mX, mY, dstX, dstY, getBlockWalkMask()));
@@ -546,11 +548,11 @@ void Being::setSpeech(const std::string &restrict text,
const std::string &restrict channel,
int time) restrict2
{
- if (!userPalette)
+ if (userPalette == nullptr)
return;
- if (!channel.empty() && (!langChatTab || langChatTab->getChannelName()
- != channel))
+ if (!channel.empty() &&
+ ((langChatTab == nullptr) || langChatTab->getChannelName() != channel))
{
return;
}
@@ -569,7 +571,7 @@ void Being::setSpeech(const std::string &restrict text,
if (mSpeech.empty())
return;
- if (!time)
+ if (time == 0)
{
const size_t sz = mSpeech.size();
if (sz < 200)
@@ -634,9 +636,9 @@ void Being::setSpeech(const std::string &restrict text,
else
{
const bool isShowName = (speech == BeingSpeech::NAME_IN_BUBBLE);
- if (!mSpeechBubble)
+ if (mSpeechBubble == nullptr)
createSpeechBubble();
- if (mSpeechBubble)
+ if (mSpeechBubble != nullptr)
{
mSpeechBubble->setCaption(isShowName ? mName : "");
mSpeechBubble->setText(mSpeech, isShowName);
@@ -650,18 +652,18 @@ void Being::takeDamage(Being *restrict const attacker,
const int attackId,
const int level) restrict2
{
- if (!userPalette || !attacker)
+ if ((userPalette == nullptr) || (attacker == nullptr))
return;
BLOCK_START("Being::takeDamage1")
Font *font = nullptr;
- const std::string damage = amount ? toString(amount) :
+ const std::string damage = amount != 0 ? toString(amount) :
// TRANSLATORS: dodge or miss message in attacks
type == AttackType::FLEE ? _("dodge") : _("miss");
const Color *color;
- if (gui)
+ if (gui != nullptr)
font = gui->getInfoParticleFont();
// Selecting the right color
@@ -680,7 +682,7 @@ void Being::takeDamage(Being *restrict const attacker,
color = &userPalette->getColor(UserColorId::HIT_CRITICAL);
}
}
- else if (!amount)
+ else if (amount == 0)
{
if (attacker == localPlayer)
{
@@ -724,18 +726,18 @@ void Being::takeDamage(Being *restrict const attacker,
color = &userPalette->getColor(UserColorId::HIT_MONSTER_PLAYER);
}
- if (chatWindow && mShowBattleEvents)
+ if ((chatWindow != nullptr) && mShowBattleEvents)
{
if (this == localPlayer)
{
- if (attacker->mType == ActorType::Player || amount)
+ if (attacker->mType == ActorType::Player || (amount != 0))
{
chatWindow->battleChatLog(strprintf("%s : Hit you -%d",
attacker->getName().c_str(), amount),
ChatMsgType::BY_OTHER);
}
}
- else if (attacker == localPlayer && amount)
+ else if (attacker == localPlayer && (amount != 0))
{
chatWindow->battleChatLog(strprintf("%s : You hit %s -%d",
attacker->mName.c_str(),
@@ -744,7 +746,7 @@ void Being::takeDamage(Being *restrict const attacker,
ChatMsgType::BY_PLAYER);
}
}
- if (font && particleEngine && color)
+ if ((font != nullptr) && (particleEngine != nullptr) && (color != nullptr))
{
// Show damage number
particleEngine->addTextSplashEffect(damage,
@@ -762,11 +764,11 @@ void Being::takeDamage(Being *restrict const attacker,
if (amount > 0)
{
- if (localPlayer && localPlayer == this)
+ if ((localPlayer != nullptr) && localPlayer == this)
localPlayer->setLastHitFrom(attacker->mName);
mDamageTaken += amount;
- if (mInfo)
+ if (mInfo != nullptr)
{
playSfx(mInfo->getSound(ItemSoundEvent::HURT),
this,
@@ -776,11 +778,11 @@ void Being::takeDamage(Being *restrict const attacker,
if (!mInfo->isStaticMaxHP())
{
- if (!mHP && mInfo->getMaxHP() < mDamageTaken)
+ if ((mHP == 0) && mInfo->getMaxHP() < mDamageTaken)
mInfo->setMaxHP(mDamageTaken);
}
}
- if (mHP && isAlive())
+ if ((mHP != 0) && isAlive())
{
mHP -= amount;
if (mHP < 0)
@@ -793,13 +795,13 @@ void Being::takeDamage(Being *restrict const attacker,
updateName();
}
else if (mType == ActorType::Player &&
- socialWindow &&
+ (socialWindow != nullptr) &&
!mName.empty())
{
socialWindow->updateAvatar(mName);
}
- if (effectManager)
+ if (effectManager != nullptr)
{
const int hitEffectId = getHitEffect(attacker,
type,
@@ -811,7 +813,7 @@ void Being::takeDamage(Being *restrict const attacker,
}
else
{
- if (effectManager)
+ if (effectManager != nullptr)
{
int hitEffectId = -1;
if (type == AttackType::SKILL)
@@ -840,7 +842,7 @@ int Being::getHitEffect(const Being *restrict const attacker,
const int attackId,
const int level) const restrict2
{
- if (!effectManager)
+ if (effectManager == nullptr)
return 0;
BLOCK_START("Being::getHitEffect")
@@ -851,7 +853,7 @@ int Being::getHitEffect(const Being *restrict const attacker,
{
const SkillData *restrict const data =
skillDialog->getSkillDataByLevel(attackId, level);
- if (!data)
+ if (data == nullptr)
return -1;
if (type == AttackType::SKILL)
{
@@ -868,11 +870,12 @@ int Being::getHitEffect(const Being *restrict const attacker,
}
else
{
- if (attacker)
+ if (attacker != nullptr)
{
const ItemInfo *restrict const attackerWeapon
= attacker->getEquippedWeapon();
- if (attackerWeapon && attacker->getType() == ActorType::Player)
+ if (attackerWeapon != nullptr &&
+ attacker->getType() == ActorType::Player)
{
if (type == AttackType::MISS)
hitEffectId = attackerWeapon->getMissEffectId();
@@ -884,11 +887,11 @@ int Being::getHitEffect(const Being *restrict const attacker,
else if (attacker->getType() == ActorType::Monster)
{
const BeingInfo *restrict const info = attacker->getInfo();
- if (info)
+ if (info != nullptr)
{
const Attack *restrict const atk =
info->getAttack(attackId);
- if (atk)
+ if (atk != nullptr)
{
if (type == AttackType::MISS)
hitEffectId = atk->mMissEffectId;
@@ -931,7 +934,7 @@ void Being::handleAttack(Being *restrict const victim,
const int damage,
const int attackId) restrict2
{
- if (!victim || !mInfo)
+ if ((victim == nullptr) || (mInfo == nullptr))
return;
BLOCK_START("Being::handleAttack")
@@ -942,9 +945,9 @@ void Being::handleAttack(Being *restrict const victim,
mLastAttackX = victim->mX;
mLastAttackY = victim->mY;
- if (mType == ActorType::Player && mEquippedWeapon)
+ if (mType == ActorType::Player && (mEquippedWeapon != nullptr))
fireMissile(victim, mEquippedWeapon->getMissileParticleFile());
- else if (mInfo->getAttack(attackId))
+ else if (mInfo->getAttack(attackId) != nullptr)
fireMissile(victim, mInfo->getAttack(attackId)->mMissileParticle);
reset();
@@ -955,11 +958,11 @@ void Being::handleAttack(Being *restrict const victim,
{
const uint8_t dir = calcDirection(victim->mX,
victim->mY);
- if (dir)
+ if (dir != 0u)
setDirection(dir);
}
- if (damage && victim->mType == ActorType::Player
+ if ((damage != 0) && victim->mType == ActorType::Player
&& victim->mAction == BeingAction::SIT)
{
victim->setAction(BeingAction::STAND, 0);
@@ -971,7 +974,7 @@ void Being::handleAttack(Being *restrict const victim,
{
// here 10 is weapon slot
int weaponId = mSlots[10].spriteId;
- if (!weaponId)
+ if (weaponId == 0)
weaponId = -100 - toInt(mSubType, int);
const ItemInfo &info = ItemDB::get(weaponId);
playSfx(info.getSound(
@@ -993,7 +996,7 @@ void Being::handleSkillCasting(Being *restrict const victim,
const int skillId,
const int skillLevel) restrict2
{
- if (!victim || !mInfo || !skillDialog)
+ if ((victim == nullptr) || (mInfo == nullptr) || (skillDialog == nullptr))
return;
setAction(BeingAction::CAST, skillId);
@@ -1002,7 +1005,7 @@ void Being::handleSkillCasting(Being *restrict const victim,
skillId,
skillLevel);
- if (data)
+ if (data != nullptr)
{
effectManager->triggerDefault(data->castingSrcEffectId,
this,
@@ -1019,13 +1022,13 @@ void Being::handleSkill(Being *restrict const victim,
const int skillId,
const int skillLevel) restrict2
{
- if (!victim || !mInfo || !skillDialog)
+ if ((victim == nullptr) || (mInfo == nullptr) || (skillDialog == nullptr))
return;
const SkillInfo *restrict const skill = skillDialog->getSkill(skillId);
- const SkillData *restrict const data = skill
+ const SkillData *restrict const data = skill != nullptr
? skill->getData1(skillLevel) : nullptr;
- if (data)
+ if (data != nullptr)
{
effectManager->triggerDefault(data->srcEffectId,
this,
@@ -1036,7 +1039,7 @@ void Being::handleSkill(Being *restrict const victim,
fireMissile(victim, data->particle);
}
- if (this != localPlayer && skill)
+ if (this != localPlayer && (skill != nullptr))
{
const SkillType::SkillType type = skill->type;
if ((type & SkillType::Attack) != 0 ||
@@ -1058,15 +1061,15 @@ void Being::handleSkill(Being *restrict const victim,
{
const uint8_t dir = calcDirection(victim->mX,
victim->mY);
- if (dir)
+ if (dir != 0u)
setDirection(dir);
}
- if (damage && victim->mType == ActorType::Player
+ if ((damage != 0) && victim->mType == ActorType::Player
&& victim->mAction == BeingAction::SIT)
{
victim->setAction(BeingAction::STAND, 0);
}
- if (data)
+ if (data != nullptr)
{
if (damage > 0)
playSfx(data->soundHit, victim, true, mX, mY);
@@ -1086,7 +1089,7 @@ void Being::handleSkill(Being *restrict const victim,
void Being::showNameBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Name]);
- if (show && !mName.empty() && mShowBadges)
+ if (show && !mName.empty() && (mShowBadges != 0u))
{
const std::string badge = BadgesDB::getNameBadge(mName);
if (!badge.empty())
@@ -1143,7 +1146,7 @@ void Being::setShowName(const bool doShowName) restrict2
void Being::showGuildBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Guild]);
- if (show && !mGuildName.empty() && mShowBadges)
+ if (show && !mGuildName.empty() && (mShowBadges != 0u))
{
const std::string badge = BadgesDB::getGuildBadge(mGuildName);
if (!badge.empty())
@@ -1170,21 +1173,21 @@ void Being::setGuildPos(const std::string &restrict pos A_UNUSED) restrict2
void Being::addGuild(Guild *restrict const guild) restrict2
{
- if (!guild)
+ if (guild == nullptr)
return;
mGuilds[guild->getId()] = guild;
- if (this == localPlayer && socialWindow)
+ if (this == localPlayer && (socialWindow != nullptr))
socialWindow->addTab(guild);
}
void Being::removeGuild(const int id) restrict2
{
- if (this == localPlayer && socialWindow)
+ if (this == localPlayer && (socialWindow != nullptr))
socialWindow->removeTab(mGuilds[id]);
- if (mGuilds[id])
+ if (mGuilds[id] != nullptr)
mGuilds[id]->removeMember(mName);
mGuilds.erase(id);
}
@@ -1195,7 +1198,7 @@ const Guild *Being::getGuild(const std::string &restrict guildName) const
FOR_EACH (GuildsMapCIter, itr, mGuilds)
{
const Guild *restrict const guild = itr->second;
- if (guild && guild->getName() == guildName)
+ if ((guild != nullptr) && guild->getName() == guildName)
return guild;
}
@@ -1226,9 +1229,9 @@ void Being::clearGuilds() restrict2
{
Guild *const guild = itr->second;
- if (guild)
+ if (guild != nullptr)
{
- if (this == localPlayer && socialWindow)
+ if (this == localPlayer && (socialWindow != nullptr))
socialWindow->removeTab(guild);
guild->removeMember(mId);
@@ -1246,37 +1249,37 @@ void Being::setParty(Party *restrict const party) restrict2
Party *const old = mParty;
mParty = party;
- if (old)
+ if (old != nullptr)
old->removeMember(mId);
- if (party)
+ if (party != nullptr)
party->addMember(mId, mName);
updateColors();
- if (this == localPlayer && socialWindow)
+ if (this == localPlayer && (socialWindow != nullptr))
{
- if (old)
+ if (old != nullptr)
socialWindow->removeTab(old);
- if (party)
+ if (party != nullptr)
socialWindow->addTab(party);
}
}
void Being::updateGuild() restrict2
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
Guild *restrict const guild = localPlayer->getGuild();
- if (!guild)
+ if (guild == nullptr)
{
clearGuilds();
updateColors();
return;
}
- if (guild->getMember(mName))
+ if (guild->getMember(mName) != nullptr)
{
setGuild(guild);
if (!guild->getName().empty())
@@ -1294,17 +1297,17 @@ void Being::setGuild(Guild *restrict const guild) restrict2
clearGuilds();
addGuild(guild);
- if (old)
+ if (old != nullptr)
old->removeMember(mName);
updateColors();
- if (this == localPlayer && socialWindow)
+ if (this == localPlayer && (socialWindow != nullptr))
{
- if (old)
+ if (old != nullptr)
socialWindow->removeTab(old);
- if (guild)
+ if (guild != nullptr)
socialWindow->addTab(guild);
}
}
@@ -1312,14 +1315,14 @@ void Being::setGuild(Guild *restrict const guild) restrict2
void Being::fireMissile(Being *restrict const victim,
const std::string &restrict particle) const restrict2
{
- if (!victim || particle.empty() || !particleEngine)
+ if ((victim == nullptr) || particle.empty() || (particleEngine == nullptr))
return;
BLOCK_START("Being::fireMissile")
Particle *restrict const target = particleEngine->createChild();
- if (!target)
+ if (target == nullptr)
{
BLOCK_END("Being::fireMissile")
return;
@@ -1330,7 +1333,7 @@ void Being::fireMissile(Being *restrict const victim,
mPixelX,
mPixelY);
- if (missile)
+ if (missile != nullptr)
{
target->moveBy(Vector(0.0F, 0.0F, 32.0F));
target->setLifetime(1000);
@@ -1347,14 +1350,14 @@ std::string Being::getSitAction() const restrict2
{
if (mHorseId != 0)
return SpriteAction::SITRIDE;
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
- if (mask & BlockMask::GROUNDTOP)
+ if ((mask & BlockMask::GROUNDTOP) != 0)
return SpriteAction::SITTOP;
- else if (mask & BlockMask::AIR)
+ else if ((mask & BlockMask::AIR) != 0)
return SpriteAction::SITSKY;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return SpriteAction::SITWATER;
}
return SpriteAction::SIT;
@@ -1365,12 +1368,12 @@ std::string Being::getMoveAction() const restrict2
{
if (mHorseId != 0)
return SpriteAction::RIDE;
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return SpriteAction::FLY;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return SpriteAction::SWIM;
}
return SpriteAction::MOVE;
@@ -1379,17 +1382,17 @@ std::string Being::getMoveAction() const restrict2
std::string Being::getWeaponAttackAction(const ItemInfo *restrict const weapon)
const restrict2
{
- if (!weapon)
+ if (weapon == nullptr)
return getAttackAction();
if (mHorseId != 0)
return weapon->getRideAttackAction();
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return weapon->getSkyAttackAction();
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return weapon->getWaterAttackAction();
}
return weapon->getAttackAction();
@@ -1398,17 +1401,17 @@ std::string Being::getWeaponAttackAction(const ItemInfo *restrict const weapon)
std::string Being::getAttackAction(const Attack *restrict const attack1) const
restrict2
{
- if (!attack1)
+ if (attack1 == nullptr)
return getAttackAction();
if (mHorseId != 0)
return attack1->mRideAction;
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return attack1->mSkyAction;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return attack1->mWaterAction;
}
return attack1->mAction;
@@ -1417,17 +1420,17 @@ std::string Being::getAttackAction(const Attack *restrict const attack1) const
std::string Being::getCastAction(const SkillInfo *restrict const skill) const
restrict2
{
- if (!skill)
+ if (skill == nullptr)
return getCastAction();
if (mHorseId != 0)
return skill->castingRideAction;
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return skill->castingSkyAction;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return skill->castingWaterAction;
}
return skill->castingAction;
@@ -1458,23 +1461,23 @@ std::string Being::getStandAction() const restrict2
{
if (mHorseId != 0)
return SpriteAction::STANDRIDE;
- if (mMap)
+ if (mMap != nullptr)
{
const unsigned char mask = mMap->getBlockMask(mX, mY);
if (mTrickDead)
{
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return SpriteAction::DEADSKY;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return SpriteAction::DEADWATER;
else
return SpriteAction::DEAD;
}
else
{
- if (mask & BlockMask::AIR)
+ if ((mask & BlockMask::AIR) != 0)
return SpriteAction::STANDSKY;
- else if (mask & BlockMask::WATER)
+ else if ((mask & BlockMask::WATER) != 0)
return SpriteAction::STANDWATER;
}
}
@@ -1489,7 +1492,7 @@ void Being::setAction(const BeingActionT &restrict action,
switch (action)
{
case BeingAction::MOVE:
- if (mInfo)
+ if (mInfo != nullptr)
{
playSfx(mInfo->getSound(
ItemSoundEvent::MOVE), nullptr, true, mX, mY);
@@ -1501,7 +1504,7 @@ void Being::setAction(const BeingActionT &restrict action,
break;
case BeingAction::SIT:
currentAction = getSitAction();
- if (mInfo)
+ if (mInfo != nullptr)
{
ItemSoundEvent::Type event;
if (currentAction == SpriteAction::SITTOP)
@@ -1512,21 +1515,21 @@ void Being::setAction(const BeingActionT &restrict action,
}
break;
case BeingAction::ATTACK:
- if (mEquippedWeapon)
+ if (mEquippedWeapon != nullptr)
{
currentAction = getWeaponAttackAction(mEquippedWeapon);
reset();
}
else
{
- if (!mInfo || !mInfo->getAttack(attackId))
+ if ((mInfo == nullptr) || (mInfo->getAttack(attackId) == nullptr))
break;
currentAction = getAttackAction(mInfo->getAttack(attackId));
reset();
// attack particle effect
- if (ParticleEngine::enabled && effectManager)
+ if (ParticleEngine::enabled && (effectManager != nullptr))
{
const int effectId = mInfo->getAttack(attackId)->mEffectId;
if (effectId >= 0)
@@ -1539,7 +1542,7 @@ void Being::setAction(const BeingActionT &restrict action,
}
break;
case BeingAction::CAST:
- if (skillDialog)
+ if (skillDialog != nullptr)
{
const SkillInfo *restrict const info =
skillDialog->getSkill(attackId);
@@ -1547,7 +1550,7 @@ void Being::setAction(const BeingActionT &restrict action,
}
break;
case BeingAction::HURT:
- if (mInfo)
+ if (mInfo != nullptr)
{
playSfx(mInfo->getSound(ItemSoundEvent::HURT),
this, false, mX, mY);
@@ -1555,7 +1558,7 @@ void Being::setAction(const BeingActionT &restrict action,
break;
case BeingAction::DEAD:
currentAction = getDeadAction();
- if (mInfo)
+ if (mInfo != nullptr)
{
playSfx(mInfo->getSound(ItemSoundEvent::DIE),
this,
@@ -1573,7 +1576,7 @@ void Being::setAction(const BeingActionT &restrict action,
currentAction = getStandAction();
break;
case BeingAction::SPAWN:
- if (mInfo)
+ if (mInfo != nullptr)
{
playSfx(mInfo->getSound(ItemSoundEvent::SPAWN),
nullptr, true, mX, mY);
@@ -1591,14 +1594,14 @@ void Being::setAction(const BeingActionT &restrict action,
{
mSpriteAction = currentAction;
play(currentAction);
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
mEmotionSprite->play(currentAction);
- if (mAnimationEffect)
+ if (mAnimationEffect != nullptr)
mAnimationEffect->play(currentAction);
for_each_badges()
{
AnimatedSprite *const sprite = mBadges[f];
- if (sprite)
+ if (sprite != nullptr)
sprite->play(currentAction);
}
for_each_horses(mDownHorseSprites)
@@ -1627,29 +1630,29 @@ void Being::setDirection(const uint8_t direction) restrict2
// if the direction does not change much, keep the common component
int mFaceDirection = mDirection & direction;
- if (!mFaceDirection)
+ if (mFaceDirection == 0)
mFaceDirection = direction;
SpriteDirection::Type dir;
- if (mFaceDirection & BeingDirection::UP)
+ if ((mFaceDirection & BeingDirection::UP) != 0)
{
- if (mFaceDirection & BeingDirection::LEFT)
+ if ((mFaceDirection & BeingDirection::LEFT) != 0)
dir = SpriteDirection::UPLEFT;
- else if (mFaceDirection & BeingDirection::RIGHT)
+ else if ((mFaceDirection & BeingDirection::RIGHT) != 0)
dir = SpriteDirection::UPRIGHT;
else
dir = SpriteDirection::UP;
}
- else if (mFaceDirection & BeingDirection::DOWN)
+ else if ((mFaceDirection & BeingDirection::DOWN) != 0)
{
- if (mFaceDirection & BeingDirection::LEFT)
+ if ((mFaceDirection & BeingDirection::LEFT) != 0)
dir = SpriteDirection::DOWNLEFT;
- else if (mFaceDirection & BeingDirection::RIGHT)
+ else if ((mFaceDirection & BeingDirection::RIGHT) != 0)
dir = SpriteDirection::DOWNRIGHT;
else
dir = SpriteDirection::DOWN;
}
- else if (mFaceDirection & BeingDirection::RIGHT)
+ else if ((mFaceDirection & BeingDirection::RIGHT) != 0)
{
dir = SpriteDirection::RIGHT;
}
@@ -1660,15 +1663,15 @@ void Being::setDirection(const uint8_t direction) restrict2
mSpriteDirection = dir;
CompoundSprite::setSpriteDirection(dir);
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
mEmotionSprite->setSpriteDirection(dir);
- if (mAnimationEffect)
+ if (mAnimationEffect != nullptr)
mAnimationEffect->setSpriteDirection(dir);
for_each_badges()
{
AnimatedSprite *const sprite = mBadges[f];
- if (sprite)
+ if (sprite != nullptr)
sprite->setSpriteDirection(dir);
}
@@ -1721,10 +1724,11 @@ void Being::nextTile() restrict2
mPath.pop_front();
const uint8_t dir = calcDirection(pos.x, pos.y);
- if (dir)
+ if (dir != 0u)
setDirection(dir);
- if (!mMap || !mMap->getWalk(pos.x, pos.y, getBlockWalkMask()))
+ if (mMap == nullptr ||
+ !mMap->getWalk(pos.x, pos.y, getBlockWalkMask()))
{
setAction(BeingAction::STAND, 0);
return;
@@ -1779,7 +1783,7 @@ void Being::logic() restrict2
}
const int time = tick_time * MILLISECONDS_IN_A_TICK;
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
mEmotionSprite->update(time);
for_each_horses(mDownHorseSprites)
(*it)->update(time);
@@ -1807,7 +1811,7 @@ void Being::logic() restrict2
for_each_badges()
{
AnimatedSprite *restrict const sprite = mBadges[f];
- if (sprite)
+ if (sprite != nullptr)
sprite->update(time);
}
@@ -1833,11 +1837,11 @@ void Being::logic() restrict2
case BeingAction::ATTACK:
{
- if (!mActionTime)
+ if (mActionTime == 0)
break;
int curFrame = 0;
- if (mAttackSpeed)
+ if (mAttackSpeed != 0)
{
curFrame = (get_elapsed_time(mActionTime) * frameCount)
/ mAttackSpeed;
@@ -1864,10 +1868,10 @@ void Being::logic() restrict2
const int yOffset = getOffset<BeingDirection::UP,
BeingDirection::DOWN>();
int offset = xOffset;
- if (!offset)
+ if (offset == 0)
offset = yOffset;
- if (!xOffset && !yOffset)
+ if ((xOffset == 0) && (yOffset == 0))
mNeedPosUpdate = false;
const int halfTile = mapTileSize / 2;
@@ -1901,7 +1905,7 @@ void Being::logic() restrict2
gameHandler->removeDeadBeings() &&
get_elapsed_time(mActionTime) / mSpeed >= frameCount))
{
- if (mType != ActorType::Player && actorManager)
+ if (mType != ActorType::Player && (actorManager != nullptr))
actorManager->destroy(this);
}
@@ -1923,7 +1927,7 @@ void Being::logic() restrict2
void Being::botLogic() restrict2
{
- if (!mOwner || !mMap || !mInfo)
+ if ((mOwner == nullptr) || (mMap == nullptr) || (mInfo == nullptr))
return;
const int time = tick_time;
@@ -1975,7 +1979,7 @@ void Being::botLogic() restrict2
case BeingAction::ATTACK:
{
const Being *const target = localPlayer->getTarget();
- if (!target)
+ if (target == nullptr)
return;
const BeingId targetId = target->getId();
if (mType == ActorType::Homunculus)
@@ -2008,7 +2012,7 @@ void Being::botLogic() restrict2
void Being::botFixOffset(int &restrict dstX,
int &restrict dstY) const
{
- if (!mInfo || !mOwner)
+ if ((mInfo == nullptr) || (mOwner == nullptr))
return;
int offsetX1;
@@ -2068,7 +2072,7 @@ void Being::botFixOffset(int &restrict dstX,
}
dstX += offsetX;
dstY += offsetY;
- if (mMap)
+ if (mMap != nullptr)
{
if (!mMap->getWalk(dstX, dstY, getBlockWalkMask()))
{
@@ -2232,7 +2236,7 @@ void Being::updateBotDirection(const int dstX,
break;
}
}
- if (newDir && newDir != mDirection)
+ if ((newDir != 0u) && newDir != mDirection)
{
if (mType == ActorType::Homunculus)
homunculusHandler->setDirection(newDir);
@@ -2250,19 +2254,19 @@ void Being::drawEmotion(Graphics *restrict const graphics,
const int px = mPixelX - offsetX - mapTileSize / 2;
const int py = mPixelY - offsetY - mapTileSize * 2 - mapTileSize;
- if (mAnimationEffect)
+ if (mAnimationEffect != nullptr)
mAnimationEffect->draw(graphics, px, py);
- if (mShowBadges && mBadgesCount)
+ if ((mShowBadges != 0u) && (mBadgesCount != 0u))
{
int x;
int y;
- if (mShowBadges == 2 && mDispName && gui)
+ if (mShowBadges == 2 && (mDispName != nullptr) && (gui != nullptr))
{
const Font *restrict const font = gui->getFont();
x = mDispName->getX() - offsetX + mDispName->getWidth();
y = mDispName->getY() - offsetY - font->getHeight();
}
- else if (mShowBadges == 3 && mDispName && gui)
+ else if (mShowBadges == 3 && (mDispName != nullptr) && (gui != nullptr))
{
x = px + 8 - mBadgesCount * 8;
y = mDispName->getY() - offsetY;
@@ -2275,14 +2279,14 @@ void Being::drawEmotion(Graphics *restrict const graphics,
for_each_badges()
{
const AnimatedSprite *restrict const sprite = mBadges[f];
- if (sprite)
+ if (sprite != nullptr)
{
sprite->draw(graphics, x, y);
x += 16;
}
}
}
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
mEmotionSprite->draw(graphics, px, py);
}
@@ -2301,7 +2305,7 @@ void Being::drawSpeech(const int offsetX,
// Draw speech above this being
if (mSpeechTime == 0)
{
- if (mSpeechBubble && mSpeechBubble->mVisible == Visible_true)
+ if ((mSpeechBubble != nullptr) && mSpeechBubble->mVisible == Visible_true)
mSpeechBubble->setVisible(Visible_false);
mSpeech.clear();
}
@@ -2310,7 +2314,7 @@ void Being::drawSpeech(const int offsetX,
{
delete2(mText)
- if (mSpeechBubble)
+ if (mSpeechBubble != nullptr)
{
mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2),
py - getHeight() - (mSpeechBubble->getHeight()));
@@ -2320,10 +2324,10 @@ void Being::drawSpeech(const int offsetX,
}
else if (mSpeechTime > 0 && speech == BeingSpeech::TEXT_OVERHEAD)
{
- if (mSpeechBubble)
+ if (mSpeechBubble != nullptr)
mSpeechBubble->setVisible(Visible_false);
- if (!mText && userPalette)
+ if ((mText == nullptr) && (userPalette != nullptr))
{
mText = new Text(mSpeech,
mPixelX,
@@ -2338,7 +2342,7 @@ void Being::drawSpeech(const int offsetX,
}
else if (speech == BeingSpeech::NO_SPEECH)
{
- if (mSpeechBubble)
+ if (mSpeechBubble != nullptr)
mSpeechBubble->setVisible(Visible_false);
delete2(mText)
}
@@ -2381,12 +2385,12 @@ int Being::getOffset() const restrict2
void Being::updateCoords() restrict2
{
- if (!mDispName)
+ if (mDispName == nullptr)
return;
int offsetX = mPixelX;
int offsetY = mPixelY;
- if (mInfo)
+ if (mInfo != nullptr)
{
offsetX += mInfo->getNameOffsetX();
offsetY += mInfo->getNameOffsetY();
@@ -2406,7 +2410,7 @@ void Being::optionChanged(const std::string &restrict value) restrict2
void Being::flashName(const int time) restrict2
{
- if (mDispName)
+ if (mDispName != nullptr)
mDispName->flash(time);
}
@@ -2429,7 +2433,7 @@ std::string Being::getGenderSign() const restrict2
else if (getGender() == Gender::MALE)
str = "\u2642";
}
- if (mShowPlayersStatus && !mShowBadges)
+ if (mShowPlayersStatus && (mShowBadges == 0u))
{
if (mShop)
str.append("$");
@@ -2475,18 +2479,18 @@ void Being::showName() restrict2
}
Font *font = nullptr;
- if (localPlayer && localPlayer->getTarget() == this
+ if ((localPlayer != nullptr) && localPlayer->getTarget() == this
&& mType != ActorType::Monster)
{
font = boldFont;
}
else if (mType == ActorType::Player
- && !player_relations.isGoodName(this) && gui)
+ && !player_relations.isGoodName(this) && (gui != nullptr))
{
font = gui->getSecureFont();
}
- if (mInfo)
+ if (mInfo != nullptr)
{
mDispName = new FlashText(displayName,
mPixelX + mInfo->getNameOffsetX(),
@@ -2530,7 +2534,7 @@ void Being::setDefaultNameColor(const UserColorIdT defaultColor) restrict2
void Being::updateColors()
{
- if (userPalette)
+ if (userPalette != nullptr)
{
if (mType == ActorType::Monster)
{
@@ -2580,12 +2584,12 @@ void Being::updateColors()
{
mNameColor = &userPalette->getColor(UserColorId::ENEMY);
}
- else if (mParty && localPlayer
+ else if ((mParty != nullptr) && (localPlayer != nullptr)
&& mParty == localPlayer->getParty())
{
mNameColor = &userPalette->getColor(UserColorId::PARTY);
}
- else if (localPlayer && getGuild()
+ else if ((localPlayer != nullptr) && (getGuild() != nullptr)
&& getGuild() == localPlayer->getGuild())
{
mNameColor = &userPalette->getColor(UserColorId::GUILD);
@@ -2617,7 +2621,7 @@ void Being::updateColors()
}
}
- if (mDispName)
+ if (mDispName != nullptr)
mDispName->setColor(mNameColor);
}
}
@@ -2626,13 +2630,13 @@ void Being::updateSprite(const unsigned int slot,
const int id,
const std::string &restrict color) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSlots.size()))
mSlots.resize(slot + 1, BeingSlot());
- if (slot && mSlots[slot].spriteId == id)
+ if ((slot != 0u) && mSlots[slot].spriteId == id)
return;
setSpriteColor(slot,
id,
@@ -2643,7 +2647,7 @@ void Being::updateSprite(const unsigned int slot,
void Being::setSpriteId(const unsigned int slot,
const int id) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -2659,7 +2663,7 @@ void Being::setSpriteId(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = mSlots[slot].spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -2677,7 +2681,7 @@ void Being::setSpriteId(const unsigned int slot,
pathJoin(paths.getStringValue("sprites"), filename));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -2690,7 +2694,7 @@ void Being::setSpriteId(const unsigned int slot,
addItemParticles(id, info.getDisplay());
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -2706,14 +2710,14 @@ void Being::setSpriteId(const unsigned int slot,
beingSlot.colorId = ItemColor_one;
beingSlot.cardsId = CardsList(nullptr);
recalcSpritesOrder();
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
// reset sprite id, reset colors, reset cards
void Being::unSetSprite(const unsigned int slot) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -2727,7 +2731,7 @@ void Being::unSetSprite(const unsigned int slot) restrict2
BeingSlot &beingSlot = mSlots[slot];
const int id1 = beingSlot.spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
beingSlot.spriteId = 0;
@@ -2735,7 +2739,7 @@ void Being::unSetSprite(const unsigned int slot) restrict2
beingSlot.colorId = ItemColor_one;
beingSlot.cardsId = CardsList(nullptr);
recalcSpritesOrder();
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
@@ -2744,7 +2748,7 @@ void Being::setSpriteColor(const unsigned int slot,
const int id,
const std::string &color) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -2764,7 +2768,7 @@ void Being::setSpriteColor(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = mSlots[slot].spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -2783,7 +2787,7 @@ void Being::setSpriteColor(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -2796,7 +2800,7 @@ void Being::setSpriteColor(const unsigned int slot,
addItemParticles(id, info.getDisplay());
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -2812,7 +2816,7 @@ void Being::setSpriteColor(const unsigned int slot,
beingSlot.colorId = ItemColor_one;
beingSlot.cardsId = CardsList(nullptr);
recalcSpritesOrder();
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
@@ -2821,7 +2825,7 @@ void Being::setSpriteColorId(const unsigned int slot,
const int id,
ItemColor colorId) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -2843,7 +2847,7 @@ void Being::setSpriteColorId(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = mSlots[slot].spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -2863,7 +2867,7 @@ void Being::setSpriteColorId(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -2876,7 +2880,7 @@ void Being::setSpriteColorId(const unsigned int slot,
addItemParticles(id, info.getDisplay());
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -2892,7 +2896,7 @@ void Being::setSpriteColorId(const unsigned int slot,
beingSlot.colorId = colorId;
beingSlot.cardsId = CardsList(nullptr);
recalcSpritesOrder();
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
@@ -2901,7 +2905,7 @@ void Being::setSpriteCards(const unsigned int slot,
const int id,
const CardsList &cards) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -2924,7 +2928,7 @@ void Being::setSpriteCards(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = mSlots[slot].spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -2949,7 +2953,7 @@ void Being::setSpriteCards(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -2964,7 +2968,7 @@ void Being::setSpriteCards(const unsigned int slot,
cards);
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -2980,7 +2984,7 @@ void Being::setSpriteCards(const unsigned int slot,
beingSlot.colorId = colorId;
beingSlot.cardsId = CardsList(cards);
recalcSpritesOrder();
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
@@ -2995,7 +2999,7 @@ void Being::setWeaponId(const int id) restrict2
void Being::setTempSprite(const unsigned int slot,
const int id) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -3013,7 +3017,7 @@ void Being::setTempSprite(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = beingSlot.spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -3041,7 +3045,7 @@ void Being::setTempSprite(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -3055,7 +3059,7 @@ void Being::setTempSprite(const unsigned int slot,
addItemParticles(id, info.getDisplay());
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -3069,7 +3073,7 @@ void Being::setTempSprite(const unsigned int slot,
void Being::setHairTempSprite(const unsigned int slot,
const int id) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -3087,7 +3091,7 @@ void Being::setHairTempSprite(const unsigned int slot,
mSpriteDraw[slot] = 0;
const int id1 = mSlots[slot].spriteId;
- if (id1)
+ if (id1 != 0)
removeItemParticles(id1);
}
else
@@ -3114,7 +3118,7 @@ void Being::setHairTempSprite(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -3127,7 +3131,7 @@ void Being::setHairTempSprite(const unsigned int slot,
addItemParticles(id, info.getDisplay());
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -3150,7 +3154,7 @@ void Being::setHairColorSpriteID(const unsigned int slot,
void Being::setSpriteColor(const unsigned int slot,
const std::string &restrict color) restrict2
{
- if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
return;
if (slot >= CAST_U32(mSprites.size()))
@@ -3186,7 +3190,7 @@ void Being::setSpriteColor(const unsigned int slot,
combineDye(filename, color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -3196,7 +3200,7 @@ void Being::setSpriteColor(const unsigned int slot,
CompoundSprite::setSprite(slot, equipmentSprite);
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -3208,7 +3212,7 @@ void Being::setSpriteColor(const unsigned int slot,
beingSlot.color = color;
beingSlot.colorId = ItemColor_one;
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
@@ -3306,7 +3310,7 @@ bool Being::updateFromCache() restrict2
const BeingCacheEntry *restrict const entry =
Being::getCacheEntry(getId());
- if (entry && entry->getTime() + 120 >= cur_time)
+ if ((entry != nullptr) && entry->getTime() + 120 >= cur_time)
{
if (!entry->getName().empty())
setName(entry->getName());
@@ -3321,7 +3325,7 @@ bool Being::updateFromCache() restrict2
if (mAdvanced)
{
const int flags = entry->getFlags();
- if (serverFeatures &&
+ if ((serverFeatures != nullptr) &&
Net::getNetworkType() == ServerType::TMWATHENA)
{
mShop = ((flags & BeingFlag::SHOP) != 0);
@@ -3343,7 +3347,7 @@ bool Being::updateFromCache() restrict2
showInactiveBadge(mInactive);
showAwayBadge(mAway);
updateAwayEffect();
- if (mType == ActorType::Player || mTeamId)
+ if (mType == ActorType::Player || (mTeamId != 0u))
updateColors();
return true;
}
@@ -3356,7 +3360,7 @@ void Being::addToCache() const restrict2
return;
BeingCacheEntry *entry = Being::getCacheEntry(getId());
- if (!entry)
+ if (entry == nullptr)
{
entry = new BeingCacheEntry(getId());
beingInfoCache.push_front(entry);
@@ -3400,7 +3404,7 @@ BeingCacheEntry* Being::getCacheEntry(const BeingId id)
{
FOR_EACH (std::list<BeingCacheEntry*>::iterator, i, beingInfoCache)
{
- if (!*i)
+ if (*i == nullptr)
continue;
if (id == (*i)->getId())
@@ -3420,7 +3424,7 @@ BeingCacheEntry* Being::getCacheEntry(const BeingId id)
void Being::setGender(const GenderT gender) restrict2
{
- if (!charServerHandler)
+ if (charServerHandler == nullptr)
return;
if (gender != mGender)
@@ -3455,7 +3459,7 @@ void Being::setGender(const GenderT gender) restrict2
combineDye(filename, beingSlot.color)));
}
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
equipmentSprite->setSpriteDirection(getSpriteDirection());
startTime = getStartTime();
@@ -3464,7 +3468,7 @@ void Being::setGender(const GenderT gender) restrict2
CompoundSprite::setSprite(i, equipmentSprite);
setAction(mAction, 0);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
if (lastTime > 0)
{
@@ -3473,7 +3477,7 @@ void Being::setGender(const GenderT gender) restrict2
}
}
- if (beingEquipmentWindow)
+ if (beingEquipmentWindow != nullptr)
beingEquipmentWindow->updateBeing(this);
}
}
@@ -3485,7 +3489,7 @@ void Being::setGender(const GenderT gender) restrict2
void Being::showGmBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Gm]);
- if (show && mIsGM && mShowBadges)
+ if (show && mIsGM && (mShowBadges != 0u))
{
const std::string gmBadge = paths.getStringValue("gmbadge");
if (!gmBadge.empty())
@@ -3510,13 +3514,13 @@ void Being::setGM(const bool gm) restrict2
void Being::talkTo() const restrict2
{
- if (!npcHandler)
+ if (npcHandler == nullptr)
return;
if (!PacketLimiter::limitPackets(PacketType::PACKET_NPC_TALK))
{
// using workaround...
- if (playerHandler &&
+ if ((playerHandler != nullptr) &&
PacketLimiter::limitPackets(PacketType::PACKET_ATTACK))
{
playerHandler->attack(mId, Keep_false);
@@ -3537,7 +3541,7 @@ void Being::drawPlayer(Graphics *restrict const graphics,
const int px = mPixelX - mapTileSize / 2 + offsetX;
// getActorY() + offsetY;
const int py = mPixelY - mapTileSize + offsetY;
- if (mHorseInfo)
+ if (mHorseInfo != nullptr)
{
HorseOffset &offset = mHorseInfo->offsets[mSpriteDirection];
for_each_horses(mDownHorseSprites)
@@ -3571,10 +3575,10 @@ void Being::drawBeingCursor(Graphics *const graphics,
const int offsetX,
const int offsetY) const
{
- if (mUsedTargetCursor)
+ if (mUsedTargetCursor != nullptr)
{
mUsedTargetCursor->update(tick_time * MILLISECONDS_IN_A_TICK);
- if (!mInfo)
+ if (mInfo == nullptr)
{
mUsedTargetCursor->draw(graphics,
offsetX - mCursorPaddingX,
@@ -3722,7 +3726,7 @@ void Being::drawPlayerSprites(Graphics *restrict const graphics,
continue;
Sprite *restrict const sprite = mSprites[mSpriteRemap[f]];
- if (sprite)
+ if (sprite != nullptr)
{
sprite->setAlpha(mAlpha);
sprite->draw(graphics, posX, posY);
@@ -3742,7 +3746,7 @@ void Being::drawSpritesSDL(Graphics *restrict const graphics,
continue;
const Sprite *restrict const sprite = mSprites[mSpriteRemap[f]];
- if (sprite)
+ if (sprite != nullptr)
sprite->draw(graphics, posX, posY);
}
}
@@ -3765,13 +3769,13 @@ void Being::drawCompound(Graphics *const graphics,
if (mSprites.empty()) // Nothing to draw
return;
- if (mAlpha == 1.0F && mImage)
+ if (mAlpha == 1.0F && (mImage != nullptr))
{
graphics->drawImage(mImage,
posX + mOffsetX,
posY + mOffsetY);
}
- else if (mAlpha && mAlphaImage)
+ else if ((mAlpha != 0.0f) && (mAlphaImage != nullptr))
{
mAlphaImage->setAlpha(mAlpha);
graphics->drawImage(mAlphaImage,
@@ -3791,7 +3795,7 @@ void Being::drawPlayerSpriteAt(Graphics *restrict const graphics,
drawCompound(graphics, x, y);
if (mShowOwnHP &&
- mInfo &&
+ (mInfo != nullptr) &&
localPlayer == this &&
mAction != BeingAction::DEAD)
{
@@ -3823,14 +3827,14 @@ void Being::drawMonsterSpriteAt(Graphics *restrict const graphics,
mType == ActorType::Monster &&
mAction != BeingAction::DEAD)
{
- if (!userPalette)
+ if (userPalette == nullptr)
{
CompoundSprite::drawSimple(graphics, x, y);
return;
}
int attackRange;
- if (mAttackRange)
+ if (mAttackRange != 0)
attackRange = mapTileSize * mAttackRange;
else
attackRange = mapTileSize;
@@ -3846,14 +3850,14 @@ void Being::drawMonsterSpriteAt(Graphics *restrict const graphics,
CompoundSprite::drawSimple(graphics, x, y);
if (mShowMobHP &&
- mInfo &&
- localPlayer &&
+ (mInfo != nullptr) &&
+ (localPlayer != nullptr) &&
localPlayer->getTarget() == this &&
mType == ActorType::Monster)
{
// show hp bar here
int maxHP = mMaxHP;
- if (!maxHP)
+ if (maxHP == 0)
maxHP = mInfo->getMaxHP();
drawHpBar(graphics,
@@ -3876,14 +3880,14 @@ void Being::drawHomunculusSpriteAt(Graphics *restrict const graphics,
if (mHighlightMonsterAttackRange &&
mAction != BeingAction::DEAD)
{
- if (!userPalette)
+ if (userPalette == nullptr)
{
CompoundSprite::drawSimple(graphics, x, y);
return;
}
int attackRange;
- if (mAttackRange)
+ if (mAttackRange != 0)
attackRange = mapTileSize * mAttackRange;
else
attackRange = mapTileSize;
@@ -3899,15 +3903,15 @@ void Being::drawHomunculusSpriteAt(Graphics *restrict const graphics,
CompoundSprite::drawSimple(graphics, x, y);
if (mShowMobHP &&
- mInfo)
+ (mInfo != nullptr))
{
const HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (info &&
+ if ((info != nullptr) &&
mId == info->id)
{
// show hp bar here
int maxHP = PlayerInfo::getStatBase(Attributes::HOMUN_MAX_HP);
- if (!maxHP)
+ if (maxHP == 0)
maxHP = mInfo->getMaxHP();
drawHpBar(graphics,
@@ -3931,14 +3935,14 @@ void Being::drawMercenarySpriteAt(Graphics *restrict const graphics,
if (mHighlightMonsterAttackRange &&
mAction != BeingAction::DEAD)
{
- if (!userPalette)
+ if (userPalette == nullptr)
{
CompoundSprite::drawSimple(graphics, x, y);
return;
}
int attackRange;
- if (mAttackRange)
+ if (mAttackRange != 0)
attackRange = mapTileSize * mAttackRange;
else
attackRange = mapTileSize;
@@ -3954,15 +3958,15 @@ void Being::drawMercenarySpriteAt(Graphics *restrict const graphics,
CompoundSprite::drawSimple(graphics, x, y);
if (mShowMobHP &&
- mInfo)
+ (mInfo != nullptr))
{
const MercenaryInfo *const info = PlayerInfo::getMercenary();
- if (info &&
+ if ((info != nullptr) &&
mId == info->id)
{
// show hp bar here
int maxHP = PlayerInfo::getStatBase(Attributes::MERC_MAX_HP);
- if (!maxHP)
+ if (maxHP == 0)
maxHP = mInfo->getMaxHP();
drawHpBar(graphics,
@@ -3986,14 +3990,14 @@ void Being::drawElementalSpriteAt(Graphics *restrict const graphics,
if (mHighlightMonsterAttackRange &&
mAction != BeingAction::DEAD)
{
- if (!userPalette)
+ if (userPalette == nullptr)
{
CompoundSprite::drawSimple(graphics, x, y);
return;
}
int attackRange;
- if (mAttackRange)
+ if (mAttackRange != 0)
attackRange = mapTileSize * mAttackRange;
else
attackRange = mapTileSize;
@@ -4009,13 +4013,13 @@ void Being::drawElementalSpriteAt(Graphics *restrict const graphics,
CompoundSprite::drawSimple(graphics, x, y);
if (mShowMobHP &&
- mInfo)
+ (mInfo != nullptr))
{
if (mId == PlayerInfo::getElementalId())
{
// show hp bar here
int maxHP = PlayerInfo::getStatBase(Attributes::ELEMENTAL_MAX_HP);
- if (!maxHP)
+ if (maxHP == 0)
maxHP = mInfo->getMaxHP();
drawHpBar(graphics,
@@ -4037,10 +4041,10 @@ void Being::drawPortalSpriteAt(Graphics *restrict const graphics,
const int y) const restrict2
{
if (mHighlightMapPortals &&
- mMap &&
+ (mMap != nullptr) &&
!mMap->getHasWarps())
{
- if (!userPalette)
+ if (userPalette == nullptr)
{
CompoundSprite::drawSimple(graphics, x, y);
return;
@@ -4073,12 +4077,12 @@ void Being::drawHpBar(Graphics *restrict const graphics,
const int width,
const int height) const restrict2
{
- if (maxHP <= 0 || !userPalette)
+ if (maxHP <= 0 || (userPalette == nullptr))
return;
float p;
- if (hp)
+ if (hp != 0)
{
p = static_cast<float>(maxHP) / static_cast<float>(hp);
}
@@ -4100,8 +4104,8 @@ void Being::drawHpBar(Graphics *restrict const graphics,
#ifdef TMWA_SUPPORT
if (!serverFeatures->haveServerHp())
{ // old servers
- if ((!damage && (this != localPlayer || hp == maxHP))
- || (!hp && maxHP == damage))
+ if ((damage == 0 && (this != localPlayer || hp == maxHP))
+ || (hp == 0 && maxHP == damage))
{
graphics->setColor(userPalette->getColorWithAlpha(color1));
graphics->fillRectangle(Rect(
@@ -4218,7 +4222,7 @@ void Being::recalcSpritesOrder() restrict2
continue;
const int id = mSlots[slot].spriteId;
- if (!id)
+ if (id == 0)
continue;
const ItemInfo &info = ItemDB::get(id);
@@ -4228,7 +4232,7 @@ void Being::recalcSpritesOrder() restrict2
const SpriteToItemMap *restrict const spriteToItems
= info.getSpriteToItemReplaceMap(dir);
- if (spriteToItems)
+ if (spriteToItems != nullptr)
{
FOR_EACHP (SpriteToItemMapCIter, itr, spriteToItems)
{
@@ -4429,7 +4433,7 @@ void Being::recalcSpritesOrder() restrict2
{
const BeingSlot &beingSlot = mSlots[slot];
const int id = beingSlot.spriteId;
- if (!id)
+ if (id == 0)
continue;
updatedSprite[slot] = true;
@@ -4495,9 +4499,9 @@ void Being::updateHit(const int amount) restrict2
{
if (amount > 0)
{
- if (!mMinHit || amount < mMinHit)
+ if ((mMinHit == 0) || amount < mMinHit)
mMinHit = amount;
- if (amount != mCriticalHit && (!mMaxHit || amount > mMaxHit))
+ if (amount != mCriticalHit && ((mMaxHit == 0) || amount > mMaxHit))
mMaxHit = amount;
}
}
@@ -4649,14 +4653,14 @@ void Being::setEmote(const uint8_t emotion,
{
delete2(mEmotionSprite)
const EmoteInfo *const info = EmoteDB::get2(emotionIndex, true);
- if (info)
+ if (info != nullptr)
{
const EmoteSprite *restrict const sprite =
info->sprites.front();
- if (sprite)
+ if (sprite != nullptr)
{
mEmotionSprite = AnimatedSprite::clone(sprite->sprite);
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
mEmotionTime = info->time;
else
mEmotionTime = emote_time;
@@ -4669,7 +4673,7 @@ void Being::setEmote(const uint8_t emotion,
}
}
- if (mEmotionSprite)
+ if (mEmotionSprite != nullptr)
{
mEmotionSprite->play(mSpriteAction);
mEmotionSprite->setSpriteDirection(mSpriteDirection);
@@ -4683,10 +4687,10 @@ void Being::setEmote(const uint8_t emotion,
void Being::updatePercentHP() restrict2
{
- if (!mMaxHP)
+ if (mMaxHP == 0)
return;
BLOCK_START("Being::updatePercentHP")
- if (mHP)
+ if (mHP != 0)
{
const unsigned num = mHP * 100 / mMaxHP;
if (num != mNumber)
@@ -4735,9 +4739,9 @@ void Being::removeAfkEffect() restrict2
void Being::addSpecialEffect(const int effect) restrict2
{
- if (effectManager &&
+ if ((effectManager != nullptr) &&
ParticleEngine::enabled &&
- !mSpecialParticle &&
+ (mSpecialParticle == nullptr) &&
effect != -1)
{
mSpecialParticle = effectManager->triggerReturn(effect, this);
@@ -4746,7 +4750,7 @@ void Being::addSpecialEffect(const int effect) restrict2
void Being::removeSpecialEffect() restrict2
{
- if (effectManager && mSpecialParticle)
+ if ((effectManager != nullptr) && (mSpecialParticle != nullptr))
{
mChildParticleEffects.removeLocally(mSpecialParticle);
mSpecialParticle = nullptr;
@@ -4776,7 +4780,7 @@ void Being::playSfx(const SoundInfo &sound,
{
BLOCK_START("Being::playSfx")
- if (being)
+ if (being != nullptr)
{
// here need add timer and delay sound
const int time = tick_time;
@@ -4816,7 +4820,7 @@ void Being::setTileCoords(const int x, const int y) restrict2
{
mX = x;
mY = y;
- if (mMap)
+ if (mMap != nullptr)
{
mPixelOffsetY = 0;
mFixedOffsetY = mPixelOffsetY;
@@ -4830,7 +4834,7 @@ void Being::setMap(Map *restrict const map) restrict2
mCastEndTime = 0;
delete2(mCastingEffect);
ActorSprite::setMap(map);
- if (mMap)
+ if (mMap != nullptr)
{
mPixelOffsetY = mMap->getHeightOffset(mX, mY);
mFixedOffsetY = mPixelOffsetY;
@@ -4861,12 +4865,12 @@ void Being::addItemParticles(const int id,
pi = (*it).second;
}
- if (!pi || !pi->particles.empty())
+ if ((pi == nullptr) || !pi->particles.empty())
return;
// setup particle effects
if (ParticleEngine::enabled &&
- particleEngine)
+ (particleEngine != nullptr))
{
FOR_EACH (StringVectCIter, itr, display.particles)
{
@@ -4899,12 +4903,12 @@ void Being::addItemParticlesCards(const int id,
pi = (*it).second;
}
- if (!pi || !pi->particles.empty())
+ if ((pi == nullptr) || !pi->particles.empty())
return;
// setup particle effects
if (ParticleEngine::enabled &&
- particleEngine)
+ (particleEngine != nullptr))
{
FOR_EACH (StringVectCIter, itr, display.particles)
{
@@ -4956,7 +4960,7 @@ void Being::removeItemParticles(const int id) restrict2
if (it == mSpriteParticles.end())
return;
ParticleInfo *restrict const pi = (*it).second;
- if (pi)
+ if (pi != nullptr)
{
FOR_EACH (std::vector<Particle*>::const_iterator, itp, pi->particles)
mChildParticleEffects.removeLocally(*itp);
@@ -4970,7 +4974,7 @@ void Being::recreateItemParticles() restrict2
FOR_EACH (SpriteParticleInfoIter, it, mSpriteParticles)
{
ParticleInfo *restrict const pi = (*it).second;
- if (pi && !pi->files.empty())
+ if ((pi != nullptr) && !pi->files.empty())
{
FOR_EACH (std::vector<Particle*>::const_iterator,
itp, pi->particles)
@@ -5002,7 +5006,7 @@ void Being::setTeamId(const uint16_t teamId) restrict2
void Being::showTeamBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Team]);
- if (show && mTeamId && mShowBadges)
+ if (show && (mTeamId != 0u) && (mShowBadges != 0u))
{
const std::string name = paths.getStringValue("badges") +
paths.getStringValue(strprintf("team%dbadge",
@@ -5028,7 +5032,7 @@ void Being::showBadges(const bool show) restrict2
void Being::showPartyBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Party]);
- if (show && !mPartyName.empty() && mShowBadges)
+ if (show && !mPartyName.empty() && (mShowBadges != 0u))
{
const std::string badge = BadgesDB::getPartyBadge(mPartyName);
if (!badge.empty())
@@ -5053,7 +5057,7 @@ void Being::setPartyName(const std::string &restrict name) restrict2
void Being::showShopBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Shop]);
- if (show && mShop && mShowBadges)
+ if (show && mShop && (mShowBadges != 0u))
{
const std::string badge = paths.getStringValue("shopbadge");
if (!badge.empty())
@@ -5068,7 +5072,7 @@ void Being::showShopBadge(const bool show) restrict2
void Being::showInactiveBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Inactive]);
- if (show && mInactive && mShowBadges)
+ if (show && mInactive && (mShowBadges != 0u))
{
const std::string badge = paths.getStringValue("inactivebadge");
if (!badge.empty())
@@ -5083,7 +5087,7 @@ void Being::showInactiveBadge(const bool show) restrict2
void Being::showAwayBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Away]);
- if (show && mAway && mShowBadges)
+ if (show && mAway && (mShowBadges != 0u))
{
const std::string badge = paths.getStringValue("awaybadge");
if (!badge.empty())
@@ -5100,7 +5104,7 @@ void Being::updateBadgesCount() restrict2
mBadgesCount = 0;
for_each_badges()
{
- if (mBadges[f])
+ if (mBadges[f] != nullptr)
mBadgesCount ++;
}
}
@@ -5169,7 +5173,7 @@ void Being::addCast(const int dstX,
skillId,
skillLevel);
delete2(mCastingEffect);
- if (data)
+ if (data != nullptr)
{
const std::string castingAnimation = data->castingAnimation;
mCastingEffect = new CastingEffect(skillId,
@@ -5218,7 +5222,7 @@ void Being::setHorse(const int horseId) restrict2
if (mHorseId != 0)
{
mHorseInfo = HorseDB::get(horseId);
- if (mHorseInfo)
+ if (mHorseInfo != nullptr)
{
FOR_EACH (SpriteRefs, it, mHorseInfo->downSprites)
{
@@ -5281,7 +5285,7 @@ void Being::setSpiritBalls(const unsigned int balls) restrict2
void Being::addSpiritBalls(const unsigned int balls,
const int effectId) restrict2
{
- if (!effectManager)
+ if (effectManager == nullptr)
return;
for (unsigned int f = 0; f < balls; f ++)
{
@@ -5294,7 +5298,7 @@ void Being::addSpiritBalls(const unsigned int balls,
void Being::removeSpiritBalls(const unsigned int balls) restrict2
{
- if (!particleEngine)
+ if (particleEngine == nullptr)
return;
for (unsigned int f = 0; f < balls && !mSpiritParticles.empty(); f ++)
{
@@ -5314,22 +5318,22 @@ void Being::fixDirectionOffsets(int &offsetX,
int &offsetY) const
{
const uint8_t dir = mDirection;
- if (dir & BeingDirection::DOWN)
+ if ((dir & BeingDirection::DOWN) != 0)
{
// do nothing
}
- else if (dir & BeingDirection::UP)
+ else if ((dir & BeingDirection::UP) != 0)
{
offsetX = -offsetX;
offsetY = -offsetY;
}
- else if (dir & BeingDirection::LEFT)
+ else if ((dir & BeingDirection::LEFT) != 0)
{
const int tmp = offsetY;
offsetY = offsetX;
offsetX = -tmp;
}
- else if (dir & BeingDirection::RIGHT)
+ else if ((dir & BeingDirection::RIGHT) != 0)
{
const int tmp = offsetY;
offsetY = -offsetX;
diff --git a/src/being/being.h b/src/being/being.h
index 79f9a4d83..55ebd386e 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -312,7 +312,7 @@ class Being notfinal : public ActorSprite,
{ return CAST_S16(mGuilds.size()); }
bool isInParty() const restrict2 noexcept2 A_WARN_UNUSED
- { return mParty; }
+ { return mParty != nullptr; }
void setParty(Party *restrict const party) restrict2;
@@ -407,14 +407,14 @@ class Being notfinal : public ActorSprite,
int getTargetOffsetX() const restrict2 override A_WARN_UNUSED
{
- if (!mInfo)
+ if (mInfo == nullptr)
return 0;
return mInfo->getTargetOffsetX();
}
int getTargetOffsetY() const restrict2 override A_WARN_UNUSED
{
- if (!mInfo)
+ if (mInfo == nullptr)
return 0;
return mInfo->getTargetOffsetY();
}
@@ -424,7 +424,7 @@ class Being notfinal : public ActorSprite,
*/
virtual unsigned char getBlockWalkMask() const restrict2 A_WARN_UNUSED
{
- if (!mInfo)
+ if (mInfo == nullptr)
return 0;
return mInfo->getBlockWalkMask();
}
@@ -434,7 +434,7 @@ class Being notfinal : public ActorSprite,
*/
BlockTypeT getBlockType() const restrict2 override A_WARN_UNUSED
{
- if (!mInfo)
+ if (mInfo == nullptr)
return BlockType::NONE;
return mInfo->getBlockType();
}
@@ -879,7 +879,10 @@ class Being notfinal : public ActorSprite,
const int level) const restrict2 A_WARN_UNUSED;
CursorT getHoverCursor() const restrict2 A_WARN_UNUSED
- { return mInfo ? mInfo->getHoverCursor() : Cursor::CURSOR_POINTER; }
+ {
+ return mInfo != nullptr ?
+ mInfo->getHoverCursor() : Cursor::CURSOR_POINTER;
+ }
void addAfkEffect() restrict2;
diff --git a/src/being/castingeffect.cpp b/src/being/castingeffect.cpp
index 0d80f7ce2..cd7bec82a 100644
--- a/src/being/castingeffect.cpp
+++ b/src/being/castingeffect.cpp
@@ -46,15 +46,15 @@ CastingEffect::CastingEffect(const int skillId,
mRectX((x - range) * mapTileSize),
mRectY((y - range) * mapTileSize),
mRectSize(range * mapTileSize * 2 + mapTileSize),
- mAnimationX(mRectX + (mRectSize - (mSprite ?
+ mAnimationX(mRectX + (mRectSize - (mSprite != nullptr ?
mSprite->getWidth() : 0)) / 2),
- mAnimationY(mRectY + (mRectSize - (mSprite ?
+ mAnimationY(mRectY + (mRectSize - (mSprite != nullptr ?
mSprite->getHeight() : 0)) / 2)
{
mPixelX = x * mapTileSize;
mPixelY = y * mapTileSize;
mYDiff = range * mapTileSize + 31;
- if (!mSprite)
+ if (mSprite == nullptr)
{
reportAlways("Skill %d/%d casting animation '%s' load failed",
skillId,
@@ -79,7 +79,7 @@ void CastingEffect::draw(Graphics *const graphics,
mRectY + offsetY,
mRectSize,
mRectSize));
- if (mSprite)
+ if (mSprite != nullptr)
{
mSprite->draw(graphics,
mAnimationX + offsetX,
@@ -89,13 +89,13 @@ void CastingEffect::draw(Graphics *const graphics,
void CastingEffect::update(const int time)
{
- if (mSprite)
+ if (mSprite != nullptr)
mSprite->update(time);
}
bool CastingEffect::isTerminated() const
{
- if (mSprite)
+ if (mSprite != nullptr)
return mSprite->isTerminated();
return false;
}
diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp
index ae62ead8f..7c313e51e 100644
--- a/src/being/compoundsprite.cpp
+++ b/src/being/compoundsprite.cpp
@@ -97,7 +97,7 @@ bool CompoundSprite::reset()
bool ret = false;
FOR_EACH (SpriteIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
ret |= (*it)->reset();
}
if (ret)
@@ -112,7 +112,7 @@ bool CompoundSprite::play(const std::string &action)
bool ret2 = true;
FOR_EACH (SpriteIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
{
const bool tmpVal = (*it)->play(action);
ret |= tmpVal;
@@ -133,7 +133,7 @@ bool CompoundSprite::update(const int time)
mLastTime = time;
FOR_EACH (SpriteIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
ret |= (*it)->update(time);
}
mNeedsRedraw |= ret;
@@ -151,11 +151,11 @@ void CompoundSprite::drawSimple(Graphics *const graphics,
if (mSprites.empty()) // Nothing to draw
return;
- if (mAlpha == 1.0F && mImage)
+ if (mAlpha == 1.0F && (mImage != nullptr))
{
graphics->drawImage(mImage, posX + mOffsetX, posY + mOffsetY);
}
- else if (mAlpha && mAlphaImage)
+ else if ((mAlpha != 0.0f) && (mAlphaImage != nullptr))
{
mAlphaImage->setAlpha(mAlpha);
graphics->drawImage(mAlphaImage,
@@ -173,7 +173,7 @@ void CompoundSprite::drawSprites(Graphics *const graphics,
{
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
{
(*it)->setAlpha(mAlpha);
(*it)->draw(graphics, posX, posY);
@@ -187,7 +187,7 @@ void CompoundSprite::drawSpritesSDL(Graphics *const graphics,
{
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
(*it)->draw(graphics, posX, posY);
}
}
@@ -197,7 +197,7 @@ int CompoundSprite::getWidth() const
FOR_EACH (SpriteConstIterator, it, mSprites)
{
const Sprite *const base = *it;
- if (base)
+ if (base != nullptr)
return base->getWidth();
}
@@ -209,7 +209,7 @@ int CompoundSprite::getHeight() const
FOR_EACH (SpriteConstIterator, it, mSprites)
{
const Sprite *const base = *it;
- if (base)
+ if (base != nullptr)
return base->getHeight();
}
@@ -226,7 +226,7 @@ bool CompoundSprite::setSpriteDirection(const SpriteDirection::Type direction)
bool ret = false;
FOR_EACH (SpriteIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
ret |= (*it)->setSpriteDirection(direction);
}
if (ret)
@@ -237,7 +237,7 @@ bool CompoundSprite::setSpriteDirection(const SpriteDirection::Type direction)
int CompoundSprite::getNumberOfLayers() const
{
- if (mImage || mAlphaImage)
+ if ((mImage != nullptr) || (mAlphaImage != nullptr))
return 1;
else
return CAST_S32(mSprites.size());
@@ -247,7 +247,7 @@ unsigned int CompoundSprite::getCurrentFrame() const
{
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
return (*it)->getCurrentFrame();
}
return 0;
@@ -257,7 +257,7 @@ unsigned int CompoundSprite::getFrameCount() const
{
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
return (*it)->getFrameCount();
}
return 0;
@@ -283,7 +283,7 @@ void CompoundSprite::setSprite(const size_t layer, Sprite *const sprite)
void CompoundSprite::removeSprite(const int layer)
{
// Skip if it won't change anything
- if (!mSprites[layer])
+ if (mSprites[layer] == nullptr)
return;
delete2(mSprites[layer]);
@@ -334,7 +334,7 @@ void CompoundSprite::redraw() const
SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_HWSURFACE,
BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask);
- if (!surface)
+ if (surface == nullptr)
return;
SurfaceGraphics *graphics = new SurfaceGraphics;
@@ -346,10 +346,10 @@ void CompoundSprite::redraw() const
int tileY = mapTileSize;
const Game *const game = Game::instance();
- if (game)
+ if (game != nullptr)
{
const Map *const map = game->getCurrentMap();
- if (map)
+ if (map != nullptr)
{
tileX = map->getTileWidth() / 2;
tileY = map->getTileWidth();
@@ -401,7 +401,7 @@ void CompoundSprite::setAlpha(float alpha)
{
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
(*it)->setAlpha(alpha);
}
}
@@ -437,7 +437,7 @@ void CompoundSprite::updateImages() const
redraw();
- if (mImage)
+ if (mImage != nullptr)
initCurrentCacheItem();
}
else
@@ -454,7 +454,7 @@ bool CompoundSprite::updateFromCache() const
// static int hits = 0;
// static int miss = 0;
- if (mCacheItem && mCacheItem->image)
+ if ((mCacheItem != nullptr) && (mCacheItem->image != nullptr))
{
imagesCache.push_front(mCacheItem);
mCacheItem = nullptr;
@@ -476,7 +476,7 @@ bool CompoundSprite::updateFromCache() const
FOR_EACH (ImagesCache::iterator, it, imagesCache)
{
CompoundItem *const ic = *it;
- if (ic && ic->data.size() == sz)
+ if ((ic != nullptr) && ic->data.size() == sz)
{
bool fail(false);
VectorPointers::const_iterator it2 = ic->data.begin();
@@ -489,9 +489,9 @@ bool CompoundSprite::updateFromCache() const
{
const void *ptr1 = nullptr;
const void *ptr2 = nullptr;
- if (*it1)
+ if (*it1 != nullptr)
ptr1 = (*it1)->getHash();
- if (*it2)
+ if (*it2 != nullptr)
ptr2 = *it2;
if (ptr1 != ptr2)
{
@@ -527,7 +527,7 @@ void CompoundSprite::initCurrentCacheItem() const
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
mCacheItem->data.push_back((*it)->getHash());
else
mCacheItem->data.push_back(nullptr);
@@ -539,7 +539,7 @@ bool CompoundSprite::updateNumber(const unsigned num)
bool res(false);
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if (*it)
+ if (*it != nullptr)
{
if ((*it)->updateNumber(num))
res = true;
diff --git a/src/being/crazymoves.cpp b/src/being/crazymoves.cpp
index d40690d18..463dfd1eb 100644
--- a/src/being/crazymoves.cpp
+++ b/src/being/crazymoves.cpp
@@ -95,8 +95,8 @@ void CrazyMoves::crazyMove()
void CrazyMoves::crazyMove1()
{
- if (!localPlayer ||
- !playerHandler ||
+ if ((localPlayer == nullptr) ||
+ (playerHandler == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -134,8 +134,8 @@ void CrazyMoves::crazyMove1()
void CrazyMoves::crazyMove2()
{
- if (!localPlayer ||
- !playerHandler ||
+ if ((localPlayer == nullptr) ||
+ (playerHandler == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -185,8 +185,8 @@ void CrazyMoves::crazyMove2()
void CrazyMoves::crazyMove3()
{
- if (!localPlayer ||
- !playerHandler ||
+ if ((localPlayer == nullptr) ||
+ (playerHandler == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -223,7 +223,7 @@ void CrazyMoves::crazyMove3()
void CrazyMoves::crazyMove4()
{
- if (!localPlayer ||
+ if ((localPlayer == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -246,7 +246,7 @@ void CrazyMoves::crazyMove4()
void CrazyMoves::crazyMove5()
{
- if (!localPlayer ||
+ if ((localPlayer == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -269,7 +269,7 @@ void CrazyMoves::crazyMove5()
void CrazyMoves::crazyMove6()
{
- if (!localPlayer ||
+ if ((localPlayer == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -316,7 +316,7 @@ void CrazyMoves::crazyMove6()
void CrazyMoves::crazyMove7()
{
- if (!localPlayer ||
+ if ((localPlayer == nullptr) ||
localPlayer->getCurrentAction() == BeingAction::MOVE)
{
return;
@@ -347,10 +347,13 @@ void CrazyMoves::crazyMove7()
void CrazyMoves::crazyMove8()
{
- if (!localPlayer || localPlayer->getCurrentAction() == BeingAction::MOVE)
+ if (localPlayer == nullptr ||
+ localPlayer->getCurrentAction() == BeingAction::MOVE)
+ {
return;
+ }
const Map *const map = localPlayer->getMap();
- if (!map)
+ if (map == nullptr)
return;
const int x = localPlayer->getTileX();
const int y = localPlayer->getTileY();
@@ -456,8 +459,11 @@ void CrazyMoves::crazyMove9()
int dx = 0;
int dy = 0;
- if (!localPlayer || localPlayer->getCurrentAction() == BeingAction::MOVE)
+ if (localPlayer == nullptr ||
+ localPlayer->getCurrentAction() == BeingAction::MOVE)
+ {
return;
+ }
switch (settings.crazyMoveState)
{
@@ -477,7 +483,7 @@ void CrazyMoves::crazyMove9()
settings.crazyMoveState = 2;
if (!localPlayer->allowAction())
return;
- if (playerHandler)
+ if (playerHandler != nullptr)
playerHandler->changeAction(BeingAction::SIT);
break;
case 2:
@@ -493,7 +499,7 @@ void CrazyMoves::crazyMove9()
void CrazyMoves::crazyMoveAm() const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
settings.crazyMoveState ++;
@@ -538,13 +544,13 @@ void CrazyMoves::crazyMoveAm() const
case 'f':
{
const uint8_t dir = localPlayer->getDirection();
- if (dir & BeingDirection::UP)
+ if ((dir & BeingDirection::UP) != 0)
dy = -1;
- else if (dir & BeingDirection::DOWN)
+ else if ((dir & BeingDirection::DOWN) != 0)
dy = 1;
- if (dir & BeingDirection::LEFT)
+ if ((dir & BeingDirection::LEFT) != 0)
dx = -1;
- else if (dir & BeingDirection::RIGHT)
+ else if ((dir & BeingDirection::RIGHT) != 0)
dx = 1;
localPlayer->move(dx, dy);
break;
@@ -552,13 +558,13 @@ void CrazyMoves::crazyMoveAm() const
case 'b':
{
const uint8_t dir = localPlayer->getDirection();
- if (dir & BeingDirection::UP)
+ if ((dir & BeingDirection::UP) != 0)
dy = 1;
- else if (dir & BeingDirection::DOWN)
+ else if ((dir & BeingDirection::DOWN) != 0)
dy = -1;
- if (dir & BeingDirection::LEFT)
+ if ((dir & BeingDirection::LEFT) != 0)
dx = 1;
- else if (dir & BeingDirection::RIGHT)
+ else if ((dir & BeingDirection::RIGHT) != 0)
dx = -1;
localPlayer->move(dx, dy);
break;
diff --git a/src/being/flooritem.cpp b/src/being/flooritem.cpp
index bc60c5e2a..3ee4a9d51 100644
--- a/src/being/flooritem.cpp
+++ b/src/being/flooritem.cpp
@@ -79,7 +79,7 @@ void FloorItem::postInit(Map *const map, int subX, int subY)
{
setMap(map);
const ItemInfo &info = ItemDB::get(mItemId);
- if (map)
+ if (map != nullptr)
{
const int maxX = info.getMaxFloorOffsetX();
const int maxY = info.getMaxFloorOffsetY();
@@ -127,7 +127,7 @@ void FloorItem::postInit(Map *const map, int subX, int subY)
void FloorItem::setCards(const int *const cards,
int sz)
{
- if (sz < 0 || !cards)
+ if (sz < 0 || cards == nullptr)
return;
if (sz > maxCards)
sz = maxCards;
@@ -158,7 +158,7 @@ std::string FloorItem::getName() const
void FloorItem::draw(Graphics *const graphics,
const int offsetX, const int offsetY) const
{
- if (!mMap)
+ if (mMap == nullptr)
return;
BLOCK_START("FloorItem::draw")
@@ -204,7 +204,7 @@ void FloorItem::draw(Graphics *const graphics,
if (mHighlight)
{
- if (font && mAmount > 1)
+ if (font != nullptr && mAmount > 1)
{
const Color &color = userPalette->getColor(
UserColorId::FLOOR_ITEM_TEXT);
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 969873ef2..c675ad32e 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -193,7 +193,7 @@ LocalPlayer::LocalPlayer(const BeingId id,
mLevel = 1;
mAdvanced = true;
mTextColor = &theme->getColor(ThemeColorId::PLAYER, 255);
- if (userPalette)
+ if (userPalette != nullptr)
mNameColor = &userPalette->getColor(UserColorId::SELF);
else
mNameColor = nullptr;
@@ -235,7 +235,7 @@ LocalPlayer::~LocalPlayer()
updateNavigateList();
- if (mAwayDialog)
+ if (mAwayDialog != nullptr)
{
soundManager.volumeRestore();
delete2(mAwayDialog)
@@ -272,10 +272,10 @@ void LocalPlayer::logic()
if (!mSyncPlayerMove)
dist = 20;
- if ((mNavigateX || mNavigateY) &&
+ if (((mNavigateX != 0) || (mNavigateY != 0)) &&
((mCrossX + dist >= mX && mCrossX <= mX + dist
&& mCrossY + dist >= mY && mCrossY <= mY + dist)
- || (!mCrossX && !mCrossY)))
+ || ((mCrossX == 0) && (mCrossY == 0))))
{
const Path::const_iterator i = mNavigatePath.begin();
if ((*i).x == mX && (*i).y == mY)
@@ -292,7 +292,7 @@ void LocalPlayer::logic()
{
const MessagePair info = mMessages.front();
- if (particleEngine && gui)
+ if ((particleEngine != nullptr) && (gui != nullptr))
{
particleEngine->addTextRiseFadeOutEffect(
info.first,
@@ -309,7 +309,7 @@ void LocalPlayer::logic()
mMessageTime--;
}
- if (mTarget)
+ if (mTarget != nullptr)
{
if (mTarget->getType() == ActorType::Npc)
{
@@ -335,7 +335,7 @@ void LocalPlayer::logic()
stopAttack(true);
}
- if (mKeepAttacking && mTarget)
+ if (mKeepAttacking && (mTarget != nullptr))
attack(mTarget, true);
}
}
@@ -348,22 +348,26 @@ void LocalPlayer::slowLogic()
{
BLOCK_START("LocalPlayer::slowLogic")
const time_t time = cur_time;
- if (weightNotice && weightNoticeTime < time)
+ if ((weightNotice != nullptr) && weightNoticeTime < time)
{
weightNotice->scheduleDelete();
weightNotice = nullptr;
weightNoticeTime = 0;
}
- if (serverFeatures &&
+ if ((serverFeatures != nullptr) &&
!serverFeatures->havePlayerStatusUpdate() &&
mEnableAdvert &&
!mBlockAdvert &&
mAdvertTime < cur_time)
{
uint8_t smile = BeingFlag::SPECIAL;
- if (mTradebot && shopWindow && !shopWindow->isShopEmpty())
+ if (mTradebot &&
+ shopWindow != nullptr &&
+ !shopWindow->isShopEmpty())
+ {
smile |= BeingFlag::SHOP;
+ }
if (settings.awayMode || settings.pseudoAwayMode)
smile |= BeingFlag::AWAY;
@@ -422,9 +426,9 @@ void LocalPlayer::setGMLevel(const int level)
if (level > 0)
{
setGM(true);
- if (statusWindow)
+ if (statusWindow != nullptr)
statusWindow->updateLevelLabel();
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->loadGMCommands();
chatWindow->showGMTab();
@@ -435,10 +439,10 @@ void LocalPlayer::setGMLevel(const int level)
void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
{
const Party *const party = Party::getParty(1);
- if (party)
+ if (party != nullptr)
{
PartyMember *const pm = party->getMember(mName);
- if (pm)
+ if (pm != nullptr)
{
pm->setX(mX);
pm->setY(mY);
@@ -447,19 +451,19 @@ void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
if (mPath.empty())
{
- if (mPickUpTarget)
+ if (mPickUpTarget != nullptr)
pickUp(mPickUpTarget);
- if (mWalkingDir)
+ if (mWalkingDir != 0u)
startWalking(mWalkingDir);
}
else if (mPath.size() == 1)
{
- if (mPickUpTarget)
+ if (mPickUpTarget != nullptr)
pickUp(mPickUpTarget);
}
- if (mGoingToTarget && mTarget && withinAttackRange(mTarget))
+ if (mGoingToTarget && (mTarget != nullptr) && withinAttackRange(mTarget))
{
mAction = BeingAction::STAND;
attack(mTarget, true);
@@ -467,7 +471,7 @@ void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
mPath.clear();
return;
}
- else if (mGoingToTarget && !mTarget)
+ else if (mGoingToTarget && (mTarget == nullptr))
{
mGoingToTarget = false;
mPath.clear();
@@ -488,7 +492,7 @@ void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
bool LocalPlayer::pickUp(FloorItem *const item)
{
- if (!item)
+ if (item == nullptr)
return false;
if (!PacketLimiter::limitPackets(PacketType::PACKET_PICKUP))
@@ -504,7 +508,7 @@ bool LocalPlayer::pickUp(FloorItem *const item)
if (dx * dx + dy * dy < dist)
{
- if (actorManager && actorManager->checkForPickup(item))
+ if ((actorManager != nullptr) && actorManager->checkForPickup(item))
{
PlayerInfo::pickUpItem(item, Sfx_true);
mPickUpTarget = nullptr;
@@ -543,20 +547,20 @@ Being *LocalPlayer::getTarget() const
void LocalPlayer::setTarget(Being *const target)
{
- if (target == this && target)
+ if (target == this && (target != nullptr))
return;
if (target == mTarget)
return;
Being *oldTarget = nullptr;
- if (mTarget)
+ if (mTarget != nullptr)
{
mTarget->untarget();
oldTarget = mTarget;
}
- if (mTarget)
+ if (mTarget != nullptr)
{
if (mTarget->getType() == ActorType::Monster)
mTarget->setShowName(false);
@@ -564,10 +568,10 @@ void LocalPlayer::setTarget(Being *const target)
mTarget = target;
- if (oldTarget)
+ if (oldTarget != nullptr)
oldTarget->updateName();
- if (target)
+ if (target != nullptr)
{
mLastTargetX = target->mX;
mLastTargetY = target->mY;
@@ -575,21 +579,21 @@ void LocalPlayer::setTarget(Being *const target)
if (mVisibleNames == VisibleName::ShowOnSelection)
target->setShowName(true);
}
- if (oldTarget && mVisibleNames == VisibleName::ShowOnSelection)
+ if (oldTarget != nullptr && mVisibleNames == VisibleName::ShowOnSelection)
oldTarget->setShowName(false);
- if (target && target->getType() == ActorType::Monster)
+ if (target != nullptr && target->getType() == ActorType::Monster)
target->setShowName(true);
}
Being *LocalPlayer::setNewTarget(const ActorTypeT type,
const AllowSort allowSort)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const target = actorManager->findNearestLivingBeing(
localPlayer, 20, type, allowSort);
- if (target && target != mTarget)
+ if ((target != nullptr) && target != mTarget)
setTarget(target);
return target;
@@ -615,13 +619,13 @@ void LocalPlayer::setDestination(const int x, const int y)
else
{
uint8_t newDir = 0;
- if (mDirection & BeingDirection::UP)
+ if ((mDirection & BeingDirection::UP) != 0)
newDir |= BeingDirection::DOWN;
- if (mDirection & BeingDirection::LEFT)
+ if ((mDirection & BeingDirection::LEFT) != 0)
newDir |= BeingDirection::RIGHT;
- if (mDirection & BeingDirection::DOWN)
+ if ((mDirection & BeingDirection::DOWN) != 0)
newDir |= BeingDirection::UP;
- if (mDirection & BeingDirection::RIGHT)
+ if ((mDirection & BeingDirection::RIGHT) != 0)
newDir |= BeingDirection::LEFT;
playerHandler->setDestination(x, y, newDir);
@@ -644,7 +648,7 @@ void LocalPlayer::setWalkingDir(const unsigned char dir)
mWalkingDir = dir;
// If we're not already walking, start walking.
- if (mAction != BeingAction::MOVE && dir)
+ if (mAction != BeingAction::MOVE && (dir != 0u))
startWalking(dir);
}
@@ -652,7 +656,7 @@ void LocalPlayer::startWalking(const unsigned char dir)
{
// This function is called by setWalkingDir(),
// but also by nextTile() for TMW-Athena...
- if (!mMap || !dir)
+ if ((mMap == nullptr) || (dir == 0u))
return;
mPickUpTarget = nullptr;
@@ -664,28 +668,28 @@ void LocalPlayer::startWalking(const unsigned char dir)
}
int dx = 0, dy = 0;
- if (dir & BeingDirection::UP)
+ if ((dir & BeingDirection::UP) != 0)
dy--;
- if (dir & BeingDirection::DOWN)
+ if ((dir & BeingDirection::DOWN) != 0)
dy++;
- if (dir & BeingDirection::LEFT)
+ if ((dir & BeingDirection::LEFT) != 0)
dx--;
- if (dir & BeingDirection::RIGHT)
+ if ((dir & BeingDirection::RIGHT) != 0)
dx++;
const unsigned char blockWalkMask = getBlockWalkMask();
// Prevent skipping corners over colliding tiles
- if (dx && !mMap->getWalk(mX + dx, mY, blockWalkMask))
+ if ((dx != 0) && !mMap->getWalk(mX + dx, mY, blockWalkMask))
dx = 0;
- if (dy && !mMap->getWalk(mX, mY + dy, blockWalkMask))
+ if ((dy != 0) && !mMap->getWalk(mX, mY + dy, blockWalkMask))
dy = 0;
// Choose a straight direction when diagonal target is blocked
- if (dx && dy && !mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
+ if (dx != 0 && dy != 0 && !mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
dx = 0;
// Walk to where the player can actually go
- if ((dx || dy) && mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
+ if ((dx != 0 || dy != 0) && mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
{
setDestination(mX + dx, mY + dy);
}
@@ -703,7 +707,7 @@ void LocalPlayer::startWalking(const unsigned char dir)
void LocalPlayer::stopWalking(const bool sendToServer)
{
- if (mAction == BeingAction::MOVE && mWalkingDir)
+ if (mAction == BeingAction::MOVE && (mWalkingDir != 0u))
{
mWalkingDir = 0;
mPickUpTarget = nullptr;
@@ -778,7 +782,7 @@ void LocalPlayer::attack(Being *const target, const bool keep,
{
mKeepAttacking = keep;
- if (!target || target->getType() == ActorType::Npc)
+ if ((target == nullptr) || target->getType() == ActorType::Npc)
return;
if (mTarget != target)
@@ -855,7 +859,7 @@ void LocalPlayer::untarget()
if (mAction == BeingAction::ATTACK)
setAction(BeingAction::STAND);
- if (mTarget)
+ if (mTarget != nullptr)
setTarget(nullptr);
}
@@ -867,10 +871,10 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo,
{
if (fail != Pickup::OKAY)
{
- if (actorManager && floorItemId != BeingId_zero)
+ if ((actorManager != nullptr) && floorItemId != BeingId_zero)
{
FloorItem *const item = actorManager->findItem(floorItemId);
- if (item)
+ if (item != nullptr)
{
if (!item->getShowMsg())
return;
@@ -920,10 +924,10 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo,
msg = N_("Unknown problem picking up item.");
break;
}
- if (localChatTab && config.getBoolValue("showpickupchat"))
+ if ((localChatTab != nullptr) && config.getBoolValue("showpickupchat"))
localChatTab->chatLog(gettext(msg), ChatMsgType::BY_SERVER);
- if (mMap && config.getBoolValue("showpickupparticle"))
+ if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
{
// Show pickup notification
addMessageToQueue(gettext(msg), UserColorId::PICKUP_INFO);
@@ -943,7 +947,7 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo,
str = itemInfo.getName(color);
}
- if (config.getBoolValue("showpickupchat") && localChatTab)
+ if (config.getBoolValue("showpickupchat") && (localChatTab != nullptr))
{
// TRANSLATORS: %d is number,
// [@@%d|%s@@] - here player can see link to item
@@ -953,7 +957,7 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo,
ChatMsgType::BY_SERVER);
}
- if (mMap && config.getBoolValue("showpickupparticle"))
+ if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
{
// Show pickup notification
if (amount > 1)
@@ -979,7 +983,7 @@ int LocalPlayer::getAttackRange() const
{
const Item *const weapon = PlayerInfo::getEquipment(
EquipSlot::FIGHT1_SLOT);
- if (weapon)
+ if (weapon != nullptr)
{
const ItemInfo &info = weapon->getInfo();
return info.getAttackRange();
@@ -992,7 +996,7 @@ bool LocalPlayer::withinAttackRange(const Being *const target,
const bool fixDistance,
const int addRange) const
{
- if (!target)
+ if (target == nullptr)
return false;
int range = getAttackRange() + addRange;
@@ -1009,7 +1013,7 @@ bool LocalPlayer::withinAttackRange(const Being *const target,
void LocalPlayer::setGotoTarget(Being *const target)
{
- if (!target)
+ if (target == nullptr)
return;
mPickUpTarget = nullptr;
@@ -1029,14 +1033,14 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect,
newStatus,
start);
- if (effect)
+ if (effect != nullptr)
{
effect->deliverMessage();
effect->playSFX();
AnimatedSprite *const sprite = effect->getIcon();
- if (!sprite)
+ if (sprite == nullptr)
{
// delete sprite, if necessary
for (size_t i = 0; i < mStatusEffectIcons.size(); )
@@ -1044,7 +1048,7 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect,
if (mStatusEffectIcons[i] == effectId)
{
mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i);
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->eraseIcon(CAST_S32(i));
}
else
@@ -1062,7 +1066,7 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect,
{
if (mStatusEffectIcons[i] == effectId)
{
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->setIcon(CAST_S32(i), sprite);
found = true;
break;
@@ -1072,7 +1076,7 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect,
if (!found)
{ // add new
const int offset = CAST_S32(mStatusEffectIcons.size());
- if (miniStatusWindow)
+ if (miniStatusWindow != nullptr)
miniStatusWindow->setIcon(offset, sprite);
mStatusEffectIcons.push_back(effectId);
}
@@ -1235,7 +1239,7 @@ void LocalPlayer::statChanged(const AttributesT id,
}
const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
- if (oldVal1 > exp.first || !oldVal2)
+ if (oldVal1 > exp.first || (oldVal2 == 0))
return;
const int change = exp.first - oldVal1;
@@ -1314,9 +1318,9 @@ void LocalPlayer::moveToTarget(int dist)
}
}
- if (mTarget)
+ if (mTarget != nullptr)
{
- if (mMap)
+ if (mMap != nullptr)
{
debugPath = mMap->findPath(
(mPixelX - mapTileSize / 2) / mapTileSize,
@@ -1333,7 +1337,7 @@ void LocalPlayer::moveToTarget(int dist)
limit = CAST_S32(sz) - dist;
gotPos = true;
}
- else if (mNavigateX || mNavigateY)
+ else if ((mNavigateX != 0) || (mNavigateY != 0))
{
debugPath = mNavigatePath;
limit = dist;
@@ -1344,7 +1348,7 @@ void LocalPlayer::moveToTarget(int dist)
{
if (dist == 0)
{
- if (mTarget)
+ if (mTarget != nullptr)
navigateTo(mTarget->mX, mTarget->mY);
}
else
@@ -1361,7 +1365,7 @@ void LocalPlayer::moveToTarget(int dist)
navigateTo(pos.x, pos.y);
}
}
- else if (mLastTargetX || mLastTargetY)
+ else if ((mLastTargetX != 0) || (mLastTargetY != 0))
{
navigateTo(mLastTargetX, mLastTargetY);
}
@@ -1370,11 +1374,11 @@ void LocalPlayer::moveToTarget(int dist)
void LocalPlayer::moveToHome()
{
mPickUpTarget = nullptr;
- if ((mX != mCrossX || mY != mCrossY) && mCrossX && mCrossY)
+ if ((mX != mCrossX || mY != mCrossY) && (mCrossX != 0) && (mCrossY != 0))
{
setDestination(mCrossX, mCrossY);
}
- else if (mMap)
+ else if (mMap != nullptr)
{
const std::map<std::string, Vector>::const_iterator iter =
mHomes.find(mMap->getProperty("_realfilename"));
@@ -1400,8 +1404,8 @@ void LocalPlayer::moveToHome()
void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
{
if (settings.attackWeaponType == 1
- || !target
- || !PlayerInfo::getInventory())
+ || (target == nullptr)
+ || (PlayerInfo::getInventory() == nullptr))
{
return;
}
@@ -1418,7 +1422,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
allowSword = true;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
// if attack distance for sword
@@ -1429,12 +1433,12 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
FOR_EACH (WeaponsInfosIter, it, swords)
{
item = inv->findItem(*it, ItemColor_zero);
- if (item)
+ if (item != nullptr)
break;
}
// no swords
- if (!item)
+ if (item == nullptr)
return;
// if sword not equiped
@@ -1449,10 +1453,10 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
FOR_EACH (WeaponsInfosIter, it, shields)
{
item = inv->findItem(*it, ItemColor_zero);
- if (item)
+ if (item != nullptr)
break;
}
- if (item && item->isEquipped() == Equipped_false)
+ if ((item != nullptr) && item->isEquipped() == Equipped_false)
PlayerInfo::equipItem(item, Sfx_true);
}
}
@@ -1464,12 +1468,12 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
FOR_EACH (WeaponsInfosIter, it, bows)
{
item = inv->findItem(*it, ItemColor_zero);
- if (item)
+ if (item != nullptr)
break;
}
// no bow
- if (!item)
+ if (item == nullptr)
return;
if (item->isEquipped() == Equipped_false)
@@ -1480,7 +1484,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
bool LocalPlayer::isReachable(Being *const being,
const int maxCost)
{
- if (!being || !mMap)
+ if ((being == nullptr) || (mMap == nullptr))
return false;
if (being->getReachable() == Reachable::REACH_NO)
@@ -1528,7 +1532,7 @@ bool LocalPlayer::isReachable(const int x, const int y,
const bool allowCollision) const
{
const WalkLayer *const walk = mMap->getWalkLayer();
- if (!walk)
+ if (walk == nullptr)
return false;
int num = walk->getDataAt(x, y);
if (allowCollision && num < 0)
@@ -1539,7 +1543,7 @@ bool LocalPlayer::isReachable(const int x, const int y,
bool LocalPlayer::pickUpItems(int pickUpType)
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
bool status = false;
@@ -1549,7 +1553,7 @@ bool LocalPlayer::pickUpItems(int pickUpType)
// first pick up item on player position
FloorItem *item =
actorManager->findItem(x, y);
- if (item)
+ if (item != nullptr)
status = pickUp(item);
if (pickUpType == 0)
@@ -1571,7 +1575,7 @@ bool LocalPlayer::pickUpItems(int pickUpType)
default: break;
}
item = actorManager->findItem(x, y);
- if (item)
+ if (item != nullptr)
status = pickUp(item);
break;
case 2:
@@ -1642,23 +1646,23 @@ bool LocalPlayer::pickUpItems(int pickUpType)
void LocalPlayer::moveByDirection(const unsigned char dir)
{
int dx = 0, dy = 0;
- if (dir & BeingDirection::UP)
+ if ((dir & BeingDirection::UP) != 0)
dy--;
- if (dir & BeingDirection::DOWN)
+ if ((dir & BeingDirection::DOWN) != 0)
dy++;
- if (dir & BeingDirection::LEFT)
+ if ((dir & BeingDirection::LEFT) != 0)
dx--;
- if (dir & BeingDirection::RIGHT)
+ if ((dir & BeingDirection::RIGHT) != 0)
dx++;
move(dx, dy);
}
void LocalPlayer::specialMove(const unsigned char direction)
{
- if (direction && (mNavigateX || mNavigateY))
+ if ((direction != 0u) && ((mNavigateX != 0) || (mNavigateY != 0)))
navigateClean();
- if (direction && (settings.moveType >= 2
+ if ((direction != 0u) && (settings.moveType >= 2
&& settings.moveType <= 4))
{
if (mAction == BeingAction::MOVE)
@@ -1695,8 +1699,9 @@ void LocalPlayer::magicAttack() const
{
if (Net::getNetworkType() != ServerType::TMWATHENA)
return;
- if (!chatWindow || !isAlive()
- || !playerHandler->canUseMagic())
+ if (chatWindow == nullptr ||
+ !isAlive() ||
+ !playerHandler->canUseMagic())
{
return;
}
@@ -1731,7 +1736,7 @@ void LocalPlayer::magicAttack() const
void LocalPlayer::tryMagic(const std::string &spell, const int baseMagic,
const int schoolMagic, const int mana)
{
- if (!chatWindow)
+ if (chatWindow == nullptr)
return;
if (PlayerInfo::getSkillLevel(340) >= baseMagic
@@ -1765,9 +1770,9 @@ void LocalPlayer::loadHomes()
void LocalPlayer::setMap(Map *const map)
{
BLOCK_START("LocalPlayer::setMap")
- if (map)
+ if (map != nullptr)
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateActiveList();
}
navigateClean();
@@ -1781,12 +1786,12 @@ void LocalPlayer::setMap(Map *const map)
void LocalPlayer::setHome()
{
- if (!mMap || !socialWindow)
+ if ((mMap == nullptr) || (socialWindow == nullptr))
return;
SpecialLayer *const specialLayer = mMap->getSpecialLayer();
- if (!specialLayer)
+ if (specialLayer == nullptr)
return;
const std::string key = mMap->getProperty("_realfilename");
@@ -1830,7 +1835,7 @@ void LocalPlayer::setHome()
socialWindow->addPortal(mX, mY);
}
MapItem *const mapItem = specialLayer->getTile(mX, mY);
- if (mapItem)
+ if (mapItem != nullptr)
{
const int idx = socialWindow->getPortalIndex(mX, mY);
mapItem->setName(keyboard.getKeyShortString(
@@ -1850,15 +1855,15 @@ void LocalPlayer::setHome()
saveHomes();
}
- if (!mapItem || mapItem->getType() == MapItemType::EMPTY)
+ if ((mapItem == nullptr) || mapItem->getType() == MapItemType::EMPTY)
{
- if (mDirection & BeingDirection::UP)
+ if ((mDirection & BeingDirection::UP) != 0)
type = MapItemType::ARROW_UP;
- else if (mDirection & BeingDirection::LEFT)
+ else if ((mDirection & BeingDirection::LEFT) != 0)
type = MapItemType::ARROW_LEFT;
- else if (mDirection & BeingDirection::DOWN)
+ else if ((mDirection & BeingDirection::DOWN) != 0)
type = MapItemType::ARROW_DOWN;
- else if (mDirection & BeingDirection::RIGHT)
+ else if ((mDirection & BeingDirection::RIGHT) != 0)
type = MapItemType::ARROW_RIGHT;
}
else
@@ -1871,7 +1876,7 @@ void LocalPlayer::setHome()
{
socialWindow->addPortal(mX, mY);
mapItem = specialLayer->getTile(mX, mY);
- if (mapItem)
+ if (mapItem != nullptr)
{
const int idx = socialWindow->getPortalIndex(mX, mY);
mapItem->setName(keyboard.getKeyShortString(
@@ -1925,7 +1930,7 @@ std::string LocalPlayer::getPingTime() const
std::string str;
if (!mWaitPing)
{
- if (!mPingTime)
+ if (mPingTime == 0)
str = "?";
else
str = toString(CAST_S32(mPingTime));
@@ -2023,10 +2028,10 @@ void LocalPlayer::afkRespond(ChatTab *const tab, const std::string &nick)
if (config.getIntValue("afkFormat") == 1)
msg = "*" + msg + "*";
- if (!tab)
+ if (tab == nullptr)
{
chatHandler->privateMessage(nick, msg);
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(std::string(mName).append(
" : ").append(msg),
@@ -2048,11 +2053,11 @@ void LocalPlayer::afkRespond(ChatTab *const tab, const std::string &nick)
bool LocalPlayer::navigateTo(const int x, const int y)
{
- if (!mMap)
+ if (mMap == nullptr)
return false;
SpecialLayer *const tmpLayer = mMap->getTempLayer();
- if (!tmpLayer)
+ if (tmpLayer == nullptr)
return false;
mShowNavigePath = true;
@@ -2079,7 +2084,7 @@ bool LocalPlayer::navigateTo(const int x, const int y)
void LocalPlayer::navigateClean()
{
- if (!mMap)
+ if (mMap == nullptr)
return;
mShowNavigePath = false;
@@ -2094,7 +2099,7 @@ void LocalPlayer::navigateClean()
mNavigatePath.clear();
SpecialLayer *const tmpLayer = mMap->getTempLayer();
- if (!tmpLayer)
+ if (tmpLayer == nullptr)
return;
tmpLayer->clean();
@@ -2102,7 +2107,7 @@ void LocalPlayer::navigateClean()
void LocalPlayer::updateMusic() const
{
- if (mMap)
+ if (mMap != nullptr)
{
std::string str = mMap->getObjectData(mX, mY, MapItemType::MUSIC);
if (str.empty())
@@ -2122,29 +2127,29 @@ void LocalPlayer::updateCoords()
Being::updateCoords();
// probably map not loaded.
- if (!mPixelX || !mPixelY)
+ if ((mPixelX == 0) || (mPixelY == 0))
return;
if (mX != mOldTileX || mY != mOldTileY)
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updatePortals();
- if (popupManager)
+ if (popupManager != nullptr)
popupManager->hideBeingPopup();
updateMusic();
}
- if (mMap && (mX != mOldTileX || mY != mOldTileY))
+ if ((mMap != nullptr) && (mX != mOldTileX || mY != mOldTileY))
{
SpecialLayer *const tmpLayer = mMap->getTempLayer();
- if (!tmpLayer)
+ if (tmpLayer == nullptr)
return;
const int x = (mPixelX - mapTileSize / 2) / mapTileSize;
const int y = (mPixelY - mapTileSize) / mapTileSize;
if (mNavigateId != BeingId_zero)
{
- if (!actorManager)
+ if (actorManager == nullptr)
{
navigateClean();
return;
@@ -2152,7 +2157,7 @@ void LocalPlayer::updateCoords()
const Being *const being = actorManager
->findBeing(mNavigateId);
- if (!being)
+ if (being == nullptr)
{
navigateClean();
return;
@@ -2212,7 +2217,7 @@ void LocalPlayer::targetMoved() const
int LocalPlayer::getPathLength(const Being *const being) const
{
- if (!mMap || !being)
+ if ((mMap == nullptr) || (being == nullptr))
return 0;
if (being->mX == mX && being->mY == mY)
@@ -2258,20 +2263,22 @@ int LocalPlayer::getAttackRange2() const
void LocalPlayer::attack2(Being *const target, const bool keep,
const bool dontChangeEquipment)
{
- if (!dontChangeEquipment && target)
+ if (!dontChangeEquipment && (target != nullptr))
changeEquipmentBeforeAttack(target);
const bool broken = (Net::getNetworkType() == ServerType::TMWATHENA);
// probably need cache getPathLength(target)
- if ((!target || settings.attackType == 0 || settings.attackType == 3)
- || (withinAttackRange(target, broken, broken ? 1 : 0)
- && getPathLength(target) <= getAttackRange2()))
+ if ((target == nullptr ||
+ settings.attackType == 0 ||
+ settings.attackType == 3) ||
+ (withinAttackRange(target, broken, broken ? 1 : 0) &&
+ getPathLength(target) <= getAttackRange2()))
{
attack(target, keep);
if (settings.attackType == 2)
{
- if (!target)
+ if (target == nullptr)
{
if (pickUpItems())
return;
@@ -2282,7 +2289,7 @@ void LocalPlayer::attack2(Being *const target, const bool keep,
}
}
}
- else if (!mPickUpTarget)
+ else if (mPickUpTarget == nullptr)
{
if (settings.attackType == 2)
{
@@ -2349,7 +2356,7 @@ void LocalPlayer::cancelFollow()
void LocalPlayer::imitateEmote(const Being *const being,
const unsigned char action) const
{
- if (!being)
+ if (being == nullptr)
return;
std::string player_imitated = getImitate();
@@ -2360,7 +2367,7 @@ void LocalPlayer::imitateEmote(const Being *const being,
void LocalPlayer::imitateAction(const Being *const being,
const BeingActionT &action)
{
- if (!being)
+ if (being == nullptr)
return;
if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
@@ -2373,7 +2380,7 @@ void LocalPlayer::imitateAction(const Being *const being,
void LocalPlayer::imitateDirection(const Being *const being,
const unsigned char dir)
{
- if (!being)
+ if (being == nullptr)
return;
if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
@@ -2384,13 +2391,13 @@ void LocalPlayer::imitateDirection(const Being *const being,
if (settings.followMode == 2)
{
uint8_t dir2 = 0;
- if (dir & BeingDirection::LEFT)
+ if ((dir & BeingDirection::LEFT) != 0)
dir2 |= BeingDirection::RIGHT;
- else if (dir & BeingDirection::RIGHT)
+ else if ((dir & BeingDirection::RIGHT) != 0)
dir2 |= BeingDirection::LEFT;
- if (dir & BeingDirection::UP)
+ if ((dir & BeingDirection::UP) != 0)
dir2 |= BeingDirection::DOWN;
- else if (dir & BeingDirection::DOWN)
+ else if ((dir & BeingDirection::DOWN) != 0)
dir2 |= BeingDirection::UP;
setDirection(dir2);
@@ -2407,7 +2414,7 @@ void LocalPlayer::imitateDirection(const Being *const being,
void LocalPlayer::imitateOutfit(const Being *const player,
const int sprite) const
{
- if (!player)
+ if (player == nullptr)
return;
if (settings.imitationMode == 1 &&
@@ -2421,11 +2428,11 @@ void LocalPlayer::imitateOutfit(const Being *const player,
= dynamic_cast<const AnimatedSprite *>(
player->mSprites[sprite]);
- if (equipmentSprite)
+ if (equipmentSprite != nullptr)
{
// logger->log("have equipmentSprite");
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const std::string &path = equipmentSprite->getIdPath();
@@ -2435,7 +2442,7 @@ void LocalPlayer::imitateOutfit(const Being *const player,
// logger->log("idPath: " + path);
const Item *const item = inv->findItemBySprite(path,
player->getGender(), player->getSubType());
- if (item && item->isEquipped() == Equipped_false)
+ if ((item != nullptr) && item->isEquipped() == Equipped_false)
PlayerInfo::equipItem(item, Sfx_false);
}
else
@@ -2448,7 +2455,7 @@ void LocalPlayer::imitateOutfit(const Being *const player,
return;
const Item *const item = PlayerInfo::getEquipment(equipmentSlot);
- if (item)
+ if (item != nullptr)
{
// logger->log("unequiping");
PlayerInfo::unequipItem(item, Sfx_false);
@@ -2460,7 +2467,7 @@ void LocalPlayer::imitateOutfit(const Being *const player,
void LocalPlayer::followMoveTo(const Being *const being,
const int x, const int y)
{
- if (being &&
+ if ((being != nullptr) &&
!mPlayerFollowed.empty() &&
being->mName == mPlayerFollowed)
{
@@ -2473,7 +2480,7 @@ void LocalPlayer::followMoveTo(const Being *const being,
const int x1, const int y1,
const int x2, const int y2)
{
- if (!being)
+ if (being == nullptr)
return;
mPickUpTarget = nullptr;
@@ -2501,9 +2508,10 @@ void LocalPlayer::followMoveTo(const Being *const being,
}
break;
case 3:
- if (!mTarget || mTarget->mName != mPlayerFollowed)
+ if (mTarget == nullptr ||
+ mTarget->mName != mPlayerFollowed)
{
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const b = actorManager->findBeingByName(
mPlayerFollowed, ActorType::Player);
@@ -2538,7 +2546,7 @@ bool LocalPlayer::allowAction()
void LocalPlayer::fixPos()
{
- if (!mCrossX && !mCrossY)
+ if ((mCrossX == 0) && (mCrossY == 0))
return;
const int dx = abs(mX - mCrossX);
@@ -2558,15 +2566,15 @@ void LocalPlayer::fixPos()
void LocalPlayer::setRealPos(const int x, const int y)
{
- if (!mMap)
+ if (mMap == nullptr)
return;
SpecialLayer *const layer = mMap->getTempLayer();
- if (layer)
+ if (layer != nullptr)
{
bool cacheUpdated(false);
- if ((mCrossX || mCrossY) &&
- layer->getTile(mCrossX, mCrossY) &&
+ if (((mCrossX != 0) || (mCrossY != 0)) &&
+ (layer->getTile(mCrossX, mCrossY) != nullptr) &&
layer->getTile(mCrossX, mCrossY)->getType() == MapItemType::CROSS)
{
layer->setTile(mCrossX, mCrossY, MapItemType::EMPTY);
@@ -2578,7 +2586,7 @@ void LocalPlayer::setRealPos(const int x, const int y)
{
const MapItem *const mapItem = layer->getTile(x, y);
- if (!mapItem || mapItem->getType() == MapItemType::EMPTY)
+ if ((mapItem == nullptr) || mapItem->getType() == MapItemType::EMPTY)
{
if (mX != x && mY != y)
{
@@ -2600,10 +2608,10 @@ void LocalPlayer::setRealPos(const int x, const int y)
}
void LocalPlayer::fixAttackTarget()
{
- if (!mMap || !mTarget)
+ if ((mMap == nullptr) || (mTarget == nullptr))
return;
- if (settings.moveToTargetType == 11 || !settings.attackType
+ if (settings.moveToTargetType == 11 || (settings.attackType == 0u)
|| !config.getBoolValue("autofixPos"))
{
return;
@@ -2636,7 +2644,7 @@ int LocalPlayer::getLevel() const
void LocalPlayer::updateNavigateList()
{
- if (mMap)
+ if (mMap != nullptr)
{
const std::map<std::string, Vector>::const_iterator iter =
mHomes.find(mMap->getProperty("_realfilename"));
@@ -2644,7 +2652,7 @@ void LocalPlayer::updateNavigateList()
if (iter != mHomes.end())
{
const Vector &pos = mHomes[(*iter).first];
- if (pos.x && pos.y)
+ if ((pos.x != 0.0f) && (pos.y != 0.0f))
{
mMap->addPortalTile("home", MapItemType::HOME,
CAST_S32(pos.x), CAST_S32(pos.y));
@@ -2665,17 +2673,17 @@ void LocalPlayer::waitFor(const std::string &nick)
void LocalPlayer::checkNewName(Being *const being)
{
- if (!being)
+ if (being == nullptr)
return;
const std::string &nick = being->mName;
if (being->getType() == ActorType::Player)
{
const Guild *const guild = getGuild();
- if (guild)
+ if (guild != nullptr)
{
const GuildMember *const gm = guild->getMember(nick);
- if (gm)
+ if (gm != nullptr)
{
const int level = gm->getLevel();
if (level > 1 && being->getLevel() != level)
@@ -2685,10 +2693,10 @@ void LocalPlayer::checkNewName(Being *const being)
}
}
}
- if (chatWindow)
+ if (chatWindow != nullptr)
{
WhisperTab *const tab = chatWindow->getWhisperTab(nick);
- if (tab)
+ if (tab != nullptr)
tab->setWhisperTabColors();
}
}
@@ -2713,7 +2721,7 @@ unsigned char LocalPlayer::getBlockWalkMask() const
void LocalPlayer::removeHome()
{
- if (!mMap)
+ if (mMap == nullptr)
return;
const std::string key = mMap->getProperty("_realfilename");
@@ -2730,7 +2738,7 @@ void LocalPlayer::stopAdvert()
bool LocalPlayer::checAttackPermissions(const Being *const target)
{
- if (!target)
+ if (target == nullptr)
return false;
switch (settings.pvpAttackType)
@@ -2755,8 +2763,12 @@ void LocalPlayer::updateStatus() const
uint8_t status = 0;
if (Net::getNetworkType() == ServerType::TMWATHENA)
{
- if (mTradebot && shopWindow && !shopWindow->isShopEmpty())
+ if (mTradebot &&
+ shopWindow != nullptr &&
+ !shopWindow->isShopEmpty())
+ {
status |= BeingFlag::SHOP;
+ }
}
if (settings.awayMode || settings.pseudoAwayMode)
status |= BeingFlag::AWAY;
@@ -2773,7 +2785,7 @@ void LocalPlayer::setTestParticle(const std::string &fileName,
{
mTestParticleName = fileName;
mTestParticleTime = cur_time;
- if (mTestParticle)
+ if (mTestParticle != nullptr)
{
mChildParticleEffects.removeLocally(mTestParticle);
mTestParticle = nullptr;
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index b177b9b48..fa21f491a 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -396,10 +396,10 @@ class LocalPlayer final : public Being,
const bool updateHash = true);
int getLastAttackX() const override final
- { return mTarget ? mTarget->mX : mLastAttackX; }
+ { return mTarget != nullptr ? mTarget->mX : mLastAttackX; }
int getLastAttackY() const override final
- { return mTarget ? mTarget->mY : mLastAttackY; }
+ { return mTarget != nullptr ? mTarget->mY : mLastAttackY; }
void attributeChanged(const AttributesT id,
const int oldVal,
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index 8a9c55c5e..4429ba5f7 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -206,7 +206,7 @@ Inventory *getInventory()
Inventory *getStorageInventory()
{
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
return inventoryHandler->getStorage();
return nullptr;
}
@@ -218,9 +218,9 @@ Inventory *getCartInventory()
void clearInventory()
{
- if (mEquipment)
+ if (mEquipment != nullptr)
mEquipment->clear();
- if (mInventory)
+ if (mInventory != nullptr)
mInventory->clear();
}
@@ -231,7 +231,7 @@ Equipment *getEquipment()
const Item *getEquipment(const unsigned int slot)
{
- if (mEquipment)
+ if (mEquipment != nullptr)
return mEquipment->getEquipment(slot);
else
return nullptr;
@@ -239,7 +239,7 @@ const Item *getEquipment(const unsigned int slot)
void setEquipmentBackend(Equipment::Backend *const backend)
{
- if (mEquipment)
+ if (mEquipment != nullptr)
mEquipment->setBackend(backend);
}
@@ -247,7 +247,7 @@ void equipItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->equipItem(item);
}
@@ -255,7 +255,7 @@ void unequipItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->unequipItem(item);
}
@@ -263,19 +263,19 @@ void useItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->useItem(item);
}
void useEquipItem(const Item *const item, const Sfx sfx)
{
- if (item)
+ if (item != nullptr)
{
if (item->getType() == ItemType::Card)
{
if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
{
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->useCard(item);
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USECARD);
@@ -287,14 +287,14 @@ void useEquipItem(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->unequipItem(item);
}
else
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->equipItem(item);
}
}
@@ -302,7 +302,7 @@ void useEquipItem(const Item *const item, const Sfx sfx)
{
if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
{
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->useItem(item);
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
@@ -313,7 +313,7 @@ void useEquipItem(const Item *const item, const Sfx sfx)
void useEquipItem2(const Item *const item, const Sfx sfx)
{
- if (item)
+ if (item != nullptr)
{
if (item->isEquipment() == Equipm_false)
{
@@ -321,14 +321,14 @@ void useEquipItem2(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->unequipItem(item);
}
else
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->equipItem(item);
}
}
@@ -338,7 +338,7 @@ void useEquipItem2(const Item *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->useItem(item);
}
}
@@ -347,11 +347,12 @@ void useEquipItem2(const Item *const item, const Sfx sfx)
void dropItem(const Item *const item, const int amount, const Sfx sfx)
{
- if (item && mProtectedItems.find(item->getId()) == mProtectedItems.end())
+ if (item != nullptr &&
+ mProtectedItems.find(item->getId()) == mProtectedItems.end())
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::DROP);
- if (inventoryHandler)
+ if (inventoryHandler != nullptr)
inventoryHandler->dropItem(item, amount);
}
}
@@ -360,7 +361,7 @@ void pickUpItem(const FloorItem *const item, const Sfx sfx)
{
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::PICKUP);
- if (playerHandler)
+ if (playerHandler != nullptr)
playerHandler->pickUp(item);
}
@@ -393,7 +394,7 @@ void setTrading(const Trading trading)
#define updateAttackStat(atk, delay, speed) \
attackDelay = getStatBase(delay); \
- if (attackDelay) \
+ if (attackDelay != 0) \
{ \
setStatBase(speed, \
getStatBase(atk) * 1000 / attackDelay, \
@@ -464,7 +465,7 @@ void stateChange(const StateT state)
{
if (state == State::GAME)
{
- if (!mInventory)
+ if (mInventory == nullptr)
{
mInventory = new Inventory(InventoryType::Inventory);
mEquipment = new Equipment;
@@ -517,8 +518,11 @@ void setMercenary(MercenaryInfo *const info)
void setMercenaryBeing(Being *const being)
{
- if (!being || !mMercenary)
+ if (being == nullptr ||
+ mMercenary == nullptr)
+ {
return;
+ }
being->setName(mMercenary->name);
being->setOwner(localPlayer);
being->setLevel(mMercenary->level);
@@ -548,12 +552,15 @@ void setPet(PetInfo *const info)
void setPetBeing(Being *const being)
{
- if (being)
+ if (being != nullptr)
mPetBeingId = being->getId();
else
mPetBeingId = BeingId_zero;
- if (!being || !mPet)
+ if (being == nullptr ||
+ mPet == nullptr)
+ {
return;
+ }
being->setName(mPet->name);
being->setOwner(localPlayer);
being->setLevel(mPet->level);
@@ -577,8 +584,11 @@ void setHomunculus(HomunculusInfo *const info)
void setHomunculusBeing(Being *const being)
{
- if (!being || !mHomunculus)
+ if (being == nullptr ||
+ mHomunculus == nullptr)
+ {
return;
+ }
being->setName(mHomunculus->name);
being->setOwner(localPlayer);
}
@@ -590,21 +600,27 @@ HomunculusInfo *getHomunculus()
BeingId getHomunculusId()
{
- return mHomunculus ? mHomunculus->id : BeingId_zero;
+ return mHomunculus != nullptr ? mHomunculus->id : BeingId_zero;
}
BeingId getMercenaryId()
{
- return mMercenary ? mMercenary->id : BeingId_zero;
+ return mMercenary != nullptr ? mMercenary->id : BeingId_zero;
}
void updateAttackAi(const BeingId targetId,
const Keep keep)
{
- if (mMercenary && mercenaryHandler)
+ if (mMercenary != nullptr &&
+ mercenaryHandler != nullptr)
+ {
mercenaryHandler->attack(targetId, keep);
- if (mHomunculus && homunculusHandler)
+ }
+ if (mHomunculus != nullptr &&
+ homunculusHandler != nullptr)
+ {
homunculusHandler->attack(targetId, keep);
+ }
}
std::string getRoomName()
diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp
index 4a2d71ee2..2e4b4b68c 100644
--- a/src/being/playerrelations.cpp
+++ b/src/being/playerrelations.cpp
@@ -92,8 +92,11 @@ namespace
const std::pair<std::string, PlayerRelation *> &value,
ConfigurationObject *const cobj) const override final
{
- if (!cobj || !value.second)
+ if (cobj == nullptr ||
+ value.second == nullptr)
+ {
return nullptr;
+ }
cobj->setValue(NAME, value.first);
cobj->setValue(RELATION, toString(
CAST_S32(value.second->mRelation)));
@@ -106,13 +109,16 @@ namespace
std::map<std::string, PlayerRelation *>
*const container) const override final
{
- if (!cobj || !container)
+ if (cobj == nullptr ||
+ container == nullptr)
+ {
return container;
+ }
const std::string name = cobj->getValue(NAME, "");
if (name.empty())
return container;
- if (!(*container)[name])
+ if ((*container)[name] == nullptr)
{
const int v = cobj->getValueInt(RELATION,
CAST_S32(Relation::NEUTRAL));
@@ -178,7 +184,7 @@ int PlayerRelationsManager::getPlayerIgnoreStrategyIndex(
const std::vector<PlayerIgnoreStrategy *> *const strategies
= getPlayerIgnoreStrategies();
- if (!strategies)
+ if (strategies == nullptr)
return -1;
const size_t sz = strategies->size();
@@ -196,7 +202,7 @@ void PlayerRelationsManager::load()
Configuration *const cfg = &serverConfig;
clear();
- mPersistIgnores = cfg->getValue(PERSIST_IGNORE_LIST, 1);
+ mPersistIgnores = (cfg->getValue(PERSIST_IGNORE_LIST, 1) != 0);
mDefaultPermissions = CAST_S32(cfg->getValue(DEFAULT_PERMISSIONS,
mDefaultPermissions));
@@ -243,8 +249,8 @@ void PlayerRelationsManager::store() const
serverConfig.setValue(DEFAULT_PERMISSIONS, mDefaultPermissions);
serverConfig.setValue(PERSIST_IGNORE_LIST, mPersistIgnores);
serverConfig.setValue(PLAYER_IGNORE_STRATEGY,
- mIgnoreStrategy ? mIgnoreStrategy->mShortName
- : DEFAULT_IGNORE_STRATEGY);
+ mIgnoreStrategy != nullptr ? mIgnoreStrategy->mShortName :
+ DEFAULT_IGNORE_STRATEGY);
serverConfig.write();
}
@@ -254,13 +260,16 @@ void PlayerRelationsManager::signalUpdate(const std::string &name)
FOR_EACH (PlayerRelationListenersCIter, it, mListeners)
(*it)->updatedPlayer(name);
- if (actorManager)
+ if (actorManager != nullptr)
{
Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being && being->getType() == ActorType::Player)
+ if (being != nullptr &&
+ being->getType() == ActorType::Player)
+ {
being->updateColors();
+ }
}
}
@@ -305,18 +314,21 @@ unsigned int PlayerRelationsManager::checkPermissionSilently(
bool PlayerRelationsManager::hasPermission(const Being *const being,
const unsigned int flags) const
{
- if (!being)
+ if (being == nullptr)
return false;
if (being->getType() == ActorType::Player)
- return hasPermission(being->getName(), flags) == flags;
+ {
+ return static_cast<unsigned int>(hasPermission(
+ being->getName(), flags)) == flags;
+ }
return true;
}
bool PlayerRelationsManager::hasPermission(const std::string &name,
const unsigned int flags) const
{
- if (!actorManager)
+ if (actorManager == nullptr)
return false;
const unsigned int rejections = flags
@@ -326,12 +338,12 @@ bool PlayerRelationsManager::hasPermission(const std::string &name,
if (!permitted)
{
// execute `ignore' strategy, if possible
- if (mIgnoreStrategy)
+ if (mIgnoreStrategy != nullptr)
{
Being *const b = actorManager->findBeingByName(
name, ActorType::Player);
- if (b && b->getType() == ActorType::Player)
+ if ((b != nullptr) && b->getType() == ActorType::Player)
mIgnoreStrategy->ignore(b, rejections);
}
}
@@ -340,17 +352,17 @@ bool PlayerRelationsManager::hasPermission(const std::string &name,
}
void PlayerRelationsManager::setRelation(const std::string &player_name,
- const RelationT
- relation)
+ const RelationT relation)
{
- if (!localPlayer || (relation != Relation::NEUTRAL
- && localPlayer->getName() == player_name))
+ if (localPlayer == nullptr ||
+ (relation != Relation::NEUTRAL &&
+ localPlayer->getName() == player_name))
{
return;
}
PlayerRelation *const r = mRelations[player_name];
- if (!r)
+ if (r == nullptr)
mRelations[player_name] = new PlayerRelation(relation);
else
r->mRelation = relation;
@@ -365,7 +377,7 @@ StringVect *PlayerRelationsManager::getPlayers() const
FOR_EACH (PlayerRelationsCIter, it, mRelations)
{
- if (it->second)
+ if (it->second != nullptr)
retval->push_back(it->first);
}
@@ -381,8 +393,11 @@ StringVect *PlayerRelationsManager::getPlayersByRelation(
FOR_EACH (PlayerRelationsCIter, it, mRelations)
{
- if (it->second && it->second->mRelation == rel)
+ if ((it->second != nullptr) &&
+ it->second->mRelation == rel)
+ {
retval->push_back(it->first);
+ }
}
std::sort(retval->begin(), retval->end(), playersRelSorter);
@@ -432,10 +447,10 @@ void PlayerRelationsManager::ignoreTrade(const std::string &name) const
const RelationT relation = getRelation(name);
- if (relation == Relation::IGNORED
- || relation == Relation::DISREGARDED
- || relation == Relation::BLACKLISTED
- || relation == Relation::ERASED)
+ if (relation == Relation::IGNORED ||
+ relation == Relation::DISREGARDED ||
+ relation == Relation::BLACKLISTED ||
+ relation == Relation::ERASED)
{
return;
}
@@ -452,11 +467,11 @@ bool PlayerRelationsManager::checkBadRelation(const std::string &name) const
const RelationT relation = getRelation(name);
- if (relation == Relation::IGNORED
- || relation == Relation::DISREGARDED
- || relation == Relation::BLACKLISTED
- || relation == Relation::ERASED
- || relation == Relation::ENEMY2)
+ if (relation == Relation::IGNORED ||
+ relation == Relation::DISREGARDED ||
+ relation == Relation::BLACKLISTED ||
+ relation == Relation::ERASED ||
+ relation == Relation::ENEMY2)
{
return true;
}
@@ -502,7 +517,7 @@ class PIS_dotdotdot final : public PlayerIgnoreStrategy
void ignore(Being *const being,
const unsigned int flags A_UNUSED) const override final
{
- if (!being)
+ if (being == nullptr)
return;
logger->log("ignoring: " + being->getName());
@@ -527,7 +542,7 @@ class PIS_blinkname final : public PlayerIgnoreStrategy
void ignore(Being *const being,
const unsigned int flags A_UNUSED) const override final
{
- if (!being)
+ if (being == nullptr)
return;
logger->log("ignoring: " + being->getName());
@@ -553,7 +568,7 @@ class PIS_emote final : public PlayerIgnoreStrategy
void ignore(Being *const being,
const unsigned int flags A_UNUSED) const override final
{
- if (!being)
+ if (being == nullptr)
return;
being->setEmote(mEmotion, IGNORE_EMOTE_TIME);
@@ -599,7 +614,7 @@ bool PlayerRelationsManager::isGoodName(const std::string &name) const
bool PlayerRelationsManager::isGoodName(Being *const being) const
{
- if (!being)
+ if (being == nullptr)
return false;
if (being->getGoodStatus() != -1)
return (being->getGoodStatus() == 1);
@@ -626,8 +641,10 @@ bool PlayerRelationsManager::checkName(const std::string &name)
const std::string check = config.getStringValue("unsecureChars");
const std::string lastChar = name.substr(size - 1, 1);
- if (name.substr(0, 1) == " " || lastChar == " " || lastChar == "."
- || name.find(" ") != std::string::npos)
+ if (name.substr(0, 1) == " " ||
+ lastChar == " " ||
+ lastChar == "." ||
+ name.find(" ") != std::string::npos)
{
return false;
}