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/eathena | |
parent | f1518dd8476c968a43fa57cfb06198e290a4f77a (diff) | |
download | manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2 manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip |
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/net/eathena')
47 files changed, 479 insertions, 475 deletions
diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp index e063f2f01..ac15da627 100644 --- a/src/net/eathena/adminhandler.cpp +++ b/src/net/eathena/adminhandler.cpp @@ -112,7 +112,7 @@ void AdminHandler::mute(const Being *const being, const int type, const int limit) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_ADMIN_MUTE); @@ -129,7 +129,7 @@ void AdminHandler::muteName(const std::string &name) const void AdminHandler::requestLogin(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_ADMIN_ID_TO_LOGIN); @@ -147,7 +147,7 @@ void AdminHandler::setTileType(const int x, const int y, void AdminHandler::unequipAll(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_ADMIN_UNEQUIP_ALL); diff --git a/src/net/eathena/auctionhandler.cpp b/src/net/eathena/auctionhandler.cpp index 3ccdfa7c1..84b7c6b0d 100644 --- a/src/net/eathena/auctionhandler.cpp +++ b/src/net/eathena/auctionhandler.cpp @@ -48,7 +48,7 @@ void AuctionHandler::cancelReg() const void AuctionHandler::setItem(const Item *const item, const int amount) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_AUCTION_SET_ITEM); outMsg.writeInt16(CAST_S16( diff --git a/src/net/eathena/bankrecv.cpp b/src/net/eathena/bankrecv.cpp index 0ac21e871..9f566d5a4 100644 --- a/src/net/eathena/bankrecv.cpp +++ b/src/net/eathena/bankrecv.cpp @@ -46,7 +46,7 @@ void BankRecv::processBankDeposit(Net::MessageIn &msg) const int money = CAST_S32(msg.readInt64("money")); msg.readInt32("balance"); BankListener::distributeEvent(money); - if (reason) + if (reason != 0) NotifyManager::notify(NotifyTypes::BANK_DEPOSIT_FAILED); } @@ -56,7 +56,7 @@ void BankRecv::processBankWithdraw(Net::MessageIn &msg) const int money = CAST_S32(msg.readInt64("money")); msg.readInt32("balance"); BankListener::distributeEvent(money); - if (reason) + if (reason != 0) NotifyManager::notify(NotifyTypes::BANK_WITHDRAW_FAILED); } diff --git a/src/net/eathena/battlegroundrecv.cpp b/src/net/eathena/battlegroundrecv.cpp index 61ed702fa..2aaab9294 100644 --- a/src/net/eathena/battlegroundrecv.cpp +++ b/src/net/eathena/battlegroundrecv.cpp @@ -48,7 +48,7 @@ void BattleGroundRecv::processBattleEmblem2(Net::MessageIn &msg) const int teamId = msg.readInt16("team id"); Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setTeamId(CAST_U16(teamId)); } diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 79e37e1cf..632485e7d 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -54,7 +54,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); @@ -84,7 +84,7 @@ void BeingHandler::requestRanks(const RankT rank) const void BeingHandler::viewPlayerEquipment(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_PLAYER_VIEW_EQUIPMENT); diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp index 1e9e56661..41fe73f39 100644 --- a/src/net/eathena/beingrecv.cpp +++ b/src/net/eathena/beingrecv.cpp @@ -72,7 +72,7 @@ namespace EAthena void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg) { - if (!actorManager) + if (actorManager == nullptr) return; Being *const dstBeing = actorManager->findBeing( @@ -84,7 +84,7 @@ void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg) if (type != 2) id2 = 1; - if (!localPlayer || !dstBeing) + if ((localPlayer == nullptr) || (dstBeing == nullptr)) return; processBeingChangeLookContinue(msg, dstBeing, type, id, id2, nullptr); @@ -95,7 +95,7 @@ void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg) Being *dstBeing = nullptr; int cards[maxCards]; - if (!actorManager) + if (actorManager == nullptr) { // here can be look from char server Net::Characters &chars = Net::CharServerHandler::mCharacters; const BeingId id = msg.readBeingId("being id"); @@ -103,7 +103,8 @@ void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg) FOR_EACH (Net::Characters::iterator, it, chars) { const Net::Character *const character = *it; - if (character->dummy && character->dummy->getId() == id) + if (character->dummy != nullptr && + character->dummy->getId() == id) { dstBeing = character->dummy; break; @@ -126,7 +127,7 @@ void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg) for (int f = 0; f < maxCards; f ++) cards[f] = msg.readUInt16("card"); - if (!dstBeing) + if (dstBeing == nullptr) return; processBeingChangeLookContinue(msg, dstBeing, type, id, id2, &cards[0]); @@ -163,21 +164,21 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg, dstBeing->setWeaponId(id); dstBeing->setSpriteId(SPRITE_FLOOR, id2); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR); break; case 3: // LOOK_HEAD_BOTTOM dstBeing->setSpriteCards(SPRITE_WEAPON, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_WEAPON); break; case 4: // LOOK_HEAD_TOP Change upper headgear for eAthena, hat for us dstBeing->setSpriteCards(SPRITE_CLOTHES_COLOR, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_CLOTHES_COLOR); break; case 5: // LOOK_HEAD_MID Change middle headgear for eathena, @@ -185,7 +186,7 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg, dstBeing->setSpriteCards(SPRITE_HEAD_BOTTOM, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_BOTTOM); break; case 6: // eAthena LOOK_HAIR_COLOR @@ -202,84 +203,84 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg, dstBeing->setSpriteCards(SPRITE_FLOOR, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR); break; case 9: // eAthena LOOK_SHOES dstBeing->setSpriteCards(SPRITE_HAIR, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_HAIR); break; case 10: // LOOK_GLOVES dstBeing->setSpriteCards(SPRITE_SHOES, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_SHOES); break; case 11: // LOOK_FLOOR dstBeing->setSpriteCards(SPRITE_SHIELD, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD); break; case 12: // LOOK_ROBE dstBeing->setSpriteCards(SPRITE_HEAD_TOP, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_TOP); break; case 13: // COSTUME_HEAD_TOP dstBeing->setSpriteCards(SPRITE_HEAD_MID, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_MID); break; case 14: // COSTUME_HEAD_MID dstBeing->setSpriteCards(SPRITE_ROBE, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_ROBE); break; case 15: // COSTUME_HEAD_LOW dstBeing->setSpriteCards(SPRITE_EVOL2, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2); break; case 16: // COSTUME_GARMENT dstBeing->setSpriteCards(SPRITE_EVOL3, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL3); break; case 17: // ARMOR dstBeing->setSpriteCards(SPRITE_EVOL4, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL4); break; case 18: dstBeing->setSpriteCards(SPRITE_EVOL5, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL5); break; case 19: dstBeing->setSpriteCards(SPRITE_EVOL6, id, CardsList(cards)); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL6); break; default: @@ -290,7 +291,7 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg, void BeingRecv::processBeingVisible(Net::MessageIn &msg) { - if (!actorManager) + if (actorManager == nullptr) return; // need set type based on id @@ -326,7 +327,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); @@ -334,13 +335,13 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) dstBeing = nullptr; } - if (!dstBeing) + if (dstBeing == nullptr) { if (actorManager->isBlocked(id) == true) return; dstBeing = createBeing2(msg, id, job, type); - if (!dstBeing) + if (dstBeing == nullptr) return; } else @@ -370,7 +371,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) dstBeing->setWalkSpeed(speed); dstBeing->setSubtype(fromInt(job, BeingTypeId), 0); - if (dstBeing->getType() == ActorType::Monster && localPlayer) + if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr)) localPlayer->checkNewName(dstBeing); const int hairStyle = msg.readInt16("hair style"); @@ -461,7 +462,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) applyPlayerAction(msg, dstBeing, msg.readUInt8("action type")); 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) @@ -478,7 +479,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) dstBeing->setDirection(dir); const int level = CAST_S32(msg.readInt16("level")); - if (level) + if (level != 0) dstBeing->setLevel(level); if (msg.getVersion() >= 20080102) msg.readInt16("font"); @@ -521,7 +522,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) void BeingRecv::processBeingMove(Net::MessageIn &msg) { - if (!actorManager) + if (actorManager == nullptr) return; if (msg.getVersion() >= 20091103) @@ -561,7 +562,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); @@ -569,13 +570,13 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) dstBeing = nullptr; } - if (!dstBeing) + if (dstBeing == nullptr) { if (actorManager->isBlocked(id) == true) return; dstBeing = createBeing2(msg, id, job, type); - if (!dstBeing) + if (dstBeing == nullptr) return; } else @@ -597,7 +598,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) dstBeing->setWalkSpeed(speed); dstBeing->setSubtype(fromInt(job, BeingTypeId), 0); - if (dstBeing->getType() == ActorType::Monster && localPlayer) + if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr)) localPlayer->checkNewName(dstBeing); const int hairStyle = msg.readInt16("hair style"); @@ -689,7 +690,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) msg.readInt8("ys"); dstBeing->setAction(BeingAction::STAND, 0); dstBeing->setTileCoords(srcX, srcY); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY); if (serverFeatures->haveMove3()) dstBeing->setCachedDestination(dstX, dstY); @@ -714,11 +715,11 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) { d = dstBeing->calcDirection(dstX, dstY); } - if (d && dstBeing->getDirection() != d) + if ((d != 0u) && dstBeing->getDirection() != d) dstBeing->setDirection(d); const int level = CAST_S32(msg.readInt16("level")); - if (level) + if (level != 0) dstBeing->setLevel(level); if (msg.getVersion() >= 20080102) msg.readInt16("font"); @@ -759,7 +760,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) void BeingRecv::processBeingSpawn(Net::MessageIn &msg) { - if (!actorManager) + if (actorManager == nullptr) return; // need get type from id @@ -792,7 +793,7 @@ void BeingRecv::processBeingSpawn(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); @@ -800,13 +801,13 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg) dstBeing = nullptr; } - if (!dstBeing) + if (dstBeing == nullptr) { if (actorManager->isBlocked(id) == true) return; dstBeing = createBeing2(msg, id, job, type); - if (!dstBeing) + if (dstBeing == nullptr) return; } else @@ -828,7 +829,7 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg) dstBeing->setWalkSpeed(speed); dstBeing->setSubtype(fromInt(job, BeingTypeId), 0); - if (dstBeing->getType() == ActorType::Monster && localPlayer) + if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr)) localPlayer->checkNewName(dstBeing); const int hairStyle = msg.readInt16("hair style"); @@ -916,7 +917,7 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg) msg.readInt8("ys"); 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) @@ -933,7 +934,7 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg) dstBeing->setDirection(dir); const int level = CAST_S32(msg.readInt16("level")); - if (level) + if (level != 0) dstBeing->setLevel(level); if (msg.getVersion() >= 20080102) msg.readInt16("font"); @@ -982,10 +983,10 @@ void BeingRecv::processMapTypeProperty(Net::MessageIn &msg) MapTypeProperty2 props; props.data = CAST_U32(flags); const Game *const game = Game::instance(); - if (!game) + if (game == nullptr) return; Map *const map = game->getCurrentMap(); - if (!map) + if (map == nullptr) return; map->setPvpMode(props.bits.party | (props.bits.guild * 2)); } @@ -1058,7 +1059,7 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg, const SkillType2::SkillType2 inf2, const int castTime) { - if (!effectManager) + if (effectManager == nullptr) return; if (srcId == BeingId_zero) @@ -1070,10 +1071,10 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg, if (dstId != BeingId_zero) { // being to being Being *const dstBeing = actorManager->findBeing(dstId); - if (srcBeing) + if (srcBeing != nullptr) { srcBeing->handleSkillCasting(dstBeing, skillId, skillLevel); - if (dstBeing) + if (dstBeing != nullptr) { srcBeing->addCast(dstBeing->getTileX(), dstBeing->getTileY(), @@ -1086,13 +1087,13 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg, } else if (dstX != 0 || dstY != 0) { // being to position - if (srcBeing) + if (srcBeing != nullptr) srcBeing->setAction(BeingAction::CAST, skillId); skillDialog->playCastingDstTileEffect(skillId, skillLevel, dstX, dstY, castTime); - if (srcBeing) + if (srcBeing != nullptr) { srcBeing->addCast(dstX, dstY, skillId, @@ -1101,7 +1102,7 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg, castTime / MILLISECONDS_IN_A_TICK); } } - if (localPlayer && + if ((localPlayer != nullptr) && srcBeing == localPlayer && (inf2 & SkillType2::FreeCastAny) == 0) { @@ -1112,7 +1113,7 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg, void BeingRecv::processBeingStatusChange(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingStatusChange") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingStatusChange") return; @@ -1137,7 +1138,7 @@ void BeingRecv::processBeingStatusChange(Net::MessageIn &msg) IsStart_false : IsStart_true; Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setStatusEffect(status, flag, start); BLOCK_END("BeingRecv::processBeingStatusChange") } @@ -1145,7 +1146,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; @@ -1170,14 +1171,14 @@ 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; } dstBeing->setTileCoords(srcX, srcY); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY); if (serverFeatures->haveMove3()) dstBeing->setCachedDestination(dstX, dstY); @@ -1191,7 +1192,7 @@ void BeingRecv::processBeingMove2(Net::MessageIn &msg) void BeingRecv::processBeingAction2(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingAction2") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingAction2") return; @@ -1231,16 +1232,16 @@ void BeingRecv::processBeingAction2(Net::MessageIn &msg) case AttackType::SPLASH: case AttackType::SKILL: case AttackType::REPEATE: - if (srcBeing) + if (srcBeing != nullptr) { - if (srcSpeed && srcBeing->getType() == ActorType::Player) + if (srcSpeed != 0 && srcBeing->getType() == ActorType::Player) srcBeing->setAttackDelay(srcSpeed); // attackid=1, type srcBeing->handleAttack(dstBeing, param1, 1); if (srcBeing->getType() == ActorType::Player) srcBeing->setAttackTime(); } - if (dstBeing) + if (dstBeing != nullptr) { // level not present, using 1 dstBeing->takeDamage(srcBeing, param1, @@ -1255,26 +1256,26 @@ void BeingRecv::processBeingAction2(Net::MessageIn &msg) break; case AttackType::SIT: - if (srcBeing) + if (srcBeing != nullptr) { srcBeing->setAction(BeingAction::SIT, 0); if (srcBeing->getType() == ActorType::Player) { srcBeing->setMoveTime(); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateAction(srcBeing, BeingAction::SIT); } } break; case AttackType::STAND: - if (srcBeing) + if (srcBeing != nullptr) { srcBeing->setAction(BeingAction::STAND, 0); if (srcBeing->getType() == ActorType::Player) { srcBeing->setMoveTime(); - if (localPlayer) + if (localPlayer != nullptr) { localPlayer->imitateAction(srcBeing, BeingAction::STAND); @@ -1307,7 +1308,7 @@ void BeingRecv::processBeingHp(Net::MessageIn &msg) hp = msg.readInt16("hp"); maxHP = msg.readInt16("max hp"); } - if (dstBeing) + if (dstBeing != nullptr) { dstBeing->setHP(hp); dstBeing->setMaxHP(maxHP); @@ -1320,7 +1321,7 @@ void BeingRecv::processMonsterHp(Net::MessageIn &msg) msg.readBeingId("monster id")); const int hp = msg.readInt32("hp"); const int maxHP = msg.readInt32("max hp"); - if (dstBeing) + if (dstBeing != nullptr) { dstBeing->setHP(hp); dstBeing->setMaxHP(maxHP); @@ -1338,7 +1339,7 @@ void BeingRecv::processSkillAutoCast(Net::MessageIn &msg) msg.readString(24, "skill name"); msg.readInt8("unused"); - if (localPlayer) + if (localPlayer != nullptr) { localPlayer->handleSkill(localPlayer, 0, id, level); localPlayer->takeDamage(localPlayer, 0, AttackType::SKILL, id, level); @@ -1400,7 +1401,7 @@ void BeingRecv::processPkRanksList(Net::MessageIn &msg) void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingChangeDirection") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingChangeDirection") return; @@ -1414,26 +1415,26 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg) const uint8_t dir = Net::MessageIn::fromServerDirection( CAST_U8(msg.readUInt8("player direction") & 0x0FU)); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processBeingChangeDirection") return; } dstBeing->setDirection(dir); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateDirection(dstBeing, dir); BLOCK_END("BeingRecv::processBeingChangeDirection") } void BeingRecv::processBeingSpecialEffect(Net::MessageIn &msg) { - if (!effectManager || !actorManager) + if ((effectManager == nullptr) || (actorManager == nullptr)) return; const BeingId id = msg.readBeingId("being id"); Being *const being = actorManager->findBeing(id); - if (!being) + if (being == nullptr) return; const int effectType = msg.readInt32("effect type"); @@ -1443,7 +1444,7 @@ void BeingRecv::processBeingSpecialEffect(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()); } @@ -1501,7 +1502,7 @@ void BeingRecv::processSkillEntry(Net::MessageIn &msg) id, job, BeingType::SKILL); - if (!dstBeing) + if (dstBeing == nullptr) return; dstBeing->setAction(BeingAction::STAND, 0); dstBeing->setTileCoords(x, y); @@ -1512,7 +1513,7 @@ void BeingRecv::processSkillEntry(Net::MessageIn &msg) void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerStop") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processPlayerStop") return; @@ -1521,7 +1522,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) return; const uint32_t opt1 = msg.readInt16("opt1"); @@ -1541,14 +1542,14 @@ void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg) void BeingRecv::processPlayerStatusChange2(Net::MessageIn &msg) { - if (!actorManager) + if (actorManager == nullptr) return; // look like this function unused on server const BeingId id = msg.readBeingId("account id"); Being *const dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) return; const uint32_t option = msg.readInt32("option"); @@ -1560,7 +1561,7 @@ void BeingRecv::processPlayerStatusChange2(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; @@ -1571,7 +1572,7 @@ void BeingRecv::processBeingResurrect(Net::MessageIn &msg) const BeingId id = msg.readBeingId("being id"); msg.readInt16("unused"); Being *const dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { DEBUGLOGSTR("insible player?"); BLOCK_END("BeingRecv::processBeingResurrect") @@ -1589,7 +1590,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; @@ -1599,7 +1600,7 @@ void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg) const std::string name = msg.readString(24, "char name"); actorManager->updateNameId(name, beingId); Being *const dstBeing = actorManager->findBeing(beingId); - if (dstBeing) + if (dstBeing != nullptr) { if (beingId == localPlayer->getId()) { @@ -1623,10 +1624,10 @@ void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg) void BeingRecv::processBeingRemoveSkill(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("skill unit id"); - if (!actorManager) + if (actorManager == nullptr) return; Being *const dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) return; actorManager->destroy(dstBeing); } @@ -1659,7 +1660,7 @@ void BeingRecv::processBeingFakeName(Net::MessageIn &msg) msg.skip(3, "unused"); Being *const dstBeing = createBeing2(msg, id, job, type); - if (!dstBeing) + if (dstBeing == nullptr) return; dstBeing->setSubtype(fromInt(job, BeingTypeId), 0); dstBeing->setTileCoords(x, y); @@ -1673,7 +1674,7 @@ void BeingRecv::processBeingStatUpdate1(Net::MessageIn &msg) const int value = msg.readInt32("value"); Being *const dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) return; if (type != Sp::MANNER) @@ -1687,7 +1688,7 @@ void BeingRecv::processBeingStatUpdate1(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; @@ -1695,7 +1696,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"); @@ -1718,7 +1719,7 @@ void BeingRecv::processMobInfo(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("monster id")); const int attackRange = msg.readInt32("range"); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setAttackRange(attackRange); } @@ -1736,9 +1737,9 @@ void BeingRecv::processBeingAttrs(Net::MessageIn &msg) int language = -1; if (serverVersion >= 17) language = msg.readInt16("language"); - if (dstBeing) + if (dstBeing != nullptr) { - if (gmLevel) + if (gmLevel != 0) { if (dstBeing == localPlayer) localPlayer->setGMLevel(gmLevel); @@ -1785,7 +1786,7 @@ void BeingRecv::processSpiritBalls(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("being id")); const int balls = msg.readInt16("spirits amount"); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setSpiritBalls(balls); } @@ -1819,13 +1820,13 @@ void BeingRecv::processBeingSlide(Net::MessageIn &msg) msg.readBeingId("being id")); const int x = msg.readInt16("x"); const int y = msg.readInt16("y"); - if (!dstBeing) + if (dstBeing == nullptr) return; if (localPlayer == dstBeing) { localPlayer->stopAttack(); localPlayer->navigateClean(); - if (viewport) + if (viewport != nullptr) viewport->returnCamera(); } @@ -1929,10 +1930,10 @@ void BeingRecv::processPvpSet(Net::MessageIn &msg) const BeingId id = msg.readBeingId("being id"); const int rank = msg.readInt32("rank"); msg.readInt32("num"); - if (actorManager) + if (actorManager != nullptr) { Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setPvpRank(rank); } BLOCK_END("BeingRecv::processPvpSet") @@ -1941,7 +1942,7 @@ void BeingRecv::processPvpSet(Net::MessageIn &msg) void BeingRecv::processNameResponse2(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processNameResponse2") - if (!actorManager || !localPlayer) + if ((actorManager == nullptr) || (localPlayer == nullptr)) { BLOCK_END("BeingRecv::processNameResponse2") return; @@ -1952,7 +1953,7 @@ void BeingRecv::processNameResponse2(Net::MessageIn &msg) const std::string str = msg.readString(len - 8, "name"); actorManager->updateNameId(str, beingId); Being *const dstBeing = actorManager->findBeing(beingId); - if (dstBeing) + if (dstBeing != nullptr) { if (beingId == localPlayer->getId()) { @@ -1967,15 +1968,15 @@ void BeingRecv::processNameResponse2(Net::MessageIn &msg) if (dstBeing->getType() == ActorType::Player) dstBeing->updateColors(); - if (localPlayer) + if (localPlayer != nullptr) { const Party *const party = localPlayer->getParty(); - if (party && party->isMember(dstBeing->getId())) + if (party != nullptr && party->isMember(dstBeing->getId())) { PartyMember *const member = party->getMember( dstBeing->getId()); - if (member) + if (member != nullptr) member->setName(dstBeing->getName()); } localPlayer->checkNewName(dstBeing); @@ -1990,7 +1991,7 @@ Being *BeingRecv::createBeing2(Net::MessageIn &msg, const int32_t job, const BeingTypeT beingType) { - if (!actorManager) + if (actorManager == nullptr) return nullptr; ActorTypeT type = ActorType::Unknown; @@ -2041,7 +2042,7 @@ Being *BeingRecv::createBeing2(Net::MessageIn &msg, if (beingType == BeingType::MERSOL) { const MercenaryInfo *const info = PlayerInfo::getMercenary(); - if (info && info->id == id) + if ((info != nullptr) && info->id == id) PlayerInfo::setMercenaryBeing(being); } else if (beingType == BeingType::PET) @@ -2061,7 +2062,7 @@ void BeingRecv::processSolveCharName(Net::MessageIn &msg) { const int id = msg.readInt32("char id"); const std::string name = msg.readString(24, "name"); - if (actorManager) + if (actorManager != nullptr) actorManager->addChar(id, name); } @@ -2077,7 +2078,7 @@ void BeingRecv::processGraffiti(Net::MessageIn &msg) const std::string text = msg.readString(80, "text"); Being *const dstBeing = createBeing2(msg, id, job, BeingType::SKILL); - if (!dstBeing) + if (dstBeing == nullptr) return; dstBeing->setAction(BeingAction::STAND, 0); @@ -2090,7 +2091,7 @@ void BeingRecv::processGraffiti(Net::MessageIn &msg) void BeingRecv::processSkillDamage(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processSkillDamage") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processSkillDamage") return; @@ -2112,9 +2113,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") } @@ -2138,7 +2139,7 @@ void BeingRecv::applyPlayerAction(Net::MessageIn &msg, Being *const being, const uint8_t type) { - if (!being) + if (being == nullptr) return; switch (type) { diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp index 0cc551bdf..8bd3392a0 100644 --- a/src/net/eathena/buyingstorehandler.cpp +++ b/src/net/eathena/buyingstorehandler.cpp @@ -53,7 +53,7 @@ void BuyingStoreHandler::create(const std::string &name, createOutPacket(CMSG_BUYINGSTORE_CREATE); outMsg.writeInt16(CAST_S16(89 + items.size() * 8), "len"); outMsg.writeInt32(maxMoney, "limit money"); - outMsg.writeInt8(flag, "flag"); + outMsg.writeInt8(static_cast<int8_t>(flag), "flag"); outMsg.writeString(name, 80, "store name"); FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items) { @@ -74,7 +74,7 @@ void BuyingStoreHandler::close() const void BuyingStoreHandler::open(const Being *const being) const { - if (!being) + if (being == nullptr) return; if (packetVersion < 20100420) return; @@ -87,7 +87,7 @@ void BuyingStoreHandler::sell(const Being *const being, const Item *const item, const int amount) const { - if (!being || !item) + if ((being == nullptr) || (item == nullptr)) return; if (packetVersion < 20100420) return; diff --git a/src/net/eathena/buyingstorerecv.cpp b/src/net/eathena/buyingstorerecv.cpp index 4f9188280..55c1624f9 100644 --- a/src/net/eathena/buyingstorerecv.cpp +++ b/src/net/eathena/buyingstorerecv.cpp @@ -96,7 +96,7 @@ void BuyingStoreRecv::processBuyingStoreShowBoard(Net::MessageIn &msg) const BeingId id = msg.readBeingId("owner id"); const std::string shopName = msg.readString(80, "shop name"); Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setBuyBoard(shopName); } @@ -104,7 +104,7 @@ void BuyingStoreRecv::processBuyingStoreHideBoard(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("owner id"); Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setBuyBoard(std::string()); if (dstBeing == localPlayer) { @@ -122,7 +122,7 @@ void BuyingStoreRecv::processBuyingStoreItemsList(Net::MessageIn &msg) msg.readInt32("money limit"); const Being *const dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) return; SellDialog *const dialog = CREATEWIDGETR(BuyingStoreSellDialog, @@ -138,10 +138,10 @@ void BuyingStoreRecv::processBuyingStoreItemsList(Net::MessageIn &msg) msg.readUInt8("item type")); const int itemId = msg.readInt16("item id"); - if (!inv) + if (inv == nullptr) continue; const Item *const item = inv->findItem(itemId, ItemColor_one); - if (!item) + if (item == nullptr) continue; // +++ need add colors support dialog->addItem(itemId, itemType, ItemColor_one, amount, price); @@ -211,14 +211,14 @@ void BuyingStoreRecv::processBuyingStoreReport(Net::MessageIn &msg) void BuyingStoreRecv::processBuyingStoreDeleteItem(Net::MessageIn &msg) { - 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"); msg.readInt32("price"); - if (inventory) + if (inventory != nullptr) { if (Item *const item = inventory->getItem(index)) { diff --git a/src/net/eathena/buysellrecv.cpp b/src/net/eathena/buysellrecv.cpp index 4b111dee9..db2b6a607 100644 --- a/src/net/eathena/buysellrecv.cpp +++ b/src/net/eathena/buysellrecv.cpp @@ -61,7 +61,7 @@ void BuySellRecv::processNpcBuy(Net::MessageIn &msg) if (npcId != BeingTypeId_zero) { const BeingInfo *const info = NPCDB::get(npcId); - if (info) + if (info != nullptr) currency = info->getCurrency(); else currency = DEFAULT_CURRENCY; diff --git a/src/net/eathena/cashshophandler.cpp b/src/net/eathena/cashshophandler.cpp index 7f3cf6ce8..40e23d3a5 100644 --- a/src/net/eathena/cashshophandler.cpp +++ b/src/net/eathena/cashshophandler.cpp @@ -70,7 +70,7 @@ void CashShopHandler::buyItems(const int points, const ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); const ItemTypeT type = item->getType(); - if (!usedQuantity) + if (usedQuantity == 0) continue; if (type == ItemType::Weapon || type == ItemType::Armor || @@ -96,7 +96,7 @@ void CashShopHandler::buyItems(const int points, { ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); - if (!usedQuantity) + if (usedQuantity == 0) continue; item->increaseQuantity(usedQuantity); item->increaseUsedQuantity(-usedQuantity); diff --git a/src/net/eathena/cashshoprecv.cpp b/src/net/eathena/cashshoprecv.cpp index deafbec28..796d2a211 100644 --- a/src/net/eathena/cashshoprecv.cpp +++ b/src/net/eathena/cashshoprecv.cpp @@ -64,7 +64,7 @@ void CashShopRecv::processCashShopOpen(Net::MessageIn &msg) if (npcId != BeingTypeId_zero) { const BeingInfo *const info = NPCDB::get(npcId); - if (info) + if (info != nullptr) currency = info->getCurrency(); else currency = DEFAULT_CURRENCY; diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp index 098cdf248..22fbe000a 100644 --- a/src/net/eathena/charserverhandler.cpp +++ b/src/net/eathena/charserverhandler.cpp @@ -61,7 +61,7 @@ CharServerHandler::CharServerHandler() : void CharServerHandler::chooseCharacter(Net::Character *const character) const { - if (!character) + if (character == nullptr) return; mSelectedCharacter = character; @@ -140,7 +140,7 @@ void CharServerHandler::newCharacter(const std::string &name, const int slot, void CharServerHandler::deleteCharacter(Net::Character *const character, const std::string &email) const { - if (!character) + if (character == nullptr) return; mSelectedCharacter = character; @@ -165,7 +165,7 @@ void CharServerHandler::connect() const const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken(); - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; Network::mInstance->disconnect(); @@ -186,7 +186,7 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window) { mCharCreateDialog = window; - if (!mCharCreateDialog) + if (mCharCreateDialog == nullptr) return; StringVect attributes; diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp index 90e9618a1..fbeaf7f29 100644 --- a/src/net/eathena/charserverrecv.cpp +++ b/src/net/eathena/charserverrecv.cpp @@ -77,7 +77,7 @@ namespace CharServerRecv void CharServerRecv::readPlayerData(Net::MessageIn &msg, Net::Character *const character) { - if (!character) + if (character == nullptr) return; const Token &token = @@ -202,7 +202,7 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg, if (packetVersion >= 20110928) msg.readInt32("slot change"); if (packetVersion >= 20111025) - tempPlayer->setRename(msg.readInt32("rename (inverse)")); + tempPlayer->setRename(msg.readInt32("rename (inverse)") != 0); uint8_t gender = 99U; if (packetVersion >= 20141016) gender = CAST_U8(msg.readUInt8("gender")); @@ -238,7 +238,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); @@ -290,7 +290,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") @@ -302,7 +302,7 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) ServerInfo &server = mapServer; BLOCK_START("CharServerRecv::processChangeMapServer") const GameHandler *const gh = static_cast<GameHandler*>(gameHandler); - if (!gh || !network) + if ((gh == nullptr) || (network == nullptr)) { BLOCK_END("CharServerRecv::processChangeMapServer") return; @@ -323,7 +323,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); @@ -374,7 +374,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; @@ -384,7 +384,7 @@ void CharServerRecv::processCharCreate(Net::MessageIn &msg) void CharServerRecv::processCharCheckRename(Net::MessageIn &msg) { - if (msg.readInt16("flag")) + if (msg.readInt16("flag") != 0) { createOutPacket(CMSG_CHAR_RENAME); outMsg.writeBeingId(mRenameId, "char id"); @@ -409,7 +409,7 @@ void CharServerRecv::processCharCheckRename(Net::MessageIn &msg) void CharServerRecv::processCharRename(Net::MessageIn &msg) { const int flag = msg.readInt16("flag"); - if (!flag) + if (flag == 0) { charServerHandler->mCharSelectDialog->setName( mRenameId, @@ -539,7 +539,7 @@ void CharServerRecv::processCharCharacters(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); diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index ad779666c..f5f6760f1 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -53,7 +53,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; const std::string mes = std::string(localPlayer->getName()).append( @@ -230,7 +230,7 @@ void ChatHandler::createChatRoom(const std::string &title, void ChatHandler::battleTalk(const std::string &text) const { - if (!localPlayer) + if (localPlayer == nullptr) return; const std::string mes = std::string(localPlayer->getName()).append( @@ -253,7 +253,7 @@ void ChatHandler::battleTalk(const std::string &text) const void ChatHandler::joinChat(const ChatObject *const chat, const std::string &password) const { - if (!chat) + if (chat == nullptr) return; createOutPacket(CMSG_CHAT_ROOM_JOIN); diff --git a/src/net/eathena/chatrecv.cpp b/src/net/eathena/chatrecv.cpp index 524b0a9f3..1aee777e9 100644 --- a/src/net/eathena/chatrecv.cpp +++ b/src/net/eathena/chatrecv.cpp @@ -201,7 +201,7 @@ void ChatRecv::processColorChat(Net::MessageIn &msg) if (findCutFirst(msg2, "You're now in the '#") && findCutLast(msg2, "'")) { const size_t idx = msg2.find("' channel for '"); - if (idx != std::string::npos && chatWindow) + if (idx != std::string::npos && (chatWindow != nullptr)) { chatWindow->addChannelTab(std::string("#").append( msg2.substr(0, idx)), false); @@ -244,7 +244,7 @@ void ChatRecv::processChatContinue(std::string chatMsg, { const std::string channel = extractChannelFromMessage(chatMsg); bool allow(true); - if (chatWindow) + if (chatWindow != nullptr) { allow = chatWindow->resortChatLog(chatMsg, own, @@ -259,9 +259,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, GENERAL_CHANNEL); } BLOCK_END("ChatRecv::processChat") @@ -282,7 +282,7 @@ void ChatRecv::processGmChat(Net::MessageIn &msg) if (!findCutFirst(chatMsg, "ssss")) findCutFirst(chatMsg, "eulb"); - if (chatWindow) + if (chatWindow != nullptr) chatWindow->addGlobalMessage(chatMsg); BLOCK_END("ChatRecv::processChat") } @@ -296,7 +296,7 @@ void ChatRecv::processGmChat2(Net::MessageIn &msg) msg.readInt16("font align"); msg.readInt16("font y"); const std::string chatMsg = msg.readRawString(chatMsgLength, "message"); - if (chatWindow) + if (chatWindow != nullptr) chatWindow->addGlobalMessage(chatMsg); } @@ -327,7 +327,7 @@ void ChatRecv::processWhisperResponse(Net::MessageIn &msg) const uint8_t type = msg.readUInt8("response"); if (msg.getVersion() >= 20131223) msg.readInt32("unknown"); - if (type == 1 && chatWindow) + if (type == 1 && (chatWindow != nullptr)) { const std::string nick = Ea::ChatRecv::getLastWhisperNick(); if (nick.size() > 1 && nick[0] == '#') @@ -369,7 +369,7 @@ void ChatRecv::processChatDisplay(Net::MessageIn &msg) obj->update(); Being *const dstBeing = actorManager->findBeing(obj->ownerId); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setChat(obj); } @@ -387,13 +387,13 @@ void ChatRecv::processChatRoomJoinAck(Net::MessageIn &msg) const ChatObject *const oldChat = ChatObject::findById(id); - if (oldChat) + if (oldChat != nullptr) PlayerInfo::setRoomName(oldChat->title); else PlayerInfo::setRoomName(std::string()); chatWindow->joinRoom(true); ChatObject *const obj = new ChatObject; - if (oldChat) + if (oldChat != nullptr) { obj->ownerId = oldChat->ownerId; obj->chatId = oldChat->chatId; @@ -423,26 +423,26 @@ void ChatRecv::processChatRoomLeave(Net::MessageIn &msg) UNIMPLEMENTEDPACKETFIELD(status); break; } - if (localPlayer && name == localPlayer->getName()) + if ((localPlayer != nullptr) && name == localPlayer->getName()) { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->joinRoom(false); PlayerInfo::setRoomName(std::string()); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->setChat(nullptr); } else { Being *const being = actorManager->findBeingByName( name, ActorType::Player); - if (being) + if (being != nullptr) being->setChat(nullptr); } } void ChatRecv::processJoinChannel(Net::MessageIn &msg) { - if (!chatWindow) + if (chatWindow == nullptr) return; const std::string channel = msg.readString(24, "channel name"); @@ -489,7 +489,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick, if (player_relations.hasPermission(nick, PlayerRelation::WHISPER)) chatWindow->addWhisper(nick, chatMsg); } - else if (localChatTab) + else if (localChatTab != nullptr) { localChatTab->chatLog(chatMsg, ChatMsgType::BY_SERVER); } @@ -498,7 +498,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick, void ChatRecv::processBeingChat(Net::MessageIn &msg) { - if (!actorManager) + if (actorManager == nullptr) return; BLOCK_START("ChatRecv::processBeingChat") @@ -513,14 +513,14 @@ 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); std::string sender_name = ((pos == std::string::npos) ? "" : chatMsg.substr(0, pos)); - if (being && sender_name != being->getName() + if ((being != nullptr) && sender_name != being->getName() && being->getType() == ActorType::Player) { if (!being->getName().empty()) @@ -537,8 +537,8 @@ 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), @@ -548,7 +548,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) TryRemoveColors_true); } - if (allow && being && player_relations.hasPermission(sender_name, + if (allow && (being != nullptr) && player_relations.hasPermission(sender_name, PlayerRelation::SPEECH_FLOAT)) { being->setSpeech(chatMsg, GENERAL_CHANNEL); @@ -632,7 +632,7 @@ void ChatRecv::processChatRoomAddMember(Net::MessageIn &msg) { msg.readInt16("users"); const std::string name = msg.readString(24, "name"); - if (!localChatTab) + if (localChatTab == nullptr) return; NotifyManager::notify(NotifyTypes::ROOM_JOINED, name); } @@ -647,7 +647,7 @@ void ChatRecv::processChatRoomSettings(Net::MessageIn &msg) const uint8_t type = msg.readUInt8("type"); const std::string &title = msg.readString(sz, "title"); ChatObject *const chat = localPlayer->getChat(); - if (chat && chat->chatId == chatId) + if ((chat != nullptr) && chat->chatId == chatId) { chat->ownerId = ownerId; chat->maxUsers = limit; diff --git a/src/net/eathena/familyhandler.cpp b/src/net/eathena/familyhandler.cpp index 02bd5b43b..1a71c086d 100644 --- a/src/net/eathena/familyhandler.cpp +++ b/src/net/eathena/familyhandler.cpp @@ -44,7 +44,7 @@ FamilyHandler::FamilyHandler() : void FamilyHandler::askForChild(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_FAMILY_ASK_FOR_CHILD); diff --git a/src/net/eathena/familyrecv.cpp b/src/net/eathena/familyrecv.cpp index 8b3ca1df9..f9f7b2fd8 100644 --- a/src/net/eathena/familyrecv.cpp +++ b/src/net/eathena/familyrecv.cpp @@ -51,7 +51,7 @@ namespace FamilyRecv void FamilyRecv::processAskForChild(Net::MessageIn &msg) { - if (!localPlayer) + if (localPlayer == nullptr) { mParent1 = msg.readBeingId("account id who ask"); mParent2 = msg.readBeingId("acoount id for other parent"); @@ -62,10 +62,10 @@ void FamilyRecv::processAskForChild(Net::MessageIn &msg) mParent2 = msg.readBeingId("acoount id for other parent"); const std::string name1 = msg.readString(24, "name who ask"); const Party *const party = localPlayer->getParty(); - if (party) + if (party != nullptr) { const PartyMember *const member = party->getMember(mParent2); - if (member) + if (member != nullptr) { const std::string name2 = member->getName(); CREATEWIDGETV(confirmDlg, ConfirmDialog, @@ -84,7 +84,7 @@ void FamilyRecv::processAskForChild(Net::MessageIn &msg) void FamilyRecv::processCallPartner(Net::MessageIn &msg) { const std::string name = msg.readString(24, "name"); - if (localPlayer && name == localPlayer->getName()) + if ((localPlayer != nullptr) && name == localPlayer->getName()) { NotifyManager::notify(NotifyTypes::CALLED_PARTNER); } diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp index 019640937..8a169de60 100644 --- a/src/net/eathena/gamehandler.cpp +++ b/src/net/eathena/gamehandler.cpp @@ -60,7 +60,7 @@ void GameHandler::mapLoadedEvent() const void GameHandler::connect() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; Network::mInstance->connect(mapServer); @@ -71,7 +71,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); @@ -98,14 +98,14 @@ void GameHandler::connect() const bool GameHandler::isConnected() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return false; return Network::mInstance->isConnected(); } void GameHandler::disconnect() const { - if (Network::mInstance) + if (Network::mInstance != nullptr) Network::mInstance->disconnect(); } diff --git a/src/net/eathena/gamerecv.cpp b/src/net/eathena/gamerecv.cpp index 865ed5820..00d2c4f9d 100644 --- a/src/net/eathena/gamerecv.cpp +++ b/src/net/eathena/gamerecv.cpp @@ -63,12 +63,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/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp index 9c09d86a4..cfe77bc09 100644 --- a/src/net/eathena/generalhandler.cpp +++ b/src/net/eathena/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; Network::mInstance->flush(); @@ -184,19 +184,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(taGuild); socialWindow->removeTab(Ea::taParty); diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp index 3ea95b438..f2c90e874 100644 --- a/src/net/eathena/guildhandler.cpp +++ b/src/net/eathena/guildhandler.cpp @@ -75,12 +75,12 @@ void GuildHandler::create(const std::string &name) const void GuildHandler::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_GUILD_INVITE); outMsg.writeBeingId(being->getId(), "account id"); @@ -96,7 +96,7 @@ void GuildHandler::invite(const std::string &name) const void GuildHandler::invite(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_GUILD_INVITE); @@ -110,14 +110,14 @@ void GuildHandler::inviteResponse(const int guildId, { createOutPacket(CMSG_GUILD_INVITE_REPLY); outMsg.writeInt32(guildId, "guild id"); - outMsg.writeInt8(response, "response"); + outMsg.writeInt8(static_cast<int8_t>(response), "response"); outMsg.writeInt8(0, "unused"); outMsg.writeInt16(0, "unused"); } void GuildHandler::leave(const int guildId) const { - if (!localPlayer) + if (localPlayer == nullptr) return; createOutPacket(CMSG_GUILD_LEAVE); @@ -130,7 +130,7 @@ void GuildHandler::leave(const int guildId) const void GuildHandler::kick(const GuildMember *restrict const member, const std::string &restrict reason) const { - if (!member || !member->getGuild()) + if ((member == nullptr) || (member->getGuild() == nullptr)) return; createOutPacket(CMSG_GUILD_EXPULSION); @@ -142,7 +142,7 @@ void GuildHandler::kick(const GuildMember *restrict const member, void GuildHandler::chat(const std::string &text) const { - if (!localPlayer) + if (localPlayer == nullptr) return; const std::string str = std::string(localPlayer->getName()).append( @@ -189,7 +189,7 @@ void GuildHandler::info() const void GuildHandler::changeMemberPostion(const GuildMember *const member, const int level) const { - if (!member || !member->getGuild()) + if ((member == nullptr) || (member->getGuild() == nullptr)) return; createOutPacket(CMSG_GUILD_CHANGE_MEMBER_POS); @@ -216,7 +216,7 @@ void GuildHandler::checkMaster() const void GuildHandler::requestAlliance(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_GUILD_ALLIANCE_REQUEST); @@ -230,7 +230,7 @@ void GuildHandler::requestAllianceResponse(const int beingId, { createOutPacket(CMSG_GUILD_ALLIANCE_REPLY); outMsg.writeInt32(beingId, "account id"); - outMsg.writeInt32(accept, "accept flag"); + outMsg.writeInt32(static_cast<int32_t>(accept), "accept flag"); } void GuildHandler::endAlliance(const int guildId, @@ -258,7 +258,7 @@ void GuildHandler::changePostionInfo(const int posId, void GuildHandler::requestOpposition(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_GUILD_OPPOSITION); diff --git a/src/net/eathena/guildrecv.cpp b/src/net/eathena/guildrecv.cpp index 6d829299b..cb31788b6 100644 --- a/src/net/eathena/guildrecv.cpp +++ b/src/net/eathena/guildrecv.cpp @@ -109,7 +109,7 @@ void GuildRecv::processGuildBasicInfo(Net::MessageIn &msg) std::string castle = msg.readString(16, "castles"); msg.readInt32("unused"); - if (guildTab && showBasicInfo) + if ((guildTab != nullptr) && showBasicInfo) { showBasicInfo = false; // TRANSLATORS: guild info message @@ -142,7 +142,7 @@ void GuildRecv::processGuildBasicInfo(Net::MessageIn &msg) } Guild *const g = Guild::getGuild(CAST_S16(guildId)); - if (!g) + if (g == nullptr) return; g->setName(name); g->setEmblemId(emblem); @@ -169,7 +169,7 @@ void GuildRecv::processGuildMemberList(Net::MessageIn &msg) if (length < 4) return; const int count = (length - 4) / 104; - if (!taGuild) + if (taGuild == nullptr) { logger->log1("!taGuild"); return; @@ -195,9 +195,9 @@ void GuildRecv::processGuildMemberList(Net::MessageIn &msg) std::string name = msg.readString(24, "name"); GuildMember *const m = taGuild->addMember(id, charId, name); - if (m) + if (m != nullptr) { - m->setOnline(online); + m->setOnline(online != 0); m->setID(id); m->setCharId(charId); m->setGender(Being::intToGender(CAST_U8(gender))); @@ -205,11 +205,11 @@ void GuildRecv::processGuildMemberList(Net::MessageIn &msg) m->setExp(exp); m->setPos(pos); m->setRace(race); - if (actorManager) + if (actorManager != nullptr) { Being *const being = actorManager->findBeingByName( name, ActorType::Player); - if (being) + if (being != nullptr) { being->setGuildName(taGuild->getName()); if (being->getLevel() != level) @@ -219,24 +219,24 @@ void GuildRecv::processGuildMemberList(Net::MessageIn &msg) } } } - if (online) + if (online != 0) onlineNum ++; totalNum ++; } } taGuild->sort(); - if (actorManager) + if (actorManager != nullptr) { actorManager->updatePlayerGuild(); actorManager->updatePlayerColors(); } - if (socialWindow) + if (socialWindow != nullptr) socialWindow->updateGuildCounter(onlineNum, totalNum); } void GuildRecv::processGuildPosNameList(Net::MessageIn &msg) { - if (!taGuild) + if (taGuild == nullptr) { logger->log1("!taGuild"); return; @@ -288,10 +288,10 @@ void GuildRecv::processGuildMemberPosChange(Net::MessageIn &msg) const BeingId accountId = msg.readBeingId("account id"); const int charId = msg.readInt32("char id"); const int pos = msg.readInt32("position"); - if (taGuild) + if (taGuild != nullptr) { GuildMember *const m = taGuild->getMember(accountId, charId); - if (m) + if (m != nullptr) m->setPos(pos); } } @@ -313,7 +313,7 @@ void GuildRecv::processGuildSkillInfo(Net::MessageIn &msg) const int count = (msg.readInt16("len") - 6) / 37; msg.readInt16("skill points"); - if (skillDialog) + if (skillDialog != nullptr) skillDialog->hideSkills(SkillOwner::Guild); for (int i = 0; i < count; i++) { @@ -326,7 +326,7 @@ void GuildRecv::processGuildSkillInfo(Net::MessageIn &msg) const std::string name = msg.readString(24, "skill name"); const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable); PlayerInfo::setSkillLevel(skillId, level); - if (skillDialog) + if (skillDialog != nullptr) { if (!skillDialog->updateSkill(skillId, range, up, inf, sp)) { @@ -335,7 +335,7 @@ void GuildRecv::processGuildSkillInfo(Net::MessageIn &msg) } } } - if (skillDialog) + if (skillDialog != nullptr) skillDialog->updateModels(); } @@ -343,7 +343,7 @@ void GuildRecv::processGuildNotice(Net::MessageIn &msg) { const std::string msg1 = msg.readString(60, "msg1"); const std::string msg2 = msg.readString(120, "msg2"); - if (guildTab) + if (guildTab != nullptr) { guildTab->chatLog(msg1, ChatMsgType::BY_SERVER); guildTab->chatLog(msg2, ChatMsgType::BY_SERVER); @@ -355,14 +355,14 @@ void GuildRecv::processGuildInvite(Net::MessageIn &msg) const int guildId = msg.readInt32("guild id"); const std::string guildName = msg.readString(24, "guild name"); - if (socialWindow) + if (socialWindow != nullptr) socialWindow->showGuildInvite(guildName, guildId, ""); } void GuildRecv::processGuildInviteAck(Net::MessageIn &msg) { const uint8_t flag = msg.readUInt8("flag"); - if (!guildTab) + if (guildTab == nullptr) return; switch (flag) @@ -394,15 +394,15 @@ void GuildRecv::processGuildLeave(Net::MessageIn &msg) const std::string nick = msg.readString(24, "nick"); msg.readString(40, "message"); - if (taGuild) + if (taGuild != nullptr) taGuild->removeMember(nick); - if (!localPlayer) + if (localPlayer == nullptr) return; if (nick == localPlayer->getName()) { - if (taGuild) + if (taGuild != nullptr) { taGuild->removeFromMembers(); taGuild->clearMembers(); @@ -411,22 +411,22 @@ void GuildRecv::processGuildLeave(Net::MessageIn &msg) NotifyManager::notify(NotifyTypes::GUILD_LEFT); delete2(guildTab) - if (socialWindow && taGuild) + if ((socialWindow != nullptr) && (taGuild != nullptr)) socialWindow->removeTab(taGuild); - if (actorManager) + if (actorManager != nullptr) actorManager->updatePlayerColors(); } else { NotifyManager::notify(NotifyTypes::GUILD_USER_LEFT, nick); - if (actorManager) + if (actorManager != nullptr) { Being *const b = actorManager->findBeingByName( nick, ActorType::Player); - if (b) + if (b != nullptr) b->clearGuilds(); - if (taGuild) + if (taGuild != nullptr) taGuild->removeMember(nick); } } @@ -438,7 +438,7 @@ void GuildRecv::processGuildMessage(Net::MessageIn &msg) if (msgLength <= 0) return; - if (guildTab) + if (guildTab != nullptr) { std::string chatMsg = msg.readString(msgLength, "message"); const size_t pos = chatMsg.find(" : ", 0); @@ -505,15 +505,15 @@ void GuildRecv::processGuildBroken(Net::MessageIn &msg) void GuildRecv::processGuildExpulsionContinue(const std::string &nick) { - if (taGuild) + if (taGuild != nullptr) taGuild->removeMember(nick); - if (!localPlayer) + if (localPlayer == nullptr) return; if (nick == localPlayer->getName()) { - if (taGuild) + if (taGuild != nullptr) { taGuild->removeFromMembers(); taGuild->clearMembers(); @@ -521,22 +521,22 @@ void GuildRecv::processGuildExpulsionContinue(const std::string &nick) NotifyManager::notify(NotifyTypes::GUILD_KICKED); delete2(guildTab) - if (socialWindow && taGuild) + if ((socialWindow != nullptr) && (taGuild != nullptr)) socialWindow->removeTab(taGuild); - if (actorManager) + if (actorManager != nullptr) actorManager->updatePlayerColors(); } else { NotifyManager::notify(NotifyTypes::GUILD_USER_KICKED, nick); - if (actorManager) + if (actorManager != nullptr) { Being *const b = actorManager->findBeingByName( nick, ActorType::Player); - if (b) + if (b != nullptr) b->clearGuilds(); - if (taGuild) + if (taGuild != nullptr) taGuild->removeMember(nick); } } @@ -547,10 +547,10 @@ void GuildRecv::processGuildUpdateCoords(Net::MessageIn &msg) const BeingId id = msg.readBeingId("account id"); const int x = msg.readInt16("x"); const int y = msg.readInt16("y"); - if (taGuild) + if (taGuild != nullptr) { GuildMember *const m = taGuild->getMember(id); - if (m) + if (m != nullptr) { m->setX(x); m->setY(y); @@ -569,24 +569,24 @@ void GuildRecv::processGuildPositionInfo(Net::MessageIn &msg) std::string guildName = msg.readString(24, "guild name"); Guild *const g = Guild::getGuild(CAST_S16(guildId)); - if (!g) + if (g == nullptr) return; g->setName(guildName); g->setEmblemId(emblem); - if (!taGuild) + if (taGuild == nullptr) taGuild = g; - if (!guildTab && chatWindow) + if ((guildTab == nullptr) && (chatWindow != nullptr)) { guildTab = new GuildTab(chatWindow); if (config.getBoolValue("showChatHistory")) guildTab->loadFromLogFile("#Guild"); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->addGuild(taGuild); guildHandler->memberList(); } - if (localPlayer) + if (localPlayer != nullptr) { localPlayer->setGuild(g); localPlayer->setGuildName(g->getName()); @@ -602,17 +602,17 @@ void GuildRecv::processGuildMemberLogin(Net::MessageIn &msg) msg.readInt16("sex"))); msg.readInt16("hair"); msg.readInt16("hair color"); - if (taGuild) + if (taGuild != nullptr) { GuildMember *const m = taGuild->getMember(accountId, charId); - if (m) + if (m != nullptr) { - m->setOnline(online); - if (online) + m->setOnline(online != 0); + if (online != 0) m->setGender(gender); - if (guildTab) + if (guildTab != nullptr) guildTab->showOnline(m->getName(), fromBool(online, Online)); - if (socialWindow) + if (socialWindow != nullptr) socialWindow->updateGuildCounter(); } } diff --git a/src/net/eathena/homunculusrecv.cpp b/src/net/eathena/homunculusrecv.cpp index a30e81662..204b618a7 100644 --- a/src/net/eathena/homunculusrecv.cpp +++ b/src/net/eathena/homunculusrecv.cpp @@ -46,7 +46,7 @@ namespace EAthena void HomunculusRecv::processHomunculusSkills(Net::MessageIn &msg) { - if (skillDialog) + if (skillDialog != nullptr) skillDialog->hideSkills(SkillOwner::Homunculus); const int count = (msg.readInt16("len") - 4) / 37; @@ -62,7 +62,7 @@ void HomunculusRecv::processHomunculusSkills(Net::MessageIn &msg) const std::string name = msg.readString(24, "skill name"); const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable); PlayerInfo::setSkillLevel(skillId, level); - if (skillDialog) + if (skillDialog != nullptr) { if (!skillDialog->updateSkill(skillId, range, up, inf, sp)) { @@ -71,7 +71,7 @@ void HomunculusRecv::processHomunculusSkills(Net::MessageIn &msg) } } } - if (skillDialog) + if (skillDialog != nullptr) skillDialog->updateModels(); } @@ -82,7 +82,7 @@ void HomunculusRecv::processHomunculusData(Net::MessageIn &msg) const BeingId id = msg.readBeingId("homunculus id"); Being *const dstBeing = actorManager->findBeing(id); const int data = msg.readInt32("data"); - if (!cmd) // pre init + if (cmd == 0) // pre init { HomunculusInfo *const info = new HomunculusInfo; info->id = id; @@ -91,7 +91,7 @@ void HomunculusRecv::processHomunculusData(Net::MessageIn &msg) return; } HomunculusInfo *const info = PlayerInfo::getHomunculus(); - if (!info) + if (info == nullptr) return; switch (cmd) { @@ -164,7 +164,7 @@ void HomunculusRecv::processHomunculusInfo(Net::MessageIn &msg) PlayerInfo::updateAttrs(); HomunculusInfo *const info = PlayerInfo::getHomunculus(); - if (!info) // we can't find homunculus being because id is missing + if (info == nullptr) return; Being *const dstBeing = actorManager->findBeing(info->id); @@ -185,10 +185,10 @@ void HomunculusRecv::processHomunculusSkillUp(Net::MessageIn &msg) const int range = msg.readInt16("range"); const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable); - if (skillDialog && PlayerInfo::getSkillLevel(skillId) != level) + if (skillDialog != nullptr && PlayerInfo::getSkillLevel(skillId) != level) skillDialog->playUpdateEffect(skillId); PlayerInfo::setSkillLevel(skillId, level); - if (skillDialog) + if (skillDialog != nullptr) { if (!skillDialog->updateSkill(skillId, range, up, SkillType::Unknown, sp)) @@ -204,7 +204,7 @@ void HomunculusRecv::processHomunculusFood(Net::MessageIn &msg) { const int flag = msg.readUInt8("fail"); const int itemId = msg.readInt16("food id"); - if (flag) + if (flag != 0) { NotifyManager::notify(NotifyTypes::HOMUNCULUS_FEED_OK); } @@ -220,7 +220,7 @@ void HomunculusRecv::processHomunculusExp(Net::MessageIn &msg) { const int exp = msg.readInt32("exp"); msg.readInt32("unused"); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->addHomunXpMessage(exp); } diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index a7fde5a05..6a5152fad 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -80,7 +80,7 @@ InventoryHandler::~InventoryHandler() void InventoryHandler::equipItem(const Item *const item) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_PLAYER_EQUIP); @@ -96,7 +96,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); @@ -106,7 +106,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); @@ -117,7 +117,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); @@ -477,7 +477,7 @@ void InventoryHandler::moveItem2(const InventoryTypeT source, } // for packetVersion < 20101124 need use other packet offset - if (packet) + if (packet != 0) { createOutPacket(packet); outMsg.writeInt16(CAST_S16(slot + offset), "index"); @@ -487,7 +487,7 @@ void InventoryHandler::moveItem2(const InventoryTypeT source, void InventoryHandler::useCard(const Item *const item) { - if (!item) + if (item == nullptr) return; mItemIndex = item->getInvIndex(); @@ -509,7 +509,7 @@ void InventoryHandler::insertCard(const int cardIndex, void InventoryHandler::favoriteItem(const Item *const item, const bool favorite) const { - if (!item) + if (item == nullptr) return; if (packetVersion < 20120410) return; @@ -517,12 +517,12 @@ void InventoryHandler::favoriteItem(const Item *const item, outMsg.writeInt16(CAST_S16(item->getInvIndex() + INVENTORY_OFFSET), "item index"); - outMsg.writeInt8(favorite, "favorite flag"); + outMsg.writeInt8(static_cast<int8_t>(favorite), "favorite flag"); } void InventoryHandler::selectEgg(const Item *const item) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_PET_SELECT_EGG); outMsg.writeInt16(CAST_S16( diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp index 5403e773b..08cd1975e 100644 --- a/src/net/eathena/inventoryrecv.cpp +++ b/src/net/eathena/inventoryrecv.cpp @@ -100,12 +100,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); @@ -173,7 +173,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) flags.byte = msg.readUInt8("flags"); else flags.byte = 0; - if (inventory) + if (inventory != nullptr) { inventory->setItem(index, itemId, @@ -191,7 +191,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) } delete options; - if (equipType) + if (equipType != 0) { Ea::InventoryRecv::mEquips.setEquipment( InventoryRecv::getSlot(equipType), @@ -204,11 +204,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); @@ -259,7 +259,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) Ea::InventoryRecv::mSentPickups.pop(); } - if (err) + if (err != 0u) { PickupT pickup; switch (err) @@ -287,7 +287,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) UNIMPLEMENTEDPACKETFIELD(err); break; } - if (localPlayer) + if (localPlayer != nullptr) { if (itemId == 0) { @@ -309,7 +309,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) } else { - if (localPlayer) + if (localPlayer != nullptr) { if (itemId == 0) { @@ -329,11 +329,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, @@ -359,16 +359,16 @@ 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"); @@ -417,7 +417,7 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) else flags.byte = 0; - if (inventory) + if (inventory != nullptr) { inventory->setItem(index, itemId, @@ -556,7 +556,7 @@ void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg) equipType = msg.readInt16("wear location"); const uint8_t flag = msg.readUInt8("result"); - if (flag) + if (flag != 0u) { NotifyManager::notify(NotifyTypes::UNEQUIP_FAILED); } @@ -566,7 +566,7 @@ void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg) InventoryRecv::getSlot(equipType), -1); } - if (equipType & 0x8000) + if ((equipType & 0x8000) != 0) ArrowsListener::distributeEvent(); BLOCK_END("InventoryRecv::processPlayerUnEquip") } @@ -574,7 +574,7 @@ void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg) void InventoryRecv::processPlayerInventoryRemove2(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerInventoryRemove2") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; const DeleteItemReasonT reason = static_cast<DeleteItemReasonT>( @@ -582,7 +582,7 @@ void InventoryRecv::processPlayerInventoryRemove2(Net::MessageIn &msg) 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)) { @@ -771,7 +771,7 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg) } else { - if (Ea::InventoryRecv::mStorage) + if (Ea::InventoryRecv::mStorage != nullptr) { Ea::InventoryRecv::mStorage->setItem(index, itemId, @@ -797,7 +797,7 @@ void InventoryRecv::processPlayerUseCard(Net::MessageIn &msg) const Inventory *const inv = PlayerInfo::getInventory(); const int index = inventoryHandler->getItemIndex(); const Item *item1 = nullptr; - if (inv) + if (inv != nullptr) item1 = inv->getItem(index); SellDialog *const dialog = CREATEWIDGETR(InsertCardDialog, index, item1); @@ -806,10 +806,10 @@ void InventoryRecv::processPlayerUseCard(Net::MessageIn &msg) for (int f = 0; f < count; f ++) { const int itemIndex = msg.readInt16("item index") - INVENTORY_OFFSET; - if (!inv) + if (inv == nullptr) continue; const Item *const item = inv->getItem(itemIndex); - if (!item) + if (item == nullptr) continue; dialog->addItem(item, 0); } @@ -819,7 +819,7 @@ void InventoryRecv::processPlayerInsertCard(Net::MessageIn &msg) { const int itemIndex = msg.readInt16("item index") - INVENTORY_OFFSET; const int cardIndex = msg.readInt16("card index") - INVENTORY_OFFSET; - if (msg.readUInt8("flag")) + if (msg.readUInt8("flag") != 0u) { NotifyManager::notify(NotifyTypes::CARD_INSERT_FAILED); } @@ -827,11 +827,11 @@ void InventoryRecv::processPlayerInsertCard(Net::MessageIn &msg) { NotifyManager::notify(NotifyTypes::CARD_INSERT_SUCCESS); Inventory *const inv = PlayerInfo::getInventory(); - if (!inv) + if (inv == nullptr) return; Item *const card = inv->getItem(cardIndex); int cardId = 0; - if (card) + if (card != nullptr) { cardId = card->getId(); card->increaseQuantity(-1); @@ -839,7 +839,7 @@ void InventoryRecv::processPlayerInsertCard(Net::MessageIn &msg) inv->removeItemAt(cardIndex); } Item *const item = inv->getItem(itemIndex); - if (item) + if (item != nullptr) { item->addCard(cardId); item->updateColor(); @@ -862,7 +862,7 @@ void InventoryRecv::processPlayerItemRentalTime(Net::MessageIn &msg) void InventoryRecv::processPlayerItemRentalExpired(Net::MessageIn &msg) { - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; const int index = msg.readInt16("index") - INVENTORY_OFFSET; @@ -871,7 +871,7 @@ void InventoryRecv::processPlayerItemRentalExpired(Net::MessageIn &msg) NotifyManager::notify(NotifyTypes::RENTAL_TIME_EXPIRED, info.getName()); - if (inventory) + if (inventory != nullptr) { if (Item *const item = inventory->getItem(index)) { @@ -888,7 +888,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)) { @@ -912,7 +912,7 @@ void InventoryRecv::processCartInfo(Net::MessageIn &msg) return; Inventory *const inv = PlayerInfo::getCartInventory(); - if (!inv) + if (inv == nullptr) return; inv->resize(size); @@ -943,7 +943,7 @@ void InventoryRecv::processCartRemove(Net::MessageIn &msg) void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerCartAdd") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getCartInventory() : nullptr; const int index = msg.readInt16("index") - INVENTORY_OFFSET; @@ -975,11 +975,11 @@ void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg) } // check what cart was created, if not add delayed items - if (inventory && inventory->getSize() > 0) + if ((inventory != nullptr) && inventory->getSize() > 0) { const Item *const item = inventory->getItem(index); - if (item && item->getId() == itemId) + if ((item != nullptr) && item->getId() == itemId) amount += item->getQuantity(); inventory->setItem(index, @@ -1170,7 +1170,7 @@ void InventoryRecv::processPlayerCartRemove(Net::MessageIn &msg) const int amount = msg.readInt32("amount"); Inventory *const inv = PlayerInfo::getCartInventory(); - if (!inv) + if (inv == nullptr) return; if (Item *const item = inv->getItem(index)) @@ -1209,9 +1209,9 @@ void InventoryRecv::processPlayerRefine(Net::MessageIn &msg) const Item *item = nullptr; int notifyType; std::string itemName; - if (inv) + if (inv != nullptr) item = inv->getItem(index); - if (item) + if (item != nullptr) { itemName = item->getName(); } @@ -1340,11 +1340,11 @@ void InventoryRecv::processBindItem(Net::MessageIn &msg) { const int index = msg.readInt16("item index") - INVENTORY_OFFSET; const Inventory *const inv = PlayerInfo::getInventory(); - if (inv) + if (inv != nullptr) { std::string itemName; const Item *const item = inv->getItem(index); - if (item) + if (item != nullptr) { itemName = item->getName(); } @@ -1360,16 +1360,16 @@ void InventoryRecv::processBindItem(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)) { - if (amount) + if (amount != 0) { NotifyManager::notify(NotifyTypes::DELETE_ITEM_DROPPED, item->getName()); @@ -1398,12 +1398,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/eathena/itemrecv.cpp b/src/net/eathena/itemrecv.cpp index 062063a55..f0a6bd585 100644 --- a/src/net/eathena/itemrecv.cpp +++ b/src/net/eathena/itemrecv.cpp @@ -50,7 +50,7 @@ void ItemRecv::processItemDropped(Net::MessageIn &msg) const int subY = CAST_S32(msg.readInt8("suby")); const int amount = msg.readInt16("count"); - if (actorManager) + if (actorManager != nullptr) { actorManager->createItem(id, itemId, @@ -84,7 +84,7 @@ void ItemRecv::processItemDropped2(Net::MessageIn &msg) const int subX = CAST_S32(msg.readInt8("subx")); const int subY = CAST_S32(msg.readInt8("suby")); - if (actorManager) + if (actorManager != nullptr) { actorManager->createItem(id, itemId, @@ -124,7 +124,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, @@ -159,7 +159,7 @@ void ItemRecv::processItemVisible2(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/eathena/loginhandler.cpp b/src/net/eathena/loginhandler.cpp index 08c601434..f6ebe8e45 100644 --- a/src/net/eathena/loginhandler.cpp +++ b/src/net/eathena/loginhandler.cpp @@ -54,7 +54,7 @@ LoginHandler::~LoginHandler() void LoginHandler::connect() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; Network::mInstance->connect(mServer); @@ -71,7 +71,7 @@ void LoginHandler::connect() const bool LoginHandler::isConnected() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return false; return Network::mInstance->isConnected(); @@ -79,8 +79,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/eathena/mailrecv.cpp b/src/net/eathena/mailrecv.cpp index 38366d986..c098b6857 100644 --- a/src/net/eathena/mailrecv.cpp +++ b/src/net/eathena/mailrecv.cpp @@ -45,7 +45,7 @@ void MailRecv::processMailOpen(Net::MessageIn &msg) switch (flag) { case 0: // open window - if (mailWindow) + if (mailWindow != nullptr) { if (!mailWindow->isWindowVisible()) mailWindow->setVisible(Visible_true); @@ -54,7 +54,7 @@ void MailRecv::processMailOpen(Net::MessageIn &msg) break; case 1: // close window - if (mailWindow) + if (mailWindow != nullptr) { if (mailWindow->isWindowVisible()) mailWindow->setVisible(Visible_false); @@ -79,7 +79,7 @@ void MailRecv::processMailList(Net::MessageIn &msg) MailMessage *const mail = new MailMessage; mail->id = msg.readInt32("message id"); mail->title = msg.readString(40, "title"); - mail->unread = msg.readUInt8("unread flag") ? true : false; + mail->unread = msg.readUInt8("unread flag") != 0u ? true : false; mail->sender = msg.readString(24, "sender name"); mail->time = msg.readInt32("time stamp"); mail->strTime = timeToStr(mail->time); @@ -99,7 +99,7 @@ void MailRecv::processReadMail(Net::MessageIn &msg) mail->itemAmount = msg.readInt32("item amount"); mail->itemId = msg.readInt16("item id"); mail->itemType = msg.readInt16("item type"); - mail->itemIdentify = msg.readUInt8("identify"); + mail->itemIdentify = (msg.readUInt8("identify") != 0u); mail->itemAttribute = msg.readUInt8("attribute"); mail->itemRefine = msg.readUInt8("refine"); for (int f = 0; f < maxCards; f ++) @@ -166,9 +166,9 @@ void MailRecv::processSetAttachmentAck(Net::MessageIn &msg) { const int index = msg.readInt16("index"); const int flag = msg.readUInt8("flag"); - if (flag) + if (flag != 0) { - if (index) + if (index != 0) NotifyManager::notify(NotifyTypes::MAIL_ATTACH_ITEM_ERROR); else NotifyManager::notify(NotifyTypes::MAIL_ATTACH_MONEY_ERROR); @@ -179,7 +179,7 @@ void MailRecv::processDeleteAck(Net::MessageIn &msg) { const int mail = msg.readInt32("message id"); const int flag = msg.readInt16("fail flag"); - if (flag) + if (flag != 0) { NotifyManager::notify(NotifyTypes::MAIL_DELETE_ERROR); } @@ -194,7 +194,7 @@ void MailRecv::processMailReturn(Net::MessageIn &msg) { const int mail = msg.readInt32("message id"); const int flag = msg.readInt16("fail flag"); - if (flag) + if (flag != 0) { NotifyManager::notify(NotifyTypes::MAIL_RETURN_ERROR); } diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp index ba3304aa5..a75aec961 100644 --- a/src/net/eathena/markethandler.cpp +++ b/src/net/eathena/markethandler.cpp @@ -86,7 +86,7 @@ void MarketHandler::buyItems(const std::vector<ShopItem*> &items) const const ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); const ItemTypeT type = item->getType(); - if (!usedQuantity) + if (usedQuantity == 0) continue; if (type == ItemType::Weapon || type == ItemType::Armor || @@ -110,7 +110,7 @@ void MarketHandler::buyItems(const std::vector<ShopItem*> &items) const { ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); - if (!usedQuantity) + if (usedQuantity == 0) continue; item->increaseQuantity(usedQuantity); item->increaseUsedQuantity(-usedQuantity); diff --git a/src/net/eathena/marketrecv.cpp b/src/net/eathena/marketrecv.cpp index cfe7aa4c8..8563c67ca 100644 --- a/src/net/eathena/marketrecv.cpp +++ b/src/net/eathena/marketrecv.cpp @@ -61,7 +61,7 @@ void MarketRecv::processMarketOpen(Net::MessageIn &msg) if (npcId != BeingTypeId_zero) { const BeingInfo *const info = NPCDB::get(npcId); - if (info) + if (info != nullptr) currency = info->getCurrency(); else currency = DEFAULT_CURRENCY; @@ -99,7 +99,7 @@ void MarketRecv::processMarketBuyAck(Net::MessageIn &msg) msg.readInt16("amount"); msg.readInt32("price"); } - if (res) + if (res != 0) NotifyManager::notify(NotifyTypes::BUY_DONE); else NotifyManager::notify(NotifyTypes::BUY_FAILED); diff --git a/src/net/eathena/mercenaryrecv.cpp b/src/net/eathena/mercenaryrecv.cpp index 042c87451..594c96b6a 100644 --- a/src/net/eathena/mercenaryrecv.cpp +++ b/src/net/eathena/mercenaryrecv.cpp @@ -120,7 +120,7 @@ void MercenaryRecv::processMercenaryInfo(Net::MessageIn &msg) range); PlayerInfo::updateAttrs(); - if (dstBeing && localPlayer) + if ((dstBeing != nullptr) && (localPlayer != nullptr)) { MercenaryInfo *const mercenary = new MercenaryInfo; mercenary->id = dstBeing->getId(); @@ -134,7 +134,7 @@ void MercenaryRecv::processMercenaryInfo(Net::MessageIn &msg) void MercenaryRecv::processMercenarySkills(Net::MessageIn &msg) { - if (skillDialog) + if (skillDialog != nullptr) skillDialog->hideSkills(SkillOwner::Mercenary); const int count = (msg.readInt16("len") - 4) / 37; for (int f = 0; f < count; f ++) @@ -148,7 +148,7 @@ void MercenaryRecv::processMercenarySkills(Net::MessageIn &msg) const std::string name = msg.readString(24, "skill name"); const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable); PlayerInfo::setSkillLevel(skillId, level); - if (skillDialog) + if (skillDialog != nullptr) { if (!skillDialog->updateSkill(skillId, range, up, inf, sp)) { @@ -157,14 +157,14 @@ void MercenaryRecv::processMercenarySkills(Net::MessageIn &msg) } } } - if (skillDialog) + if (skillDialog != nullptr) skillDialog->updateModels(); } void MercenaryRecv::handleMercenaryMessage(const int cmd) { PlayerInfo::setMercenary(nullptr); - if (skillDialog) + if (skillDialog != nullptr) { skillDialog->hideSkills(SkillOwner::Mercenary); skillDialog->updateModels(); diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp index 8ea30fe50..8b3504e4e 100644 --- a/src/net/eathena/network.cpp +++ b/src/net/eathena/network.cpp @@ -207,7 +207,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/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp index 5f2da7255..85349ce9d 100644 --- a/src/net/eathena/npchandler.cpp +++ b/src/net/eathena/npchandler.cpp @@ -57,7 +57,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"); @@ -80,7 +80,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; @@ -125,7 +125,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"); @@ -169,7 +169,7 @@ void NpcHandler::buyItems(std::vector<ShopItem*> &items) const ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); const ItemTypeT type = item->getType(); - if (!usedQuantity) + if (usedQuantity == 0) continue; if (type == ItemType::Weapon || type == ItemType::Armor || @@ -193,7 +193,7 @@ void NpcHandler::buyItems(std::vector<ShopItem*> &items) const { ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); - if (!usedQuantity) + if (usedQuantity == 0) continue; item->increaseUsedQuantity(-usedQuantity); item->update(); @@ -237,7 +237,7 @@ void NpcHandler::sellItems(std::vector<ShopItem*> &items) const { ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); - if (!usedQuantity) + if (usedQuantity == 0) continue; cnt ++; } @@ -248,7 +248,7 @@ void NpcHandler::sellItems(std::vector<ShopItem*> &items) const { ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); - if (!usedQuantity) + if (usedQuantity == 0) continue; item->increaseUsedQuantity(-usedQuantity); item->update(); @@ -339,7 +339,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; } @@ -347,10 +347,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/eathena/npcrecv.cpp b/src/net/eathena/npcrecv.cpp index c23d9d11b..875718768 100644 --- a/src/net/eathena/npcrecv.cpp +++ b/src/net/eathena/npcrecv.cpp @@ -47,7 +47,7 @@ void NpcRecv::processNpcCutin(Net::MessageIn &msg) Ea::NpcRecv::mRequestLang = false; const std::string image = msg.readString(64, "image name"); const CutInT cutin = static_cast<CutInT>(msg.readUInt8("type")); - if (cutInWindow) + if (cutInWindow != nullptr) cutInWindow->show(image, cutin); } @@ -91,7 +91,7 @@ void NpcRecv::processArea(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("npc id")); const int area = msg.readInt32("area size"); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setAreaSize(area); } @@ -113,7 +113,7 @@ void NpcRecv::processNpcSkin(Net::MessageIn &msg) const int len = msg.readInt16("len"); npcHandler->getNpc(msg, NpcAction::Other); const std::string skin = msg.readString(len - 8, "skin"); - if (Ea::NpcRecv::mDialog) + if (Ea::NpcRecv::mDialog != nullptr) Ea::NpcRecv::mDialog->setSkin(skin); } diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index 590f85ec8..dd0309f0d 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -61,11 +61,11 @@ 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"); @@ -82,7 +82,7 @@ void PartyHandler::invite(const std::string &name) const void PartyHandler::inviteResponse(const int partyId, const bool accept) const { - if (localPlayer) + if (localPlayer != nullptr) { createOutPacket(CMSG_PARTY_INVITED2); outMsg.writeInt32(partyId, "party id"); @@ -97,7 +97,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"); @@ -107,11 +107,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; @@ -183,7 +183,7 @@ void PartyHandler::changeLeader(const std::string &name) const { const Being *const being = actorManager->findBeingByName( name, ActorType::Player); - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_PARTY_CHANGE_LEADER); outMsg.writeBeingId(being->getId(), "account id"); diff --git a/src/net/eathena/partyrecv.cpp b/src/net/eathena/partyrecv.cpp index 2a0b7476a..0947a525e 100644 --- a/src/net/eathena/partyrecv.cpp +++ b/src/net/eathena/partyrecv.cpp @@ -66,13 +66,13 @@ void PartyRecv::processPartyMemberInfo(Net::MessageIn &msg) msg.readInt8("pickup item share (&1)"); msg.readInt8("get item share (&2)"); - if (!Ea::taParty) + if (Ea::taParty == nullptr) return; PartyMember *const member = Ea::taParty->addMember(id, nick); - if (member) + if (member != nullptr) { - if (partyTab && member->getOnline() != online) + if ((partyTab != nullptr) && member->getOnline() != online) partyTab->showOnline(nick, fromBool(online, Online)); member->setLeader(leader); member->setOnline(online); @@ -84,9 +84,9 @@ void PartyRecv::processPartyMemberInfo(Net::MessageIn &msg) void PartyRecv::processPartySettings(Net::MessageIn &msg) { - if (!partyTab) + if (partyTab == nullptr) { - if (!chatWindow) + if (chatWindow == nullptr) return; Ea::PartyRecv::createTab(); @@ -111,15 +111,15 @@ 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 (!partyTab) + if (partyTab == nullptr) Ea::PartyRecv::createTab(); - if (Ea::taParty) + if (Ea::taParty != nullptr) { if (Ea::taParty->getNumberOfElements() > 1) { @@ -131,24 +131,24 @@ 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"); const std::string name = msg.readString(24, "party name"); - if (Ea::taParty) + if (Ea::taParty != nullptr) Ea::taParty->setName(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()); @@ -162,7 +162,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); @@ -176,9 +176,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) @@ -202,14 +202,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(); } } @@ -227,10 +227,10 @@ void PartyRecv::processPartyMessage(Net::MessageIn &msg) if (pos != std::string::npos) chatMsg.erase(0, pos + 3); - 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); } @@ -244,7 +244,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"); @@ -307,9 +307,9 @@ void PartyRecv::processPartyLeader(Net::MessageIn &msg) msg.readBeingId("old leder id")); PartyMember *const newMember = Ea::taParty->getMember( msg.readBeingId("new leder id")); - if (oldMember) + if (oldMember != nullptr) oldMember->setLeader(false); - if (newMember) + if (newMember != nullptr) newMember->setLeader(true); } @@ -318,7 +318,7 @@ void PartyRecv::processPartyInvited(Net::MessageIn &msg) const int id = msg.readInt32("party id"); const std::string partyName = msg.readString(24, "party name"); - if (socialWindow) + if (socialWindow != nullptr) socialWindow->showPartyInvite(partyName, std::string(), id); } diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp index a7062b21b..602f9cd88 100644 --- a/src/net/eathena/pethandler.cpp +++ b/src/net/eathena/pethandler.cpp @@ -58,7 +58,7 @@ void PetHandler::emote(const uint8_t emoteId) void PetHandler::catchPet(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_PET_CATCH); diff --git a/src/net/eathena/petrecv.cpp b/src/net/eathena/petrecv.cpp index 50bf43eed..f2cf65a28 100644 --- a/src/net/eathena/petrecv.cpp +++ b/src/net/eathena/petrecv.cpp @@ -74,7 +74,7 @@ void PetRecv::processEggsList(Net::MessageIn &msg) { const int count = (msg.readInt16("len") - 4) / 2; const Inventory *const inv = PlayerInfo::getInventory(); - if (!inv) + if (inv == nullptr) return; menu = MenuType::Eggs; @@ -92,7 +92,7 @@ void PetRecv::processEggsList(Net::MessageIn &msg) const int index = msg.readInt16("index") - INVENTORY_OFFSET; const Item *const item = inv->getItem(index); - if (item) + if (item != nullptr) dialog->addItem(item, 0); } } @@ -103,7 +103,7 @@ void PetRecv::processPetData(Net::MessageIn &msg) const BeingId id = msg.readBeingId("pet id"); Being *const dstBeing = actorManager->findBeing(id); const int data = msg.readInt32("data"); - if (!cmd) // pre init + if (cmd == 0) // pre init { PetInfo *const info = new PetInfo; info->id = id; @@ -112,7 +112,7 @@ void PetRecv::processPetData(Net::MessageIn &msg) return; } PetInfo *const info = PlayerInfo::getPet(); - if (!info) + if (info == nullptr) return; switch (cmd) { @@ -150,7 +150,7 @@ void PetRecv::processPetStatus(Net::MessageIn &msg) // being->setLevel(level); PetInfo *const info = PlayerInfo::getPet(); - if (!info) + if (info == nullptr) return; info->name = name; info->level = level; @@ -167,7 +167,7 @@ void PetRecv::processPetFood(Net::MessageIn &msg) { const int result = msg.readUInt8("result"); msg.readInt16("food id"); - if (result) + if (result != 0) NotifyManager::notify(NotifyTypes::PET_FEED_OK); else NotifyManager::notify(NotifyTypes::PET_FEED_ERROR); diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp index 818fffde9..ef7afa6e4 100644 --- a/src/net/eathena/playerhandler.cpp +++ b/src/net/eathena/playerhandler.cpp @@ -101,7 +101,7 @@ 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); @@ -203,7 +203,7 @@ void PlayerHandler::pickUp(const FloorItem *const floorItem) const EAthena::InventoryHandler *const handler = static_cast<EAthena::InventoryHandler*>(inventoryHandler); - if (handler) + if (handler != nullptr) handler->pushPickup(floorItem->getId()); } @@ -543,11 +543,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( @@ -558,11 +558,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); @@ -580,7 +580,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(); @@ -588,7 +588,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/eathena/playerrecv.cpp b/src/net/eathena/playerrecv.cpp index 36ee19018..9eb57b687 100644 --- a/src/net/eathena/playerrecv.cpp +++ b/src/net/eathena/playerrecv.cpp @@ -79,7 +79,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")); @@ -91,7 +91,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")); @@ -103,7 +103,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")); @@ -115,7 +115,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")); @@ -127,7 +127,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")); @@ -139,7 +139,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")); @@ -191,12 +191,12 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) void PlayerRecv::processPlayerGetExp(Net::MessageIn &msg) { - if (!localPlayer) + if (localPlayer == nullptr) return; const BeingId id = msg.readBeingId("player id"); const int exp = msg.readInt32("exp amount"); const int stat = msg.readInt16("exp type"); - const bool fromQuest = msg.readInt16("is from quest"); + const bool fromQuest = msg.readInt16("is from quest") != 0; if (!fromQuest && id == localPlayer->getId()) { if (stat == 1) @@ -221,7 +221,7 @@ void PlayerRecv::processWalkResponse(Net::MessageIn &msg) msg.readInt32("tick"); msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path"); msg.readUInt8("(sx<<4) | (sy&0x0f)"); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->setRealPos(dstX, dstY); BLOCK_END("PlayerRecv::processWalkResponse") } @@ -231,7 +231,7 @@ void PlayerRecv::processWalkError(Net::MessageIn &msg) msg.readInt32("tick"); const int x = msg.readInt16("x"); const int y = msg.readInt16("y"); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->failMove(x, y); } @@ -247,7 +247,7 @@ void PlayerRecv::processPvpInfo(Net::MessageIn &msg) void PlayerRecv::processPlayerHeal(Net::MessageIn &msg) { - if (!localPlayer) + if (localPlayer == nullptr) return; const int type = msg.readInt16("var id"); @@ -261,11 +261,11 @@ void PlayerRecv::processPlayerHeal(Net::MessageIn &msg) const int base = PlayerInfo::getAttribute(Attributes::PLAYER_HP) + amount; 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( @@ -390,23 +390,23 @@ void PlayerRecv::processPlayerRankPoints(Net::MessageIn &msg) void PlayerRecv::processOnlineList(Net::MessageIn &msg) { - if (!whoIsOnline) + if (whoIsOnline == nullptr) return; BLOCK_START("PlayerRecv::processOnlineList") const int size = msg.readInt16("len") - 4; std::vector<OnlinePlayer*> arr; - if (!size) + if (size == 0) { - if (whoIsOnline) + if (whoIsOnline != nullptr) whoIsOnline->loadList(arr); BLOCK_END("PlayerRecv::processOnlineList") return; } char *const start = reinterpret_cast<char*>(msg.readBytes(size, "nicks")); - if (!start) + if (start == nullptr) { BLOCK_END("PlayerRecv::processOnlineList") return; @@ -417,7 +417,7 @@ void PlayerRecv::processOnlineList(Net::MessageIn &msg) int addVal = 3; while (buf - start + 1 < size - && *(buf + CAST_SIZE(addVal))) + && (*(buf + CAST_SIZE(addVal)) != 0)) { const unsigned char status = *buf; buf ++; @@ -429,9 +429,9 @@ void PlayerRecv::processOnlineList(Net::MessageIn &msg) GenderT gender = Gender::UNSPECIFIED; if (config.getBoolValue("showgender")) { - if (status & BeingFlag::GENDER_MALE) + if ((status & BeingFlag::GENDER_MALE) != 0) gender = Gender::MALE; - else if (status & BeingFlag::GENDER_OTHER) + else if ((status & BeingFlag::GENDER_OTHER) != 0) gender = Gender::OTHER; else gender = Gender::FEMALE; @@ -441,7 +441,7 @@ void PlayerRecv::processOnlineList(Net::MessageIn &msg) buf += strlen(buf) + 1; } - if (whoIsOnline) + if (whoIsOnline != nullptr) whoIsOnline->loadList(arr); delete [] start; BLOCK_END("PlayerRecv::processOnlineList") @@ -466,7 +466,7 @@ void PlayerRecv::processKilledBy(Net::MessageIn &msg) else { std::string name; - if (dstBeing) + if (dstBeing != nullptr) name = dstBeing->getName(); else name = strprintf("?%u", CAST_U32(id)); diff --git a/src/net/eathena/questrecv.cpp b/src/net/eathena/questrecv.cpp index 19ba546a3..69ad93541 100644 --- a/src/net/eathena/questrecv.cpp +++ b/src/net/eathena/questrecv.cpp @@ -49,12 +49,12 @@ void QuestRecv::processAddQuest(Net::MessageIn &msg) msg.skipToEnd("unused"); - 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); @@ -70,12 +70,12 @@ void QuestRecv::processAddQuest2(Net::MessageIn &msg) const int val3 = msg.readInt32("count3"); const int time = msg.readInt32("time"); - if (questsWindow) + if (questsWindow != nullptr) { questsWindow->updateQuest(var, val1, val2, val3, time); questsWindow->rebuild(true); } - if (skillDialog) + if (skillDialog != nullptr) { skillDialog->updateQuest(var, val1, val2, val3, time); skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID); @@ -96,13 +96,13 @@ void QuestRecv::processAddQuests(Net::MessageIn &msg) msg.readInt32("time"); msg.readInt16("objectives count"); } - 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); } @@ -118,13 +118,13 @@ void QuestRecv::processAddQuests2(Net::MessageIn &msg) const int val2 = msg.readInt32("count2"); const int val3 = msg.readInt32("count3"); const int time = msg.readInt32("time"); - if (questsWindow) + if (questsWindow != nullptr) questsWindow->updateQuest(var, val1, val2, val3, time); - if (skillDialog) + if (skillDialog != nullptr) skillDialog->updateQuest(var, val1, val2, val3, time); } - if (questsWindow) + if (questsWindow != nullptr) questsWindow->rebuild(false); } @@ -170,12 +170,12 @@ void QuestRecv::processRemoveQuest(Net::MessageIn &msg) // not removing quest, because this is impossible, // but changing status to -1 - 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); diff --git a/src/net/eathena/skillrecv.cpp b/src/net/eathena/skillrecv.cpp index a7db7fa29..e4b71a076 100644 --- a/src/net/eathena/skillrecv.cpp +++ b/src/net/eathena/skillrecv.cpp @@ -71,7 +71,7 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg) const int skillCount = (msg.getLength() - 4) / sz; int updateSkill = 0; - if (skillDialog) + if (skillDialog != nullptr) skillDialog->hideSkills(SkillOwner::Player); for (int k = 0; k < skillCount; k++) { @@ -86,10 +86,10 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg) const std::string name = msg.readString(24, "skill name"); 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)) { @@ -98,10 +98,10 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg) } } } - if (skillDialog) + if (skillDialog != nullptr) { skillDialog->update(); - if (updateSkill) + if (updateSkill != 0) skillDialog->playUpdateEffect(updateSkill); } } @@ -118,10 +118,10 @@ void SkillRecv::processSkillAdd(Net::MessageIn &msg) const std::string name = msg.readString(24, "skill name"); 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)) { @@ -129,7 +129,7 @@ void SkillRecv::processSkillAdd(Net::MessageIn &msg) skillId, name, level, range, up, inf, sp); } skillDialog->update(); - if (updateSkill) + if (updateSkill != 0) skillDialog->playUpdateEffect(updateSkill); } } @@ -148,10 +148,10 @@ void SkillRecv::processSkillAdd2(Net::MessageIn &msg) const std::string name = msg.readString(24, "skill name"); 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)) { @@ -159,7 +159,7 @@ void SkillRecv::processSkillAdd2(Net::MessageIn &msg) skillId, name, level, range, up, inf, sp); } skillDialog->update(); - if (updateSkill) + if (updateSkill != 0) skillDialog->playUpdateEffect(updateSkill); } } @@ -175,10 +175,10 @@ void SkillRecv::processSkillUpdate(Net::MessageIn &msg) const int range = msg.readInt16("range"); 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)) { @@ -186,7 +186,7 @@ void SkillRecv::processSkillUpdate(Net::MessageIn &msg) skillId, "", level, range, up, inf, sp); } skillDialog->update(); - if (updateSkill) + if (updateSkill != 0) skillDialog->playUpdateEffect(updateSkill); } } @@ -204,10 +204,10 @@ void SkillRecv::processSkillUpdate2(Net::MessageIn &msg) const int range = msg.readInt16("range"); 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)) { @@ -215,7 +215,7 @@ void SkillRecv::processSkillUpdate2(Net::MessageIn &msg) skillId, "", level, range, up, inf, sp); } skillDialog->update(); - if (updateSkill) + if (updateSkill != 0) skillDialog->playUpdateEffect(updateSkill); } } @@ -228,11 +228,11 @@ void SkillRecv::processSkillDelete(Net::MessageIn &msg) if (oldLevel != 0) updateSkill = skillId; PlayerInfo::setSkillLevel(skillId, 0); - if (skillDialog) + if (skillDialog != nullptr) { skillDialog->removeSkill(skillId); skillDialog->update(); - if (updateSkill) + if (updateSkill != 0) skillDialog->playRemoveEffect(updateSkill); } } @@ -241,7 +241,7 @@ void SkillRecv::processSkillCoolDown(Net::MessageIn &msg) { const int skillId = msg.readInt16("skill id"); const int duration = msg.readInt32("duration"); - if (skillDialog) + if (skillDialog != nullptr) skillDialog->setSkillDuration(SkillOwner::Player, skillId, duration); } @@ -259,7 +259,7 @@ void SkillRecv::processSkillCoolDownList(Net::MessageIn &msg) if (msg.getVersion() >= 20120604) msg.readInt32("total"); const int duration = msg.readInt32("duration"); - if (skillDialog) + if (skillDialog != nullptr) { skillDialog->setSkillDuration(SkillOwner::Player, skillId, duration); @@ -281,19 +281,19 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) logger->log("Action: %d/%d", bskill, success); } - if (localPlayer) + if (localPlayer != nullptr) localPlayer->stopCast(true); std::string txt; if (success == CAST_S32(SKILL_FAILED) && bskill != 0) { - if (localPlayer && bskill == CAST_S32(BSKILL_EMOTE) + if ((localPlayer != nullptr) && bskill == CAST_S32(BSKILL_EMOTE) && reason == CAST_S32(RFAIL_SKILLDEP)) { localPlayer->stopAdvert(); } const SkillInfo *const info = skillDialog->getSkill(bskill); - if (info) + if (info != nullptr) { txt = info->errorText; } @@ -306,7 +306,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) else { const SkillInfo *const info = skillDialog->getSkill(skillId); - if (info) + if (info != nullptr) { txt = info->errorText + "."; } diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp index 9db89dae4..65cb72cc8 100644 --- a/src/net/eathena/tradehandler.cpp +++ b/src/net/eathena/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; TradeRecv::mItemIndex = item->getInvIndex(); diff --git a/src/net/eathena/traderecv.cpp b/src/net/eathena/traderecv.cpp index 2dcacc609..ac64d4fb0 100644 --- a/src/net/eathena/traderecv.cpp +++ b/src/net/eathena/traderecv.cpp @@ -101,7 +101,7 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) } } - if (tradeWindow) + if (tradeWindow != nullptr) { if (type == 0) { @@ -138,9 +138,9 @@ void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg) { Item *const item = PlayerInfo::getInventory()->getItem( mItemIndex); - if (!item) + if (item == nullptr) return; - if (tradeWindow) + if (tradeWindow != nullptr) { tradeWindow->addItem2(item->getId(), item->getType(), diff --git a/src/net/eathena/updateprotocol.cpp b/src/net/eathena/updateprotocol.cpp index 43b65c80c..afe25b874 100644 --- a/src/net/eathena/updateprotocol.cpp +++ b/src/net/eathena/updateprotocol.cpp @@ -41,7 +41,7 @@ void updateProtocol() #include "net/eathena/packetsout.inc" #undef packet Network *const network = Network::mInstance; - if (network) + if (network != nullptr) { network->clearHandlers(); network->registerHandlers(); diff --git a/src/net/eathena/vendinghandler.cpp b/src/net/eathena/vendinghandler.cpp index 307018680..e9d0643a3 100644 --- a/src/net/eathena/vendinghandler.cpp +++ b/src/net/eathena/vendinghandler.cpp @@ -52,7 +52,7 @@ void VendingHandler::close() const void VendingHandler::open(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_VENDING_LIST_REQ); @@ -63,7 +63,7 @@ void VendingHandler::buy(const Being *const being, const int index, const int amount) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_VENDING_BUY); @@ -83,7 +83,7 @@ void VendingHandler::buyItems(const Being *const being, { ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); - if (!usedQuantity) + if (usedQuantity == 0) continue; cnt ++; } @@ -98,7 +98,7 @@ void VendingHandler::buyItems(const Being *const being, { ShopItem *const item = *it; const int usedQuantity = item->getUsedQuantity(); - if (!usedQuantity) + if (usedQuantity == 0) continue; item->increaseQuantity(usedQuantity); item->increaseUsedQuantity(-usedQuantity); @@ -113,7 +113,7 @@ void VendingHandler::buy2(const Being *const being, const int index, const int amount) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_VENDING_BUY2); diff --git a/src/net/eathena/vendingrecv.cpp b/src/net/eathena/vendingrecv.cpp index bf0cd20eb..23d4843f1 100644 --- a/src/net/eathena/vendingrecv.cpp +++ b/src/net/eathena/vendingrecv.cpp @@ -77,7 +77,7 @@ void VendingRecv::processShowBoard(Net::MessageIn &msg) const BeingId id = msg.readBeingId("owner id"); const std::string shopName = msg.readString(80, "shop name"); Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setSellBoard(shopName); } @@ -85,7 +85,7 @@ void VendingRecv::processHideBoard(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("owner id"); Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setSellBoard(std::string()); if (dstBeing == localPlayer) { @@ -106,7 +106,7 @@ void VendingRecv::processItemsList(Net::MessageIn &msg) const int count = (msg.readInt16("len") - offset) / packetLen; const BeingId id = msg.readBeingId("id"); const Being *const being = actorManager->findBeing(id); - if (!being) + if (being == nullptr) return; int cards[maxCards]; CREATEWIDGETV(mBuyDialog, BuyDialog, being, DEFAULT_CURRENCY); @@ -142,7 +142,7 @@ void VendingRecv::processItemsList(Net::MessageIn &msg) const ItemColor color = ItemColorManager::getColorFromCards(&cards[0]); ShopItem *const item = mBuyDialog->addItem(itemId, type, color, amount, value); - if (item) + if (item != nullptr) { item->setInvIndex(index); item->setOptions(options); @@ -230,10 +230,10 @@ void VendingRecv::processReport(Net::MessageIn &msg) money = msg.readInt32("zeny"); } const Inventory *const inventory = PlayerInfo::getCartInventory(); - if (!inventory) + if (inventory == nullptr) return; const Item *const item = inventory->getItem(index); - if (!item) + if (item == nullptr) return; const ItemInfo &info = item->getInfo(); |