diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-06-06 23:34:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-06-07 19:23:40 +0300 |
commit | 36ba43d6ea38062b17f7e63ef659962bfc51c64d (patch) | |
tree | 190156cb88b13a38a6d13c69ee0742cc078065a1 /src/net/tmwa | |
parent | f1518dd8476c968a43fa57cfb06198e290a4f77a (diff) | |
download | mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2 mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip |
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/net/tmwa')
28 files changed, 297 insertions, 290 deletions
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index e9f9eb748..de2a42134 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -47,7 +47,7 @@ void BeingHandler::requestNameById(const BeingId id) const void BeingHandler::undress(Being *const being) const { - if (!being) + if (being == nullptr) return; being->unSetSprite(SPRITE_WEAPON); being->unSetSprite(SPRITE_HEAD_BOTTOM); diff --git a/src/net/tmwa/beingrecv.cpp b/src/net/tmwa/beingrecv.cpp index 4b1bb631b..cb02e690e 100644 --- a/src/net/tmwa/beingrecv.cpp +++ b/src/net/tmwa/beingrecv.cpp @@ -61,7 +61,7 @@ namespace TmwAthena void BeingRecv::processBeingChangeLook(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingChangeLook") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingChangeLook") return; @@ -74,7 +74,7 @@ void BeingRecv::processBeingChangeLook(Net::MessageIn &msg) const int16_t id = CAST_S16(msg.readUInt8("id")); const int id2 = 1; - if (!localPlayer || !dstBeing) + if ((localPlayer == nullptr) || (dstBeing == nullptr)) { BLOCK_END("BeingRecv::processBeingChangeLook") return; @@ -86,7 +86,7 @@ void BeingRecv::processBeingChangeLook(Net::MessageIn &msg) void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingChangeLook") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingChangeLook") return; @@ -109,7 +109,7 @@ void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg) id2 = 1; } - if (!localPlayer || !dstBeing) + if ((localPlayer == nullptr) || (dstBeing == nullptr)) { BLOCK_END("BeingRecv::processBeingChangeLook") return; @@ -223,7 +223,7 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg, void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerMoveUpdate") - if (!actorManager || !localPlayer) + if ((actorManager == nullptr) || (localPlayer == nullptr)) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; @@ -241,7 +241,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) disguiseId = job; Being *dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { if (actorManager->isBlocked(id) == true) { @@ -251,20 +251,20 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) dstBeing = Ea::BeingRecv::createBeing(id, job); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; } } - else if (disguiseId) + else if (disguiseId != 0) { actorManager->undelete(dstBeing); beingHandler->requestNameById(id); } uint8_t dir = dstBeing->getDirectionDelayed(); - if (dir) + if (dir != 0u) { if (dir != dstBeing->getDirection()) dstBeing->setDirection(dir); @@ -294,7 +294,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) const int guild = msg.readInt32("guild"); - if (!guildManager || !GuildManager::getEnableGuildBot()) + if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) { if (guild == 0) dstBeing->clearGuilds(); @@ -310,7 +310,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) dstBeing->setGender(Being::intToGender( CAST_U8(msg.readUInt8("gender") & 3))); - if (!disguiseId) + if (disguiseId == 0) { // Set these after the gender, as the sprites may be gender-specific dstBeing->updateSprite(SPRITE_BODY, @@ -346,12 +346,12 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) const uint16_t gmstatus = msg.readInt16("gm status"); - if (gmstatus & 0x80) + if ((gmstatus & 0x80) != 0) dstBeing->setGM(true); applyPlayerAction(msg, dstBeing, msg.readUInt8("action type")); const int level = CAST_S32(msg.readUInt8("level")); - if (level) + if (level != 0) dstBeing->setLevel(level); msg.readUInt8("unused"); @@ -369,7 +369,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerMoveUpdate") - if (!actorManager || !localPlayer) + if ((actorManager == nullptr) || (localPlayer == nullptr)) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; @@ -387,7 +387,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) disguiseId = job; Being *dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { if (actorManager->isBlocked(id) == true) { @@ -397,20 +397,20 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) dstBeing = Ea::BeingRecv::createBeing(id, job); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; } } - else if (disguiseId) + else if (disguiseId != 0) { actorManager->undelete(dstBeing); beingHandler->requestNameById(id); } uint8_t dir = dstBeing->getDirectionDelayed(); - if (dir) + if (dir != 0u) { if (dir != dstBeing->getDirection()) dstBeing->setDirection(dir); @@ -439,7 +439,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) const int guild = msg.readInt32("guild"); - if (!guildManager || !GuildManager::getEnableGuildBot()) + if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) { if (guild == 0) dstBeing->clearGuilds(); @@ -455,7 +455,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) dstBeing->setGender(Being::intToGender( CAST_U8(msg.readUInt8("gender") & 3))); - if (!disguiseId) + if (disguiseId == 0) { // Set these after the gender, as the sprites may be gender-specific dstBeing->updateSprite(SPRITE_BODY, @@ -491,12 +491,12 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) const uint16_t gmstatus = msg.readInt16("gm status"); - if (gmstatus & 0x80) + if ((gmstatus & 0x80) != 0) dstBeing->setGM(true); applyPlayerAction(msg, dstBeing, msg.readUInt8("action type")); const int level = CAST_S32(msg.readUInt8("level")); - if (level) + if (level != 0) dstBeing->setLevel(level); dstBeing->setActionTime(tick_time); @@ -511,7 +511,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) void BeingRecv::processPlayerMove(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerMoveUpdate") - if (!actorManager || !localPlayer) + if ((actorManager == nullptr) || (localPlayer == nullptr)) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; @@ -529,7 +529,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) disguiseId = job; Being *dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { if (actorManager->isBlocked(id) == true) { @@ -539,20 +539,20 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) dstBeing = Ea::BeingRecv::createBeing(id, job); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; } } - else if (disguiseId) + else if (disguiseId != 0) { actorManager->undelete(dstBeing); beingHandler->requestNameById(id); } const uint8_t dir = dstBeing->getDirectionDelayed(); - if (dir) + if (dir != 0u) { if (dir != dstBeing->getDirection()) dstBeing->setDirection(dir); @@ -584,7 +584,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) const int guild = msg.readInt32("guild"); - if (!guildManager || !GuildManager::getEnableGuildBot()) + if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) { if (guild == 0) dstBeing->clearGuilds(); @@ -600,7 +600,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) dstBeing->setGender(Being::intToGender( CAST_U8(msg.readUInt8("gender") & 3))); - if (!disguiseId) + if (disguiseId == 0) { // Set these after the gender, as the sprites may be gender-specific dstBeing->updateSprite(SPRITE_BODY, @@ -642,7 +642,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) { const int d = dstBeing->calcDirection(dstX, dstY); - if (d && dstBeing->getDirection() != d) + if ((d != 0) && dstBeing->getDirection() != d) dstBeing->setDirectionDelayed(CAST_U8(d)); } @@ -656,13 +656,13 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) const uint16_t gmstatus = msg.readInt16("gm status"); - if (gmstatus & 0x80) + if ((gmstatus & 0x80) != 0) dstBeing->setGM(true); msg.readUInt8("unused"); const int level = CAST_S32(msg.readUInt8("level")); - if (level) + if (level != 0) dstBeing->setLevel(level); msg.readUInt8("unused"); @@ -683,7 +683,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) void BeingRecv::processBeingVisible(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingVisibleOrMove") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingVisibleOrMove") return; @@ -709,7 +709,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) Being *dstBeing = actorManager->findBeing(id); - if (dstBeing && dstBeing->getType() == ActorType::Monster + if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster && !dstBeing->isAlive()) { actorManager->destroy(dstBeing); @@ -717,7 +717,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) dstBeing = nullptr; } - if (!dstBeing) + if (dstBeing == nullptr) { // Being with id >= 110000000 and job 0 are better // known as ghosts, so don't create those. @@ -735,7 +735,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) dstBeing = Ea::BeingRecv::createBeing(id, job); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processBeingVisibleOrMove") return; @@ -771,7 +771,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) const uint8_t hairStyle = msg.readUInt8("hair style"); const uint16_t look = msg.readUInt8("look"); dstBeing->setSubtype(fromInt(job, BeingTypeId), look); - if (dstBeing->getType() == ActorType::Monster && localPlayer) + if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr)) localPlayer->checkNewName(dstBeing); dstBeing->setWalkSpeed(speed); const uint16_t weapon = msg.readInt16("weapon"); @@ -792,11 +792,11 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) { const int hp = msg.readInt32("hp"); const int maxHP = msg.readInt32("max hp"); - if (hp && maxHP) + if ((hp != 0) && (maxHP != 0)) { dstBeing->setMaxHP(maxHP); const int oldHP = dstBeing->getHP(); - if (!oldHP || oldHP > hp) + if ((oldHP == 0) || oldHP > hp) dstBeing->setHP(hp); } } @@ -829,7 +829,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) } uint8_t gender = msg.readUInt8("gender"); - if (!disguiseId && dstBeing->getType() == ActorType::Player) + if ((disguiseId == 0) && dstBeing->getType() == ActorType::Player) { // reserving bits for future usage gender &= 3; @@ -866,7 +866,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) msg.readCoordinates(x, y, dir, "position"); dstBeing->setTileCoords(x, y); - if (job == 45 && socialWindow && outfitWindow) + if (job == 45 && (socialWindow != nullptr) && (outfitWindow != nullptr)) { const int num = socialWindow->getPortalIndex(x, y); if (num >= 0) @@ -898,7 +898,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) void BeingRecv::processBeingMove(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingVisibleOrMove") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingVisibleOrMove") return; @@ -924,7 +924,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) Being *dstBeing = actorManager->findBeing(id); - if (dstBeing && dstBeing->getType() == ActorType::Monster + if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster && !dstBeing->isAlive()) { actorManager->destroy(dstBeing); @@ -932,7 +932,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) dstBeing = nullptr; } - if (!dstBeing) + if (dstBeing == nullptr) { // Being with id >= 110000000 and job 0 are better // known as ghosts, so don't create those. @@ -950,7 +950,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) dstBeing = Ea::BeingRecv::createBeing(id, job); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processBeingVisibleOrMove") return; @@ -978,7 +978,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) const uint8_t hairStyle = msg.readUInt8("hair style"); const uint16_t look = msg.readUInt8("look"); dstBeing->setSubtype(fromInt(job, BeingTypeId), look); - if (dstBeing->getType() == ActorType::Monster && localPlayer) + if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr)) localPlayer->checkNewName(dstBeing); dstBeing->setWalkSpeed(speed); const uint16_t weapon = msg.readInt16("weapon"); @@ -1001,11 +1001,11 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) { const int hp = msg.readInt32("hp"); const int maxHP = msg.readInt32("max hp"); - if (hp && maxHP) + if ((hp != 0) && (maxHP != 0)) { dstBeing->setMaxHP(maxHP); const int oldHP = dstBeing->getHP(); - if (!oldHP || oldHP > hp) + if ((oldHP == 0) || oldHP > hp) dstBeing->setHP(hp); } } @@ -1038,7 +1038,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) } uint8_t gender = msg.readUInt8("gender"); - if (!disguiseId && dstBeing->getType() == ActorType::Player) + if ((disguiseId == 0) && dstBeing->getType() == ActorType::Player) { // reserving bits for future usage gender &= 3; @@ -1072,7 +1072,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) uint16_t srcX, srcY, dstX, dstY; msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path"); - if (!disguiseId) + if (disguiseId == 0) { dstBeing->setAction(BeingAction::STAND, 0); dstBeing->setTileCoords(srcX, srcY); @@ -1123,7 +1123,7 @@ void BeingRecv::processSkillCasting(Net::MessageIn &msg) void BeingRecv::processBeingStatusChange(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingStatusChange") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingStatusChange") return; @@ -1136,7 +1136,7 @@ void BeingRecv::processBeingStatusChange(Net::MessageIn &msg) msg.readUInt8("flag: 0: stop, 1: start"), Enable); Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) { // dont know on legacy servers is effect really started // or not. Because this always sending IsStart_true @@ -1148,7 +1148,7 @@ void BeingRecv::processBeingStatusChange(Net::MessageIn &msg) void BeingRecv::processBeingMove2(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingMove2") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingMove2") return; @@ -1168,7 +1168,7 @@ void BeingRecv::processBeingMove2(Net::MessageIn &msg) * we'll just pretend the packet didn't happen */ - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processBeingMove2") return; @@ -1189,7 +1189,7 @@ void BeingRecv::processBeingMove2(Net::MessageIn &msg) void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingChangeDirection") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingChangeDirection") return; @@ -1198,7 +1198,7 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("being id")); - if (!dstBeing) + if (dstBeing == nullptr) { DEBUGLOGSTR("invisible player?"); msg.readInt16("unused"); @@ -1212,7 +1212,7 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg) const uint8_t dir = Net::MessageIn::fromServerDirection( CAST_U8(msg.readUInt8("direction") & 0x0FU)); dstBeing->setDirection(dir); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateDirection(dstBeing, dir); BLOCK_END("BeingRecv::processBeingChangeDirection") } @@ -1220,7 +1220,7 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg) void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerStop") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processPlayerStop") return; @@ -1229,7 +1229,7 @@ void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg) // Change in players' flags const BeingId id = msg.readBeingId("account id"); Being *const dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { DEBUGLOGSTR("invisible player?"); msg.readInt16("stun mode"); @@ -1253,7 +1253,7 @@ void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg) void BeingRecv::processBeingResurrect(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingResurrect") - if (!actorManager || !localPlayer) + if ((actorManager == nullptr) || (localPlayer == nullptr)) { BLOCK_END("BeingRecv::processBeingResurrect") return; @@ -1263,7 +1263,7 @@ void BeingRecv::processBeingResurrect(Net::MessageIn &msg) const BeingId id = msg.readBeingId("being id"); Being *const dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { DEBUGLOGSTR("insible player?"); msg.readInt16("flag?"); @@ -1283,7 +1283,7 @@ void BeingRecv::processBeingResurrect(Net::MessageIn &msg) void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerGuilPartyInfo") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processPlayerGuilPartyInfo") return; @@ -1292,10 +1292,10 @@ void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("being id")); - if (dstBeing) + if (dstBeing != nullptr) { dstBeing->setPartyName(msg.readString(24, "party name")); - if (!guildManager || !GuildManager::getEnableGuildBot()) + if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) { dstBeing->setGuildName(msg.readString(24, "guild name")); dstBeing->setGuildPos(msg.readString(24, "guild pos")); @@ -1321,7 +1321,7 @@ void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg) void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingSelfEffect") - if (!effectManager || !actorManager) + if ((effectManager == nullptr) || (actorManager == nullptr)) { BLOCK_END("BeingRecv::processBeingSelfEffect") return; @@ -1329,7 +1329,7 @@ void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg) const BeingId id = msg.readBeingId("being id"); Being *const being = actorManager->findBeing(id); - if (!being) + if (being == nullptr) { DEBUGLOGSTR("insible player?"); msg.readInt32("effect type"); @@ -1344,7 +1344,7 @@ void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg) // +++ need dehard code effectType == 3 if (effectType == 3 && being->getType() == ActorType::Player - && socialWindow) + && (socialWindow != nullptr)) { // reset received damage socialWindow->resetDamage(being->getName()); } @@ -1359,7 +1359,7 @@ void BeingRecv::processSkillCastCancel(Net::MessageIn &msg) void BeingRecv::processIpResponse(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processIpResponse") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processIpResponse") return; @@ -1368,7 +1368,7 @@ void BeingRecv::processIpResponse(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("being id")); const std::string ip = ipToString(msg.readInt32("ip address")); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setIp(ip); else DEBUGLOGSTR("invisible player?"); @@ -1383,10 +1383,10 @@ void BeingRecv::processPvpSet(Net::MessageIn &msg) const int rank = msg.readInt32("rank"); int teamId = 0; teamId = msg.readInt32("team"); - if (actorManager) + if (actorManager != nullptr) { Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) { dstBeing->setPvpRank(rank); dstBeing->setTeamId(CAST_U16(teamId)); @@ -1400,7 +1400,7 @@ void BeingRecv::applyPlayerAction(Net::MessageIn &msg, Being *const being, const uint8_t type) { - if (!being) + if (being == nullptr) return; switch (type) { @@ -1431,7 +1431,7 @@ void BeingRecv::applyPlayerAction(Net::MessageIn &msg, void BeingRecv::processSkillDamage(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processSkillDamage") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processSkillDamage") return; @@ -1449,9 +1449,9 @@ void BeingRecv::processSkillDamage(Net::MessageIn &msg) const int level = msg.readInt16("skill level"); msg.readInt16("div"); msg.readUInt8("skill hit/type?"); - if (srcBeing) + if (srcBeing != nullptr) srcBeing->handleSkill(dstBeing, param1, id, level); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->takeDamage(srcBeing, param1, AttackType::SKILL, id, level); BLOCK_END("BeingRecv::processSkillDamage") } @@ -1459,7 +1459,7 @@ void BeingRecv::processSkillDamage(Net::MessageIn &msg) void BeingRecv::setServerGender(Being *const being, const uint8_t gender) { - if (!being) + if (being == nullptr) return; switch (gender) { diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp index 232d9492e..7f48fb89c 100644 --- a/src/net/tmwa/buysellhandler.cpp +++ b/src/net/tmwa/buysellhandler.cpp @@ -49,7 +49,7 @@ BuySellHandler::BuySellHandler() : void BuySellHandler::requestSellList(const std::string &nick) const { - if (nick.empty() != 0 || !shopWindow) + if (nick.empty() || shopWindow == nullptr) return; const std::string data("!selllist " + toString(tick_time)); @@ -60,14 +60,14 @@ void BuySellHandler::requestSellList(const std::string &nick) const } else { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); } } void BuySellHandler::requestBuyList(const std::string &nick) const { - if (nick.empty() || !shopWindow) + if (nick.empty() || (shopWindow == nullptr)) return; const std::string data("!buylist " + toString(tick_time)); @@ -79,7 +79,7 @@ void BuySellHandler::requestBuyList(const std::string &nick) const } else { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); } } @@ -88,7 +88,7 @@ void BuySellHandler::sendBuyRequest(const std::string &nick, const ShopItem *const item, const int amount) const { - if (!chatWindow || nick.empty() || !item || + if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) || amount < 1 || amount > item->getQuantity()) { return; @@ -106,7 +106,7 @@ void BuySellHandler::sendSellRequest(const std::string &nick, const ShopItem *const item, const int amount) const { - if (!chatWindow || nick.empty() || !item || + if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) || amount < 1 || amount > item->getQuantity()) { return; diff --git a/src/net/tmwa/buysellrecv.cpp b/src/net/tmwa/buysellrecv.cpp index c4fac1416..004837e50 100644 --- a/src/net/tmwa/buysellrecv.cpp +++ b/src/net/tmwa/buysellrecv.cpp @@ -95,7 +95,7 @@ void BuySellRecv::processNpcBuyResponse(Net::MessageIn &msg) } // Reset player money since buy dialog already assumed purchase // would go fine - if (Ea::BuySellRecv::mBuyDialog) + if (Ea::BuySellRecv::mBuyDialog != nullptr) { Ea::BuySellRecv::mBuyDialog->setMoney( PlayerInfo::getAttribute(Attributes::MONEY)); diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 958f08cc1..faaf89bc6 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -56,7 +56,7 @@ CharServerHandler::CharServerHandler() : void CharServerHandler::chooseCharacter(Net::Character *const character) const { - if (!character) + if (character == nullptr) return; mSelectedCharacter = character; @@ -91,7 +91,7 @@ void CharServerHandler::deleteCharacter(Net::Character *const character, const std::string &email A_UNUSED) const { - if (!character) + if (character == nullptr) return; mSelectedCharacter = character; @@ -113,7 +113,7 @@ void CharServerHandler::connect() const const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken(); - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; Network::mInstance->disconnect(); @@ -137,7 +137,7 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window) { mCharCreateDialog = window; - if (!mCharCreateDialog) + if (mCharCreateDialog == nullptr) return; StringVect attributes; @@ -157,13 +157,13 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window) const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken(); int minStat = CharDB::getMinStat(); - if (!minStat) + if (minStat == 0) minStat = 1; int maxStat = CharDB::getMaxStat(); - if (!maxStat) + if (maxStat == 0) maxStat = 9; int sumStat = CharDB::getSumStat(); - if (!sumStat) + if (sumStat == 0) sumStat = 30; mCharCreateDialog->setAttributes(attributes, sumStat, minStat, maxStat); diff --git a/src/net/tmwa/charserverrecv.cpp b/src/net/tmwa/charserverrecv.cpp index 43f405542..571ce0b3b 100644 --- a/src/net/tmwa/charserverrecv.cpp +++ b/src/net/tmwa/charserverrecv.cpp @@ -64,7 +64,7 @@ extern ServerInfo charServer; void CharServerRecv::readPlayerData(Net::MessageIn &msg, Net::Character *const character) { - if (!character) + if (character == nullptr) return; const Token &token = @@ -193,7 +193,7 @@ void CharServerRecv::processCharLogin(Net::MessageIn &msg) Net::Character *const character = new Net::Character; readPlayerData(msg, character); charServerHandler->mCharacters.push_back(character); - if (character->dummy) + if (character->dummy != nullptr) { logger->log("CharServer: Player: %s (%d)", character->dummy->getName().c_str(), character->slot); @@ -232,7 +232,7 @@ void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg) charServerHandler->clear(); charServerHandler->updateCharSelectDialog(); - if (network) + if (network != nullptr) network->disconnect(); client->setState(State::CONNECT_GAME); BLOCK_END("CharServerRecv::processCharMapInfo") @@ -244,7 +244,7 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) ServerInfo &server = mapServer; BLOCK_START("CharServerRecv::processChangeMapServer") GameHandler *const gh = static_cast<GameHandler*>(gameHandler); - if (!gh || !network) + if ((gh == nullptr) || (network == nullptr)) { BLOCK_END("CharServerRecv::processChangeMapServer") return; @@ -265,7 +265,7 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) network->disconnect(); client->setState(State::CHANGE_MAP); - if (localPlayer) + if (localPlayer != nullptr) { localPlayer->setTileCoords(x, y); localPlayer->setMap(nullptr); @@ -283,7 +283,7 @@ void CharServerRecv::processCharCreate(Net::MessageIn &msg) charServerHandler->updateCharSelectDialog(); // Close the character create dialog - if (charServerHandler->mCharCreateDialog) + if (charServerHandler->mCharCreateDialog != nullptr) { charServerHandler->mCharCreateDialog->scheduleDelete(); charServerHandler->mCharCreateDialog = nullptr; diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index f985d12e1..2bc869d92 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -51,7 +51,7 @@ ChatHandler::ChatHandler() : void ChatHandler::talk(const std::string &restrict text, const std::string &restrict channel A_UNUSED) const { - if (!localPlayer) + if (localPlayer == nullptr) return; if (tmwServerVersion >= 0x100408) diff --git a/src/net/tmwa/chatrecv.cpp b/src/net/tmwa/chatrecv.cpp index 40331db5f..116674c53 100644 --- a/src/net/tmwa/chatrecv.cpp +++ b/src/net/tmwa/chatrecv.cpp @@ -68,7 +68,7 @@ void ChatRecv::processChatContinue(std::string chatMsg, const size_t pos = chatMsg.find(" : ", 0); bool allow(true); - if (chatWindow) + if (chatWindow != nullptr) { allow = chatWindow->resortChatLog(chatMsg, ChatMsgType::BY_PLAYER, @@ -80,7 +80,7 @@ void ChatRecv::processChatContinue(std::string chatMsg, if (channel.empty()) { const std::string senseStr("You sense the following: "); - if (actorManager && !chatMsg.find(senseStr)) + if ((actorManager != nullptr) && (chatMsg.find(senseStr) == 0u)) { actorManager->parseLevels( chatMsg.substr(senseStr.size())); @@ -111,9 +111,9 @@ void ChatRecv::processChatContinue(std::string chatMsg, trim(chatMsg); - if (localPlayer) + if (localPlayer != nullptr) { - if ((chatWindow || Ea::ChatRecv::mShowMotd) && allow) + if (((chatWindow != nullptr) || Ea::ChatRecv::mShowMotd) && allow) localPlayer->setSpeech(chatMsg, channel); } BLOCK_END("ChatRecv::processChat") @@ -131,9 +131,9 @@ void ChatRecv::processGmChat(Net::MessageIn &msg) std::string chatMsg = msg.readRawString(chatMsgLength, "message"); - if (localChatTab) + if (localChatTab != nullptr) { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->addGlobalMessage(chatMsg); } BLOCK_END("ChatRecv::processChat") @@ -177,7 +177,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick, if (nick != "Server") { - if (guildManager && GuildManager::getEnableGuildBot() + if ((guildManager != nullptr) && GuildManager::getEnableGuildBot() && nick == "guild" && guildManager->processGuildMessage(chatMsg)) { BLOCK_END("ChatRecv::processWhisper") @@ -190,13 +190,13 @@ void ChatRecv::processWhisperContinue(const std::string &nick, const bool showMsg = !config.getBoolValue("hideShopMessages"); if (player_relations.hasPermission(nick, PlayerRelation::TRADE)) { - if (shopWindow) + if (shopWindow != nullptr) { // commands to shop from player if (chatMsg.find("!selllist ") == 0) { if (tradeBot) { - if (showMsg && chatWindow) + if (showMsg && (chatWindow != nullptr)) chatWindow->addWhisper(nick, chatMsg); shopWindow->giveList(nick, ShopWindow::SELL); } @@ -205,14 +205,14 @@ void ChatRecv::processWhisperContinue(const std::string &nick, { if (tradeBot) { - if (showMsg && chatWindow) + if (showMsg && (chatWindow != nullptr)) chatWindow->addWhisper(nick, chatMsg); shopWindow->giveList(nick, ShopWindow::BUY); } } else if (chatMsg.find("!buyitem ") == 0) { - if (showMsg && chatWindow) + if (showMsg && (chatWindow != nullptr)) chatWindow->addWhisper(nick, chatMsg); if (tradeBot) { @@ -222,7 +222,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick, } else if (chatMsg.find("!sellitem ") == 0) { - if (showMsg && chatWindow) + if (showMsg && (chatWindow != nullptr)) chatWindow->addWhisper(nick, chatMsg); if (tradeBot) { @@ -234,24 +234,24 @@ void ChatRecv::processWhisperContinue(const std::string &nick, && chatMsg.find("\302\202") == 0) { chatMsg = chatMsg.erase(0, 2); - if (showMsg && chatWindow) + if (showMsg && (chatWindow != nullptr)) chatWindow->addWhisper(nick, chatMsg); if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0) shopWindow->showList(nick, chatMsg); } - else if (chatWindow) + else if (chatWindow != nullptr) { chatWindow->addWhisper(nick, chatMsg); } } - else if (chatWindow) + else if (chatWindow != nullptr) { chatWindow->addWhisper(nick, chatMsg); } } else { - if (chatWindow && (showMsg || (chatMsg.find("!selllist") != 0 + if ((chatWindow != nullptr) && (showMsg || (chatMsg.find("!selllist") != 0 && chatMsg.find("!buylist") != 0))) { chatWindow->addWhisper(nick, chatMsg); @@ -259,9 +259,9 @@ void ChatRecv::processWhisperContinue(const std::string &nick, } } } - else if (localChatTab) + else if (localChatTab != nullptr) { - if (gmChatTab && strStartWith(chatMsg, "[GM] ")) + if ((gmChatTab != nullptr) && strStartWith(chatMsg, "[GM] ")) { chatMsg = chatMsg.substr(5); const size_t pos = chatMsg.find(": ", 0); @@ -285,7 +285,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick, void ChatRecv::processBeingChat(Net::MessageIn &msg) { - if (!actorManager) + if (actorManager == nullptr) return; BLOCK_START("ChatRecv::processBeingChat") @@ -301,7 +301,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) std::string chatMsg = msg.readRawString(chatMsgLength, "message"); - if (being && being->getType() == ActorType::Player) + if ((being != nullptr) && being->getType() == ActorType::Player) being->setTalkTime(); const size_t pos = chatMsg.find(" : ", 0); @@ -311,7 +311,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) if (serverFeatures->haveIncompleteChatMessages()) { // work around for "new" tmw server - if (being) + if (being != nullptr) sender_name = being->getName(); if (sender_name.empty()) { @@ -321,7 +321,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) sender_name.append(" ").append(name); } } - else if (being && + else if ((being != nullptr) && sender_name != being->getName() && being->getType() == ActorType::Player) { @@ -339,9 +339,9 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) // We use getIgnorePlayer instead of ignoringPlayer here // because ignorePlayer' side effects are triggered // right below for Being::IGNORE_SPEECH_FLOAT. - if (player_relations.checkPermissionSilently(sender_name, - PlayerRelation::SPEECH_LOG) && - chatWindow) + if ((player_relations.checkPermissionSilently(sender_name, + PlayerRelation::SPEECH_LOG) != 0u) && + (chatWindow != nullptr)) { allow = chatWindow->resortChatLog( removeColors(sender_name).append(" : ").append(chatMsg), @@ -352,7 +352,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) } if (allow && - being && + (being != nullptr) && player_relations.hasPermission(sender_name, PlayerRelation::SPEECH_FLOAT)) { diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index 2eb505431..d01acd178 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -57,7 +57,7 @@ void GameHandler::mapLoadedEvent() const void GameHandler::connect() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; BLOCK_START("GameHandler::connect") @@ -67,7 +67,7 @@ void GameHandler::connect() const if (client->getState() == State::CONNECT_GAME) { // Change the player's ID to the account ID to match what eAthena uses - if (localPlayer) + if (localPlayer != nullptr) { Ea::GameRecv::mCharID = localPlayer->getId(); localPlayer->setId(token.account_ID); @@ -100,7 +100,7 @@ void GameHandler::connect() const bool GameHandler::isConnected() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return false; return Network::mInstance->isConnected(); } @@ -108,7 +108,7 @@ bool GameHandler::isConnected() const void GameHandler::disconnect() const { BLOCK_START("GameHandler::disconnect") - if (Network::mInstance) + if (Network::mInstance != nullptr) Network::mInstance->disconnect(); BLOCK_END("GameHandler::disconnect") } diff --git a/src/net/tmwa/gamerecv.cpp b/src/net/tmwa/gamerecv.cpp index e71bdc3b7..ab13076fb 100644 --- a/src/net/tmwa/gamerecv.cpp +++ b/src/net/tmwa/gamerecv.cpp @@ -51,12 +51,12 @@ void GameRecv::processMapLogin(Net::MessageIn &msg) mLastHost &= 0xffffff; Network *const network = Network::mInstance; - if (network) + if (network != nullptr) network->pauseDispatch(); // Switch now or we'll have problems client->setState(State::GAME); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->setTileCoords(x, y); } diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index e50ddcbb7..25e4aa1ad 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -129,7 +129,7 @@ void GeneralHandler::load() const void GeneralHandler::reload() const { - if (Network::mInstance) + if (Network::mInstance != nullptr) Network::mInstance->disconnect(); static_cast<LoginHandler*>(mLoginHandler)->clearWorlds(); @@ -152,7 +152,7 @@ void GeneralHandler::unload() const void GeneralHandler::flushSend() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; Network::mInstance->flush(); @@ -160,7 +160,7 @@ void GeneralHandler::flushSend() const void GeneralHandler::flushNetwork() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; BLOCK_START("GeneralHandler::flushNetwork 1") @@ -188,19 +188,19 @@ void GeneralHandler::flushNetwork() const void GeneralHandler::clearHandlers() const { - if (Network::mInstance) + if (Network::mInstance != nullptr) Network::mInstance->clearHandlers(); } void GeneralHandler::gameStarted() const { - if (skillDialog) + if (skillDialog != nullptr) skillDialog->loadSkills(); } void GeneralHandler::gameEnded() const { - if (socialWindow) + if (socialWindow != nullptr) socialWindow->removeTab(Ea::taParty); delete2(partyTab); diff --git a/src/net/tmwa/guildmanager.cpp b/src/net/tmwa/guildmanager.cpp index 7615b02ab..d3670cdac 100644 --- a/src/net/tmwa/guildmanager.cpp +++ b/src/net/tmwa/guildmanager.cpp @@ -80,15 +80,15 @@ void GuildManager::init() val = 0; serverConfig.setValue("enableGuildBot", val); } - mEnableGuildBot = val; + mEnableGuildBot = (val != 0); if (mEnableGuildBot) { - if (!guildManager) + if (guildManager == nullptr) guildManager = new GuildManager; else guildManager->reload(); } - else if (guildManager) + else if (guildManager != nullptr) { delete2(guildManager); } @@ -106,10 +106,10 @@ void GuildManager::reload() mRequestTime = 0; mTempList.clear(); - if (socialWindow) + if (socialWindow != nullptr) { Guild *const guild = Guild::getGuild(1); - if (guild && socialWindow) + if ((guild != nullptr) && (socialWindow != nullptr)) socialWindow->removeTab(guild); } delete2(mTab); @@ -122,7 +122,7 @@ void GuildManager::send(const std::string &msg) void GuildManager::chat(const std::string &msg) { - if (!localPlayer || !mTab) + if ((localPlayer == nullptr) || (mTab == nullptr)) return; chatHandler->privateMessage("guild", msg); @@ -132,7 +132,7 @@ void GuildManager::chat(const std::string &msg) void GuildManager::getNames(StringVect &names) const { const Guild *const guild = createGuild(); - if (guild) + if (guild != nullptr) guild->getNames(names); } @@ -177,7 +177,7 @@ void GuildManager::slowLogic() void GuildManager::updateList() { Guild *const guild = Guild::getGuild(1); - if (guild) + if (guild != nullptr) { guild->setServerGuild(false); StringVectCIter it = mTempList.begin(); @@ -194,17 +194,18 @@ void GuildManager::updateList() name = name.substr(0, sz - 1); GuildMember *const m = guild->addMember( fromInt(i, BeingId), 0, name); - if (m) + if (m != nullptr) { - m->setOnline(status & 1); + m->setOnline((status & 1) != 0); m->setGender(Gender::UNSPECIFIED); - if (status & 2) + if ((status & 2) != 0) m->setPos(10); else m->setPos(0); - if (localPlayer && name == localPlayer->getName()) + if (localPlayer != nullptr && + name == localPlayer->getName()) { - mHavePower = (status & 2); + mHavePower = ((status & 2) != 0); m->setOnline(true); } } @@ -214,12 +215,12 @@ void GuildManager::updateList() } guild->sort(); createTab(guild); - if (actorManager) + if (actorManager != nullptr) { actorManager->updatePlayerGuild(); actorManager->updatePlayerColors(); } - if (socialWindow) + if (socialWindow != nullptr) socialWindow->updateGuildCounter(); } mTempList.clear(); @@ -229,12 +230,12 @@ void GuildManager::updateList() void GuildManager::createTab(Guild *const guild) { - if (!mTab) + if (mTab == nullptr) { mTab = new EmulateGuildTab(chatWindow); if (config.getBoolValue("showChatHistory")) mTab->loadFromLogFile("#Guild"); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->addGuild(guild); } } @@ -242,7 +243,7 @@ void GuildManager::createTab(Guild *const guild) Guild *GuildManager::createGuild() const { Guild *const guild = Guild::getGuild(1); - if (!guild) + if (guild == nullptr) return nullptr; guild->setServerGuild(false); @@ -269,7 +270,7 @@ bool GuildManager::process(std::string msg) if (!haveNick && findCutLast(msg, " is now Offline.")) { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; if (msg.size() < 4) return false; @@ -277,40 +278,40 @@ bool GuildManager::process(std::string msg) msg = msg.substr(3); GuildMember *const m = guild->addMember(msg); - if (m) + if (m != nullptr) m->setOnline(false); guild->sort(); mRequest = false; - if (mTab) + if (mTab != nullptr) mTab->showOnline(msg, Online_false); - if (socialWindow) + if (socialWindow != nullptr) socialWindow->updateGuildCounter(); return true; } else if (!haveNick && findCutLast(msg, " is now Online.")) { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; if (msg.size() < 4) return false; if (msg[0] == '#' && msg[1] == '#') msg = msg.substr(3); GuildMember *const m = guild->addMember(msg); - if (m) + if (m != nullptr) m->setOnline(true); guild->sort(); mRequest = false; - if (mTab) + if (mTab != nullptr) mTab->showOnline(msg, Online_true); - if (socialWindow) + if (socialWindow != nullptr) socialWindow->updateGuildCounter(); return true; } else if (findCutFirst(msg, "Welcome to the ")) { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; // logger->log("welcome message: %s", msg.c_str()); const size_t pos = msg.find("! ("); @@ -318,7 +319,7 @@ bool GuildManager::process(std::string msg) return false; msg = msg.substr(0, pos); guild->setName(msg); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->setGuildName(msg); mGotName = true; mSentNameRequest = false; @@ -328,7 +329,7 @@ bool GuildManager::process(std::string msg) else if (findCutFirst(msg, "Player name: ")) { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; size_t pos = msg.find("Access Level: "); if (pos == std::string::npos) @@ -357,7 +358,7 @@ bool GuildManager::process(std::string msg) // logger->log("guild name: %s", msg.c_str()); guild->setName(msg); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->setGuildName(msg); mGotName = true; mSentNameRequest = false; @@ -396,7 +397,7 @@ bool GuildManager::process(std::string msg) && findCutLast(msg, " guild chat. If you would like to accept " "this invitation please reply \"yes\" and if not then \"no\" .")) { - if (socialWindow) + if (socialWindow != nullptr) socialWindow->showGuildInvite(msg, 1, ""); return true; } @@ -404,19 +405,19 @@ bool GuildManager::process(std::string msg) "from the Guild.") || findCutLast(msg, " has left the Guild."))) { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; if (msg.size() < 4) return false; if (msg[0] == '#' && msg[1] == '#') msg = msg.substr(3); - if (actorManager) + if (actorManager != nullptr) { Being *const b = actorManager->findBeingByName( msg, ActorType::Player); - if (b) + if (b != nullptr) { b->clearGuilds(); b->setGuildName(""); @@ -435,19 +436,19 @@ bool GuildManager::process(std::string msg) else { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; - if (!mTab) + if (mTab == nullptr) { createTab(guild); } - if (mTab) + if (mTab != nullptr) { const size_t pos = msg.find(": ", 0); if (pos != std::string::npos) { const std::string sender_name = msg.substr(0, pos); - if (!guild->getMember(sender_name)) + if (guild->getMember(sender_name) == nullptr) { mTab->chatLog(msg, ChatMsgType::BY_SERVER); return true; @@ -495,10 +496,10 @@ void GuildManager::notice(const std::string &msg) void GuildManager::clear() { - if (socialWindow) + if (socialWindow != nullptr) { Guild *const guild = Guild::getGuild(1); - if (guild) + if (guild != nullptr) socialWindow->removeTab(guild); } } @@ -514,11 +515,11 @@ void GuildManager::inviteResponse(const bool response) bool GuildManager::afterRemove() { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; guild->removeFromMembers(); guild->clearMembers(); - if (localPlayer) + if (localPlayer != nullptr) { localPlayer->setGuildName(""); localPlayer->clearGuilds(); @@ -526,9 +527,9 @@ bool GuildManager::afterRemove() NotifyManager::notify(NotifyTypes::GUILD_LEFT); delete2(mTab); - if (socialWindow) + if (socialWindow != nullptr) socialWindow->removeTab(guild); - if (actorManager) + if (actorManager != nullptr) { actorManager->updatePlayerGuild(); actorManager->updatePlayerColors(); diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index e3172c583..2d555fb84 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -69,7 +69,7 @@ InventoryHandler::~InventoryHandler() void InventoryHandler::equipItem(const Item *const item) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_PLAYER_EQUIP); @@ -80,7 +80,7 @@ void InventoryHandler::equipItem(const Item *const item) const void InventoryHandler::unequipItem(const Item *const item) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_PLAYER_UNEQUIP); @@ -90,7 +90,7 @@ void InventoryHandler::unequipItem(const Item *const item) const void InventoryHandler::useItem(const Item *const item) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_PLAYER_INVENTORY_USE); @@ -101,7 +101,7 @@ void InventoryHandler::useItem(const Item *const item) const void InventoryHandler::dropItem(const Item *const item, const int amount) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_PLAYER_INVENTORY_DROP); diff --git a/src/net/tmwa/inventoryrecv.cpp b/src/net/tmwa/inventoryrecv.cpp index 974fd40c8..b699fe49e 100644 --- a/src/net/tmwa/inventoryrecv.cpp +++ b/src/net/tmwa/inventoryrecv.cpp @@ -77,12 +77,12 @@ namespace InventoryRecv void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerEquipment") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; msg.readInt16("len"); Equipment *const equipment = PlayerInfo::getEquipment(); - if (equipment && !equipment->getBackend()) + if ((equipment != nullptr) && (equipment->getBackend() == nullptr)) { // look like SMSG_PLAYER_INVENTORY was not received Ea::InventoryRecv::mEquips.clear(); equipment->setBackend(&Ea::InventoryRecv::mEquips); @@ -110,7 +110,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) index, itemId, CAST_S32(itemType), identified); } - if (inventory) + if (inventory != nullptr) { inventory->setItem(index, itemId, @@ -126,7 +126,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) inventory->setCards(index, cards, 4); } - if (equipType) + if (equipType != 0) { Ea::InventoryRecv::mEquips.setEquipment( InventoryRecv::getSlot(equipType), @@ -139,11 +139,11 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerInventoryAdd") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; - if (PlayerInfo::getEquipment() - && !PlayerInfo::getEquipment()->getBackend()) + if ((PlayerInfo::getEquipment() != nullptr) + && (PlayerInfo::getEquipment()->getBackend() == nullptr)) { // look like SMSG_PLAYER_INVENTORY was not received Ea::InventoryRecv::mEquips.clear(); PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips); @@ -171,7 +171,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) Ea::InventoryRecv::mSentPickups.pop(); } - if (err) + if (err != 0u) { PickupT pickup; switch (err) @@ -199,7 +199,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) UNIMPLEMENTEDPACKETFIELD(err); break; } - if (localPlayer) + if (localPlayer != nullptr) { if (itemId == 0) { @@ -221,7 +221,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) } else { - if (localPlayer) + if (localPlayer != nullptr) { if (itemId == 0) { @@ -241,11 +241,11 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) } } - if (inventory) + if (inventory != nullptr) { const Item *const item = inventory->getItem(index); - if (item && item->getId() == itemId) + if ((item != nullptr) && item->getId() == itemId) amount += item->getQuantity(); inventory->setItem(index, @@ -269,17 +269,17 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerInventory") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; - if (PlayerInfo::getEquipment()) + if (PlayerInfo::getEquipment() != nullptr) { // Clear inventory - this will be a complete refresh Ea::InventoryRecv::mEquips.clear(); PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips); } - if (inventory) + if (inventory != nullptr) inventory->clear(); msg.readInt16("len"); @@ -307,9 +307,9 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) } // Trick because arrows are not considered equipment - const bool isEquipment = arrow & 0x8000; + const bool isEquipment = (arrow & 0x8000) != 0; - if (inventory) + if (inventory != nullptr) { inventory->setItem(index, itemId, @@ -381,7 +381,7 @@ void InventoryRecv::processPlayerEquip(Net::MessageIn &msg) const int equipType = msg.readInt16("equip type"); const uint8_t flag = msg.readUInt8("flag"); - if (!flag) + if (flag == 0u) { NotifyManager::notify(NotifyTypes::EQUIP_FAILED); } @@ -401,13 +401,13 @@ void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg) const int equipType = msg.readInt16("equip type"); const uint8_t flag = msg.readUInt8("flag"); - if (flag) + if (flag != 0u) { Ea::InventoryRecv::mEquips.setEquipment( InventoryRecv::getSlot(equipType), -1); } - if (equipType & 0x8000) + if ((equipType & 0x8000) != 0) ArrowsListener::distributeEvent(); BLOCK_END("InventoryRecv::processPlayerUnEquip") } @@ -482,7 +482,7 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg) } else { - if (Ea::InventoryRecv::mStorage) + if (Ea::InventoryRecv::mStorage != nullptr) { Ea::InventoryRecv::mStorage->setItem(index, itemId, @@ -507,7 +507,7 @@ void InventoryRecv::processPlayerStorageRemove(Net::MessageIn &msg) // Move an item out of storage const int index = msg.readInt16("index") - STORAGE_OFFSET; const int amount = msg.readInt32("amount"); - if (Ea::InventoryRecv::mStorage) + if (Ea::InventoryRecv::mStorage != nullptr) { if (Item *const item = Ea::InventoryRecv::mStorage->getItem(index)) { @@ -522,12 +522,12 @@ void InventoryRecv::processPlayerStorageRemove(Net::MessageIn &msg) void InventoryRecv::processPlayerInventoryRemove(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerInventoryRemove") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; const int index = msg.readInt16("index") - INVENTORY_OFFSET; const int amount = msg.readInt16("amount"); - if (inventory) + if (inventory != nullptr) { if (Item *const item = inventory->getItem(index)) { @@ -545,12 +545,12 @@ int InventoryRecv::getSlot(const int eAthenaSlot) if (eAthenaSlot == 0) return EquipSlot::VECTOREND; - if (eAthenaSlot & 0x8000) + if ((eAthenaSlot & 0x8000) != 0) return inventoryHandler->getProjectileSlot(); unsigned int mask = 1; int position = 0; - while (!(eAthenaSlot & mask)) + while ((eAthenaSlot & mask) == 0u) { mask <<= 1; position++; diff --git a/src/net/tmwa/itemrecv.cpp b/src/net/tmwa/itemrecv.cpp index 1fe1d866c..53d3a19bc 100644 --- a/src/net/tmwa/itemrecv.cpp +++ b/src/net/tmwa/itemrecv.cpp @@ -42,7 +42,7 @@ void ItemRecv::processItemDropped(Net::MessageIn &msg) const int subY = CAST_S32(msg.readInt8("sub y")); const int amount = msg.readInt16("amount"); - if (actorManager) + if (actorManager != nullptr) { actorManager->createItem(id, itemId, @@ -70,7 +70,7 @@ void ItemRecv::processItemVisible(Net::MessageIn &msg) const int subX = CAST_S32(msg.readInt8("sub x")); const int subY = CAST_S32(msg.readInt8("sub y")); - if (actorManager) + if (actorManager != nullptr) { actorManager->createItem(id, itemId, diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 392598161..393935f1a 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -52,7 +52,7 @@ LoginHandler::~LoginHandler() void LoginHandler::connect() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; Network::mInstance->connect(mServer); @@ -64,7 +64,7 @@ void LoginHandler::connect() const bool LoginHandler::isConnected() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return false; return Ea::LoginRecv::mVersionResponse && @@ -73,8 +73,11 @@ bool LoginHandler::isConnected() const void LoginHandler::disconnect() const { - if (Network::mInstance && Network::mInstance->getServer() == mServer) + if (Network::mInstance != nullptr && + Network::mInstance->getServer() == mServer) + { Network::mInstance->disconnect(); + } } void LoginHandler::changePassword(const std::string &restrict oldPassword, diff --git a/src/net/tmwa/loginrecv.cpp b/src/net/tmwa/loginrecv.cpp index 050bd68c1..05b4aaba3 100644 --- a/src/net/tmwa/loginrecv.cpp +++ b/src/net/tmwa/loginrecv.cpp @@ -62,21 +62,24 @@ void LoginRecv::processServerVersion(Net::MessageIn &msg) if (b1 == 255) { // old TMWA const unsigned int options = msg.readInt32("options"); - Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION; + Ea::LoginRecv::mRegistrationEnabled = + ((options & FLAG_REGISTRATION) != 0u); serverVersion = 0; tmwServerVersion = 0; } else if (b1 >= 0x0d) { // new TMWA const unsigned int options = msg.readInt32("options"); - Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION; + Ea::LoginRecv::mRegistrationEnabled = + ((options & FLAG_REGISTRATION) != 0u); serverVersion = 0; tmwServerVersion = (b1 << 16) | (b2 << 8) | b3; } else { // eAthena const unsigned int options = msg.readInt32("options"); - Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION; + Ea::LoginRecv::mRegistrationEnabled = + ((options & FLAG_REGISTRATION) != 0u); serverVersion = 0; tmwServerVersion = 0; } diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index c3b9d45d3..30ec6e8ec 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -132,7 +132,7 @@ void Network::dispatchMessages() if (msgId < messagesSize) { const PacketFuncPtr func = mPackets[msgId].func; - if (func) + if (func != nullptr) func(msg); else logger->log("Unhandled packet: %u 0x%x", msgId, msgId); diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 898e9fff4..0c0b13116 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -52,7 +52,7 @@ NpcHandler::NpcHandler() : void NpcHandler::talk(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_NPC_TALK); outMsg.writeBeingId(being->getId(), "npc id"); @@ -74,7 +74,7 @@ void NpcHandler::closeDialog(const BeingId npcId) if (it != NpcDialog::mNpcDialogs.end()) { NpcDialog *const dialog = (*it).second; - if (dialog) + if (dialog != nullptr) dialog->close(); if (dialog == Ea::NpcRecv::mDialog) Ea::NpcRecv::mDialog = nullptr; @@ -110,7 +110,7 @@ void NpcHandler::stringInput(const BeingId npcId, void NpcHandler::buy(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_NPC_BUY_SELL_REQUEST); outMsg.writeBeingId(being->getId(), "npc id"); @@ -223,7 +223,7 @@ BeingId NpcHandler::getNpc(Net::MessageIn &msg, { CREATEWIDGETV(Ea::NpcRecv::mDialog, NpcDialog, npcId); Ea::NpcRecv::mDialog->saveCamera(); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->stopWalking(false); NpcDialog::mNpcDialogs[npcId] = Ea::NpcRecv::mDialog; } @@ -231,10 +231,10 @@ BeingId NpcHandler::getNpc(Net::MessageIn &msg, else { NpcDialog *const dialog = diag->second; - if (Ea::NpcRecv::mDialog && Ea::NpcRecv::mDialog != dialog) + if (Ea::NpcRecv::mDialog != nullptr && Ea::NpcRecv::mDialog != dialog) Ea::NpcRecv::mDialog->restoreCamera(); Ea::NpcRecv::mDialog = dialog; - if (Ea::NpcRecv::mDialog) + if (Ea::NpcRecv::mDialog != nullptr) Ea::NpcRecv::mDialog->saveCamera(); } return npcId; diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index ae93238f4..54c808556 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -59,12 +59,12 @@ void PartyHandler::create(const std::string &name) const void PartyHandler::invite(const std::string &name) const { - if (!actorManager) + if (actorManager == nullptr) return; const Being *const being = actorManager->findBeingByName( name, ActorType::Player); - if (being) + if (being != nullptr) { createOutPacket(CMSG_PARTY_INVITE); outMsg.writeBeingId(being->getId(), "account id"); @@ -74,7 +74,7 @@ void PartyHandler::invite(const std::string &name) const void PartyHandler::inviteResponse(const int partyId A_UNUSED, const bool accept) const { - if (localPlayer) + if (localPlayer != nullptr) { createOutPacket(CMSG_PARTY_INVITED); outMsg.writeBeingId(localPlayer->getId(), "account id"); @@ -89,7 +89,7 @@ void PartyHandler::leave() const void PartyHandler::kick(const Being *const being) const { - if (being) + if (being != nullptr) { createOutPacket(CMSG_PARTY_KICK); outMsg.writeBeingId(being->getId(), "account id"); @@ -99,11 +99,11 @@ void PartyHandler::kick(const Being *const being) const void PartyHandler::kick(const std::string &name) const { - if (!Ea::taParty) + if (Ea::taParty == nullptr) return; const PartyMember *const m = Ea::taParty->getMember(name); - if (!m) + if (m == nullptr) { NotifyManager::notify(NotifyTypes::PARTY_USER_NOT_IN_PARTY, name); return; diff --git a/src/net/tmwa/partyrecv.cpp b/src/net/tmwa/partyrecv.cpp index a54e35cc0..78c012652 100644 --- a/src/net/tmwa/partyrecv.cpp +++ b/src/net/tmwa/partyrecv.cpp @@ -45,9 +45,9 @@ namespace TmwAthena void PartyRecv::processPartySettings(Net::MessageIn &msg) { - if (!partyTab) + if (partyTab == nullptr) { - if (!chatWindow) + if (chatWindow == nullptr) return; Ea::PartyRecv::createTab(); @@ -67,12 +67,12 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg) bool isOldParty = false; std::set<std::string> names; std::set<std::string> onlineNames; - if (!Ea::taParty) + if (Ea::taParty == nullptr) { logger->log1("error: party empty in SMSG_PARTY_INFO"); Ea::taParty = Party::getParty(1); } - if (Ea::taParty) + if (Ea::taParty != nullptr) { if (Ea::taParty->getNumberOfElements() > 1) { @@ -84,23 +84,23 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg) if ((*it)->getOnline()) onlineNames.insert((*it)->getName()); } - if (localPlayer) + if (localPlayer != nullptr) onlineNames.insert(localPlayer->getName()); } } - if (!localPlayer) + if (localPlayer == nullptr) logger->log1("error: localPlayer==0 in SMSG_PARTY_INFO"); - if (Ea::taParty) + if (Ea::taParty != nullptr) Ea::taParty->clearMembers(); const int length = msg.readInt16("len"); - if (Ea::taParty) + if (Ea::taParty != nullptr) Ea::taParty->setName(msg.readString(24, "party name")); const int count = (length - 28) / 46; - if (localPlayer && Ea::taParty) + if ((localPlayer != nullptr) && (Ea::taParty != nullptr)) { localPlayer->setParty(Ea::taParty); localPlayer->setPartyName(Ea::taParty->getName()); @@ -114,7 +114,7 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg) const bool leader = msg.readUInt8("leader") == 0U; const bool online = msg.readUInt8("online") == 0U; - if (Ea::taParty) + if (Ea::taParty != nullptr) { bool joined(false); @@ -128,9 +128,9 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg) } } PartyMember *const member = Ea::taParty->addMember(id, nick); - if (member) + if (member != nullptr) { - if (!joined && partyTab) + if (!joined && (partyTab != nullptr)) { if (!names.empty() && ((onlineNames.find(nick) == onlineNames.end() && online) @@ -154,14 +154,14 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg) } } - if (Ea::taParty) + if (Ea::taParty != nullptr) Ea::taParty->sort(); - if (localPlayer && Ea::taParty) + if ((localPlayer != nullptr) && (Ea::taParty != nullptr)) { localPlayer->setParty(Ea::taParty); localPlayer->setPartyName(Ea::taParty->getName()); - if (socialWindow) + if (socialWindow != nullptr) socialWindow->updateParty(); } } @@ -175,10 +175,10 @@ void PartyRecv::processPartyMessage(Net::MessageIn &msg) const BeingId id = msg.readBeingId("id"); const std::string chatMsg = msg.readString(msgLength, "message"); - if (Ea::taParty && partyTab) + if ((Ea::taParty != nullptr) && (partyTab != nullptr)) { const PartyMember *const member = Ea::taParty->getMember(id); - if (member) + if (member != nullptr) { partyTab->chatLog(member->getName(), chatMsg); } @@ -192,7 +192,7 @@ void PartyRecv::processPartyMessage(Net::MessageIn &msg) void PartyRecv::processPartyInviteResponse(Net::MessageIn &msg) { - if (!partyTab) + if (partyTab == nullptr) return; const std::string nick = msg.readString(24, "nick"); @@ -225,17 +225,17 @@ void PartyRecv::processPartyInvited(Net::MessageIn &msg) const std::string partyName = msg.readString(24, "party name"); std::string nick; - if (actorManager) + if (actorManager != nullptr) { const Being *const being = actorManager->findBeing(id); - if (being) + if (being != nullptr) { if (being->getType() == ActorType::Player) nick = being->getName(); } } - if (socialWindow) + if (socialWindow != nullptr) socialWindow->showPartyInvite(partyName, nick, 0); } @@ -243,9 +243,9 @@ void PartyRecv::processPartyMove(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("id"); PartyMember *m = nullptr; - if (Ea::taParty) + if (Ea::taParty != nullptr) m = Ea::taParty->getMember(id); - if (m) + if (m != nullptr) { msg.readInt32("unused"); m->setX(msg.readInt16("x")); @@ -276,9 +276,9 @@ void PartyRecv::processPartyUpdateHp(Net::MessageIn &msg) const int hp = msg.readInt16("hp"); const int maxhp = msg.readInt16("max hp"); PartyMember *m = nullptr; - if (Ea::taParty) + if (Ea::taParty != nullptr) m = Ea::taParty->getMember(id); - if (m) + if (m != nullptr) { m->setHp(hp); m->setMaxHp(maxhp); @@ -286,7 +286,7 @@ void PartyRecv::processPartyUpdateHp(Net::MessageIn &msg) // The server only sends this when the member is in range, so // lets make sure they get the party hilight. - if (actorManager && Ea::taParty) + if ((actorManager != nullptr) && (Ea::taParty != nullptr)) { if (Being *const b = actorManager->findBeing(id)) b->setParty(Ea::taParty); diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index d9ec46fe3..66bd1a037 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -99,14 +99,14 @@ void PlayerHandler::increaseSkill(const uint16_t skillId) const void PlayerHandler::pickUp(const FloorItem *const floorItem) const { - if (!floorItem) + if (floorItem == nullptr) return; createOutPacket(CMSG_ITEM_PICKUP); outMsg.writeBeingId(floorItem->getId(), "object id"); TmwAthena::InventoryHandler *const handler = static_cast<TmwAthena::InventoryHandler*>(inventoryHandler); - if (handler) + if (handler != nullptr) handler->pushPickup(floorItem->getId()); } @@ -245,11 +245,11 @@ void PlayerHandler::setStat(Net::MessageIn &msg, break; case Sp::HP: PlayerInfo::setAttribute(Attributes::PLAYER_HP, base); - if (localPlayer->isInParty() && Party::getParty(1)) + if (localPlayer->isInParty() && (Party::getParty(1) != nullptr)) { PartyMember *const m = Party::getParty(1) ->getMember(localPlayer->getId()); - if (m) + if (m != nullptr) { m->setHp(base); m->setMaxHp(PlayerInfo::getAttribute( @@ -260,11 +260,11 @@ void PlayerHandler::setStat(Net::MessageIn &msg, case Sp::MAXHP: PlayerInfo::setAttribute(Attributes::PLAYER_MAX_HP, base); - if (localPlayer->isInParty() && Party::getParty(1)) + if (localPlayer->isInParty() && (Party::getParty(1) != nullptr)) { PartyMember *const m = Party::getParty(1)->getMember( localPlayer->getId()); - if (m) + if (m != nullptr) { m->setHp(PlayerInfo::getAttribute(Attributes::PLAYER_HP)); m->setMaxHp(base); @@ -282,7 +282,7 @@ void PlayerHandler::setStat(Net::MessageIn &msg, break; case Sp::BASELEVEL: PlayerInfo::setAttribute(Attributes::PLAYER_LEVEL, base); - if (localPlayer) + if (localPlayer != nullptr) { localPlayer->setLevel(base); localPlayer->updateName(); @@ -290,7 +290,7 @@ void PlayerHandler::setStat(Net::MessageIn &msg, break; case Sp::SKILLPOINT: PlayerInfo::setAttribute(Attributes::PLAYER_SKILL_POINTS, base); - if (skillDialog) + if (skillDialog != nullptr) skillDialog->update(); break; case Sp::STR: diff --git a/src/net/tmwa/playerrecv.cpp b/src/net/tmwa/playerrecv.cpp index 20a1d0d9f..b6b23403f 100644 --- a/src/net/tmwa/playerrecv.cpp +++ b/src/net/tmwa/playerrecv.cpp @@ -42,7 +42,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) unsigned int val = msg.readUInt8("str"); PlayerInfo::setStatBase(Attributes::PLAYER_STR, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_STR, msg.readUInt8("str cost")); @@ -54,7 +54,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) val = msg.readUInt8("agi"); PlayerInfo::setStatBase(Attributes::PLAYER_AGI, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_AGI, msg.readUInt8("agi cost")); @@ -66,7 +66,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) val = msg.readUInt8("vit"); PlayerInfo::setStatBase(Attributes::PLAYER_VIT, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_VIT, msg.readUInt8("vit cost")); @@ -78,7 +78,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) val = msg.readUInt8("int"); PlayerInfo::setStatBase(Attributes::PLAYER_INT, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_INT, msg.readUInt8("int cost")); @@ -90,7 +90,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) val = msg.readUInt8("dex"); PlayerInfo::setStatBase(Attributes::PLAYER_DEX, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_DEX, msg.readUInt8("dex cost")); @@ -102,7 +102,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) val = msg.readUInt8("luk"); PlayerInfo::setStatBase(Attributes::PLAYER_LUK, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_LUK, msg.readUInt8("luk cost")); @@ -157,7 +157,7 @@ void PlayerRecv::processWalkResponse(Net::MessageIn &msg) msg.readInt32("tick"); msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path"); msg.readUInt8("unused"); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->setRealPos(dstX, dstY); BLOCK_END("PlayerRecv::processWalkResponse") } diff --git a/src/net/tmwa/questrecv.cpp b/src/net/tmwa/questrecv.cpp index 7f732514c..d38012a69 100644 --- a/src/net/tmwa/questrecv.cpp +++ b/src/net/tmwa/questrecv.cpp @@ -36,12 +36,12 @@ void QuestRecv::processSetQuestVar(Net::MessageIn &msg) { const int var = msg.readInt16("variable"); const int val = msg.readInt32("value"); - if (questsWindow) + if (questsWindow != nullptr) { questsWindow->updateQuest(var, val, 0, 0, 0); questsWindow->rebuild(true); } - if (skillDialog) + if (skillDialog != nullptr) { skillDialog->updateQuest(var, val, 0, 0, 0); skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID); @@ -55,12 +55,12 @@ void QuestRecv::processPlayerQuests(Net::MessageIn &msg) { const int var = msg.readInt16("variable"); const int val = msg.readInt32("value"); - if (questsWindow) + if (questsWindow != nullptr) questsWindow->updateQuest(var, val, 0, 0, 0); - if (skillDialog) + if (skillDialog != nullptr) skillDialog->updateQuest(var, val, 0, 0, 0); } - if (questsWindow) + if (questsWindow != nullptr) questsWindow->rebuild(false); } diff --git a/src/net/tmwa/skillrecv.cpp b/src/net/tmwa/skillrecv.cpp index 546a94b2c..faea79059 100644 --- a/src/net/tmwa/skillrecv.cpp +++ b/src/net/tmwa/skillrecv.cpp @@ -60,10 +60,10 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg) msg.skip(24, "unused"); const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable); const int oldLevel = PlayerInfo::getSkillLevel(skillId); - if (oldLevel && oldLevel != level) + if ((oldLevel != 0) && oldLevel != level) updateSkill = skillId; PlayerInfo::setSkillLevel(skillId, level); - if (skillDialog) + if (skillDialog != nullptr) { if (!skillDialog->updateSkill(skillId, range, up, inf, sp)) { @@ -72,10 +72,10 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg) } } } - if (skillDialog) + if (skillDialog != nullptr) { skillDialog->update(); - if (updateSkill) + if (updateSkill != 0) skillDialog->playUpdateEffect(updateSkill); } } @@ -99,7 +99,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) if (success == CAST_S32(SKILL_FAILED) && skillId == CAST_S32(SKILL_BASIC)) { - if (localPlayer && + if ((localPlayer != nullptr) && bskill == CAST_S32(BSKILL_EMOTE) && reason == CAST_S32(RFAIL_SKILLDEP)) { diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index 4310d4c4a..28ecb15df 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -48,7 +48,7 @@ TradeHandler::TradeHandler() : void TradeHandler::request(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_TRADE_REQUEST); @@ -66,7 +66,7 @@ void TradeHandler::respond(const bool accept) const void TradeHandler::addItem(const Item *const item, const int amount) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST); diff --git a/src/net/tmwa/traderecv.cpp b/src/net/tmwa/traderecv.cpp index a8233ef50..f846de3c0 100644 --- a/src/net/tmwa/traderecv.cpp +++ b/src/net/tmwa/traderecv.cpp @@ -68,7 +68,7 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) for (int f = 0; f < maxCards; f++) cards[f] = msg.readUInt16("card"); - if (tradeWindow) + if (tradeWindow != nullptr) { if (type == 0) { @@ -98,12 +98,12 @@ void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg) // Trade: New Item add response (was 0x00ea, now 01b1) const int index = msg.readInt16("index") - INVENTORY_OFFSET; Item *item = nullptr; - if (PlayerInfo::getInventory()) + if (PlayerInfo::getInventory() != nullptr) item = PlayerInfo::getInventory()->getItem(index); - if (!item) + if (item == nullptr) { - if (tradeWindow) + if (tradeWindow != nullptr) tradeWindow->receivedOk(true); return; } @@ -114,7 +114,7 @@ void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg) { case 0: // Successfully added item - if (tradeWindow) + if (tradeWindow != nullptr) { tradeWindow->addItem2(item->getId(), item->getType(), diff --git a/src/net/tmwa/updateprotocol.cpp b/src/net/tmwa/updateprotocol.cpp index cbf514c94..3928cc101 100644 --- a/src/net/tmwa/updateprotocol.cpp +++ b/src/net/tmwa/updateprotocol.cpp @@ -35,7 +35,7 @@ void updateProtocol() #include "net/tmwa/packetsout.inc" #undef packet Network *const network = Network::mInstance; - if (network) + if (network != nullptr) { network->clearHandlers(); network->registerHandlers(); |