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 | |
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')
101 files changed, 986 insertions, 971 deletions
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index beca46eff..c6bef957c 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -35,13 +35,13 @@ CharCreateDialog *CharServerHandler::mCharCreateDialog = nullptr; void CharServerHandler::updateCharSelectDialog() { - if (mCharSelectDialog) + if (mCharSelectDialog != nullptr) mCharSelectDialog->setCharacters(mCharacters); } void CharServerHandler::unlockCharSelectDialog() { - if (mCharSelectDialog) + if (mCharSelectDialog != nullptr) mCharSelectDialog->unlock(); } diff --git a/src/net/download.cpp b/src/net/download.cpp index 5e3ffebf6..7dbb06e3c 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -73,12 +73,12 @@ Download::Download(void *const ptr, mUpload(isUpload), mIsXml(isXml) { - if (mError) + if (mError != nullptr) mError[0] = 0; mOptions.cancel = 0; mOptions.memoryWrite = 0; - mOptions.checkAdler = true; + mOptions.checkAdler = 1u; if (!mUpload) { const std::string serverName = settings.serverName; @@ -96,20 +96,20 @@ Download::Download(void *const ptr, Download::~Download() { - if (mFormPost) + if (mFormPost != nullptr) { curl_formfree(mFormPost); mFormPost = nullptr; } - if (mHeaders) + if (mHeaders != nullptr) { curl_slist_free_all(mHeaders); mHeaders = nullptr; } int status; - if (mThread && SDL_GetThreadID(mThread)) + if ((mThread != nullptr) && (SDL_GetThreadID(mThread) != 0u)) SDL_WaitThread(mThread, &status); mThread = nullptr; free(mError); @@ -120,7 +120,7 @@ Download::~Download() */ unsigned long Download::fadler32(FILE *const file) { - if (!file) + if (file == nullptr) return 0; // Obtain file size @@ -169,7 +169,7 @@ void Download::setFile(const std::string &filename, const int64_t adler32) if (adler32 > -1) { mAdler = static_cast<unsigned long>(adler32); - mOptions.checkAdler = true; + mOptions.checkAdler = 1u; } else { @@ -179,7 +179,7 @@ void Download::setFile(const std::string &filename, const int64_t adler32) void Download::setWriteFunction(WriteFunction write) { - mOptions.memoryWrite = true; + mOptions.memoryWrite = 1u; mWriteFunction = write; } @@ -188,10 +188,10 @@ bool Download::start() logger->log("Starting download: %s", mUrl.c_str()); mThread = SDL::createThread(&downloadThread, "download", this); - if (!mThread) + if (mThread == nullptr) { logger->log1(DOWNLOAD_ERROR_MESSAGE_THREAD); - if (mError) + if (mError != nullptr) strcpy(mError, DOWNLOAD_ERROR_MESSAGE_THREAD); mUpdateFunction(mPtr, DownloadStatus::ThreadError, 0, 0); if (!mIgnoreError) @@ -205,8 +205,8 @@ void Download::cancel() { logger->log("Canceling download: %s", mUrl.c_str()); - mOptions.cancel = true; - if (mThread && SDL_GetThreadID(mThread)) + mOptions.cancel = 1u; + if ((mThread != nullptr) && (SDL_GetThreadID(mThread) != 0u)) SDL_WaitThread(mThread, nullptr); mThread = nullptr; @@ -222,13 +222,13 @@ int Download::downloadProgress(void *clientp, double dltotal, double dlnow, { Download *const d = reinterpret_cast<Download *>(clientp); - if (!d) + if (d == nullptr) return -5; if (d->mUpload) return 0; - if (d->mOptions.cancel) + if (d->mOptions.cancel != 0u) { return d->mUpdateFunction(d->mPtr, DownloadStatus::Cancelled, CAST_SIZE(dltotal), @@ -247,7 +247,7 @@ int Download::downloadThread(void *ptr) Download *const d = reinterpret_cast<Download*>(ptr); CURLcode res; - if (!d) + if (d == nullptr) return 0; std::string outFilename; @@ -258,7 +258,7 @@ int Download::downloadThread(void *ptr) } else { - if (!d->mOptions.memoryWrite) + if (d->mOptions.memoryWrite == 0u) outFilename = d->mFileName + ".part"; else outFilename.clear(); @@ -274,12 +274,12 @@ int Download::downloadThread(void *ptr) logger->log_r("selected url: %s", d->mUrl.c_str()); while (attempts < 3 && !complete && - !d->mOptions.cancel && + (d->mOptions.cancel == 0u) && isTerminate == false) { d->mUpdateFunction(d->mPtr, DownloadStatus::Starting, 0, 0); - if (d->mOptions.cancel || isTerminate == true) + if ((d->mOptions.cancel != 0u) || isTerminate == true) { // need terminate thread? d->mThread = nullptr; @@ -287,7 +287,9 @@ int Download::downloadThread(void *ptr) } d->mCurl = curl_easy_init(); - if (d->mCurl && !d->mOptions.cancel && isTerminate == false) + if (d->mCurl != nullptr && + d->mOptions.cancel == 0u && + isTerminate == false) { FILE *file = nullptr; @@ -306,7 +308,7 @@ int Download::downloadThread(void *ptr) curl_easy_setopt(d->mCurl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(d->mCurl, CURLOPT_HTTPHEADER, d->mHeaders); - if (d->mOptions.memoryWrite) + if (d->mOptions.memoryWrite != 0u) { curl_easy_setopt(d->mCurl, CURLOPT_FAILONERROR, 1); curl_easy_setopt(d->mCurl, CURLOPT_WRITEFUNCTION, @@ -316,7 +318,7 @@ int Download::downloadThread(void *ptr) else { file = fopen(outFilename.c_str(), "w+b"); - if (file) + if (file != nullptr) { curl_easy_setopt(d->mCurl, CURLOPT_WRITEDATA, file); @@ -343,7 +345,7 @@ int Download::downloadThread(void *ptr) } if ((res = curl_easy_perform(d->mCurl)) != 0 && - !d->mOptions.cancel && + (d->mOptions.cancel == 0u) && isTerminate == false) { PRAGMA45(GCC diagnostic push) @@ -351,7 +353,7 @@ int Download::downloadThread(void *ptr) switch (res) { case CURLE_ABORTED_BY_CALLBACK: - d->mOptions.cancel = true; + d->mOptions.cancel = 1u; break; case CURLE_COULDNT_CONNECT: default: @@ -359,9 +361,9 @@ int Download::downloadThread(void *ptr) } PRAGMA45(GCC diagnostic pop) - if (res) + if (res != 0u) { - if (d->mError) + if (d->mError != nullptr) { logger->log_r("curl error %d: %s host: %s", res, d->mError, d->mUrl.c_str()); @@ -370,17 +372,17 @@ int Download::downloadThread(void *ptr) continue; } - if (d->mOptions.cancel || isTerminate == true) + if ((d->mOptions.cancel != 0u) || isTerminate == true) break; // d->mUpdateFunction(d->mPtr, DownloadStatus::Error, 0, 0); - if (file) + if (file != nullptr) { fclose(file); file = nullptr; } - if (!d->mUpload && !d->mOptions.memoryWrite) + if (!d->mUpload && (d->mOptions.memoryWrite == 0u)) ::remove(outFilename.c_str()); attempts++; continue; @@ -391,7 +393,7 @@ int Download::downloadThread(void *ptr) if (d->mUpload) { - if (file) + if (file != nullptr) { fclose(file); file = nullptr; @@ -401,16 +403,16 @@ int Download::downloadThread(void *ptr) } else { - if (!d->mOptions.memoryWrite) + if (d->mOptions.memoryWrite == 0u) { // Don't check resources.xml checksum - if (d->mOptions.checkAdler) + if (d->mOptions.checkAdler != 0u) { const unsigned long adler = fadler32(file); if (d->mAdler != adler) { - if (file) + if (file != nullptr) { fclose(file); file = nullptr; @@ -427,7 +429,7 @@ int Download::downloadThread(void *ptr) } } - if (file) + if (file != nullptr) { fclose(file); file = nullptr; @@ -435,7 +437,7 @@ int Download::downloadThread(void *ptr) // Any existing file with this name is deleted first, // otherwise the rename will fail on Windows. - if (!d->mOptions.cancel && isTerminate == false) + if ((d->mOptions.cancel == 0u) && isTerminate == false) { if (d->mIsXml) { @@ -453,7 +455,7 @@ int Download::downloadThread(void *ptr) // Check if we can open it and no errors were // encountered during renaming file = fopen(d->mFileName.c_str(), "rb"); - if (file) + if (file != nullptr) { fclose(file); file = nullptr; @@ -469,13 +471,13 @@ int Download::downloadThread(void *ptr) } } - if (d->mCurl) + if (d->mCurl != nullptr) { curl_easy_cleanup(d->mCurl); d->mCurl = nullptr; } - if (d->mOptions.cancel || isTerminate == true) + if ((d->mOptions.cancel != 0u) || isTerminate == true) { // need ternibate thread? d->mThread = nullptr; @@ -484,13 +486,13 @@ int Download::downloadThread(void *ptr) attempts++; } - if ((complete && attempts < 3) || d->mOptions.cancel) + if ((complete && attempts < 3) || (d->mOptions.cancel != 0u)) break; } d->mThread = nullptr; - if (d->mOptions.cancel || isTerminate == true) + if ((d->mOptions.cancel != 0u) || isTerminate == true) { // Nothing to do... } @@ -509,7 +511,7 @@ int Download::downloadThread(void *ptr) void Download::addProxy(CURL *const curl) { const int mode = config.getIntValue("downloadProxyType"); - if (!mode) + if (mode == 0) return; if (mode > 1) diff --git a/src/net/ea/beingrecv.cpp b/src/net/ea/beingrecv.cpp index 756bdbfc2..2c5eab9e3 100644 --- a/src/net/ea/beingrecv.cpp +++ b/src/net/ea/beingrecv.cpp @@ -59,7 +59,7 @@ namespace BeingRecv void BeingRecv::processBeingRemove(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingRemove") - if (!actorManager || !localPlayer) + if ((actorManager == nullptr) || (localPlayer == nullptr)) { BLOCK_END("BeingRecv::processBeingRemove") return; @@ -70,7 +70,7 @@ void BeingRecv::processBeingRemove(Net::MessageIn &msg) const BeingId id = msg.readBeingId("being id"); const uint8_t type = msg.readUInt8("remove flag"); Being *const dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processBeingRemove") return; @@ -94,14 +94,14 @@ void BeingRecv::processBeingRemove(Net::MessageIn &msg) else if (type == 0U && dstBeing->getType() == ActorType::Npc) { const BeingInfo *const info = dstBeing->getInfo(); - if (!info || info->getAllowDelete()) + if ((info == nullptr) || (info->getAllowDelete() != 0)) actorManager->destroy(dstBeing); } else { if (dstBeing->getType() == ActorType::Player) { - if (socialWindow) + if (socialWindow != nullptr) socialWindow->updateActiveList(); const std::string name = dstBeing->getName(); if (!name.empty() && config.getBoolValue("logPlayerActions")) @@ -147,7 +147,7 @@ void BeingRecv::processBeingRemove(Net::MessageIn &msg) void BeingRecv::processBeingAction(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingAction") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingAction") return; @@ -174,16 +174,16 @@ void BeingRecv::processBeingAction(Net::MessageIn &msg) case AttackType::MULTI: // Critical Damage case AttackType::REFLECT: // Reflected Damage case AttackType::FLEE: // Lucky Dodge - 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, @@ -198,26 +198,26 @@ void BeingRecv::processBeingAction(Net::MessageIn &msg) // srcBeing->setAction(BeingAction::DEAD, 0); 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); @@ -242,7 +242,7 @@ void BeingRecv::processBeingAction(Net::MessageIn &msg) void BeingRecv::processBeingEmotion(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingEmotion") - if (!localPlayer || !actorManager) + if ((localPlayer == nullptr) || (actorManager == nullptr)) { BLOCK_END("BeingRecv::processBeingEmotion") return; @@ -250,7 +250,7 @@ void BeingRecv::processBeingEmotion(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("being id")); - if (!dstBeing) + if (dstBeing == nullptr) { DEBUGLOGSTR("invisible player?"); msg.readUInt8("emote"); @@ -259,7 +259,7 @@ void BeingRecv::processBeingEmotion(Net::MessageIn &msg) } const uint8_t emote = msg.readUInt8("emote"); - if (emote && + if ((emote != 0u) && player_relations.hasPermission(dstBeing, PlayerRelation::EMOTE)) { dstBeing->setEmote(emote, 0); @@ -273,7 +273,7 @@ void BeingRecv::processBeingEmotion(Net::MessageIn &msg) void BeingRecv::processNameResponse(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processNameResponse") - if (!localPlayer || !actorManager) + if ((localPlayer == nullptr) || (actorManager == nullptr)) { BLOCK_END("BeingRecv::processNameResponse") return; @@ -285,7 +285,7 @@ void BeingRecv::processNameResponse(Net::MessageIn &msg) actorManager->updateNameId(name, beingId); - if (dstBeing) + if (dstBeing != nullptr) { if (beingId == localPlayer->getId()) { @@ -297,10 +297,10 @@ void BeingRecv::processNameResponse(Net::MessageIn &msg) { dstBeing->setName(name); } - else if (viewport) + else if (viewport != nullptr) { Map *const map = viewport->getMap(); - if (map) + if (map != nullptr) { map->addPortalTile(name, MapItemType::PORTAL, dstBeing->getTileX(), dstBeing->getTileY()); @@ -312,15 +312,15 @@ void BeingRecv::processNameResponse(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); @@ -335,7 +335,7 @@ void BeingRecv::processNameResponse(Net::MessageIn &msg) void BeingRecv::processPlayerStop(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerStop") - if (!actorManager || !localPlayer) + if ((actorManager == nullptr) || (localPlayer == nullptr)) { BLOCK_END("BeingRecv::processPlayerStop") return; @@ -346,7 +346,7 @@ void BeingRecv::processPlayerStop(Net::MessageIn &msg) if (mSync || id != localPlayer->getId()) { Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) { const uint16_t x = msg.readInt16("x"); const uint16_t y = msg.readInt16("y"); @@ -372,7 +372,7 @@ void BeingRecv::processPlayerMoveToAttack(Net::MessageIn &msg) msg.readInt16("y"); msg.readInt16("attack range"); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->fixAttackTarget(); BLOCK_END("BeingRecv::processPlayerStop") } @@ -391,7 +391,7 @@ void BeingRecv::processSkillNoDamage(Net::MessageIn &msg) msg.readBeingId("src being id")); msg.readUInt8("fail"); - if (srcBeing) + if (srcBeing != nullptr) srcBeing->handleSkill(dstBeing, heal, id, 1); } @@ -399,14 +399,14 @@ void BeingRecv::processPvpMapMode(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPvpMapMode") const Game *const game = Game::instance(); - if (!game) + if (game == nullptr) { BLOCK_END("BeingRecv::processPvpMapMode") return; } Map *const map = game->getCurrentMap(); - if (map) + if (map != nullptr) map->setPvpMode(msg.readInt16("pvp mode")); BLOCK_END("BeingRecv::processPvpMapMode") } @@ -414,7 +414,7 @@ void BeingRecv::processPvpMapMode(Net::MessageIn &msg) void BeingRecv::processBeingMove3(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingMove3") - if (!actorManager || !serverFeatures->haveMove3()) + if ((actorManager == nullptr) || !serverFeatures->haveMove3()) { BLOCK_END("BeingRecv::processBeingMove3") return; @@ -426,7 +426,7 @@ void BeingRecv::processBeingMove3(Net::MessageIn &msg) const int len = msg.readInt16("len") - 14; Being *const dstBeing = actorManager->findBeing( msg.readBeingId("being id")); - if (!dstBeing || dstBeing == localPlayer) + if ((dstBeing == nullptr) || dstBeing == localPlayer) { DEBUGLOGSTR("invisible player?"); msg.readInt16("speed"); @@ -443,7 +443,7 @@ void BeingRecv::processBeingMove3(Net::MessageIn &msg) const unsigned char *moves = msg.readBytes(len, "moving path"); Path path; - if (moves) + if (moves != nullptr) { int x2 = dstBeing->getCachedX(); int y2 = dstBeing->getCachedY(); @@ -496,7 +496,7 @@ void BeingRecv::processBeingMove3(Net::MessageIn &msg) Being *BeingRecv::createBeing(const BeingId id, const int job) { - if (!actorManager) + if (actorManager == nullptr) return nullptr; ActorTypeT type = ActorType::Unknown; diff --git a/src/net/ea/buysellrecv.cpp b/src/net/ea/buysellrecv.cpp index ad09d2076..09109a540 100644 --- a/src/net/ea/buysellrecv.cpp +++ b/src/net/ea/buysellrecv.cpp @@ -79,7 +79,7 @@ void BuySellRecv::processNpcSell(Net::MessageIn &msg) const Item *const item = PlayerInfo::getInventory() ->getItem(index); - if (item && item->isEquipped() == Equipped_false) + if ((item != nullptr) && item->isEquipped() == Equipped_false) dialog->addItem(item, value); } } diff --git a/src/net/ea/charserverrecv.cpp b/src/net/ea/charserverrecv.cpp index 4c249b1ec..7f27a6d2e 100644 --- a/src/net/ea/charserverrecv.cpp +++ b/src/net/ea/charserverrecv.cpp @@ -111,7 +111,7 @@ void CharServerRecv::processCharCreateFailed(Net::MessageIn &msg) ShowCenter_true, nullptr, 260); - if (charServerHandler->mCharCreateDialog) + if (charServerHandler->mCharCreateDialog != nullptr) charServerHandler->mCharCreateDialog->unlock(); BLOCK_END("CharServerRecv::processCharCreateFailed") } diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 300a063aa..c9f18ad86 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -36,7 +36,7 @@ ChatHandler::ChatHandler() if (!ChatRecv::mSentWhispers.empty()) ChatRecv::mSentWhispers.pop(); ChatRecv::mMotdTime = 0; - ChatRecv::mShowAllLang = serverConfig.getValue("showAllLang", 0); + ChatRecv::mShowAllLang = (serverConfig.getValue("showAllLang", 0) != 0); ChatRecv::mShowMotd = config.getBoolValue("showmotd"); ChatRecv::mSkipping = true; } diff --git a/src/net/ea/chatrecv.cpp b/src/net/ea/chatrecv.cpp index af01fd75b..87db3fa98 100644 --- a/src/net/ea/chatrecv.cpp +++ b/src/net/ea/chatrecv.cpp @@ -87,7 +87,7 @@ void ChatRecv::processWhisperResponseContinue(Net::MessageIn &msg, // Success (don't need to report) break; case 0x01: - if (chatWindow) + if (chatWindow != nullptr) { chatWindow->addWhisper(nick, // TRANSLATORS: chat message @@ -97,7 +97,7 @@ void ChatRecv::processWhisperResponseContinue(Net::MessageIn &msg, } break; case 0x02: - if (chatWindow) + if (chatWindow != nullptr) { chatWindow->addWhisper(nick, // TRANSLATORS: chat message @@ -107,7 +107,7 @@ void ChatRecv::processWhisperResponseContinue(Net::MessageIn &msg, } break; case 0x03: - if (chatWindow) + if (chatWindow != nullptr) { chatWindow->addWhisper(nick, // TRANSLATORS: chat message @@ -128,10 +128,12 @@ void ChatRecv::processMVPEffect(Net::MessageIn &msg) BLOCK_START("ChatRecv::processMVPEffect") // Display MVP player const BeingId id = msg.readBeingId("being id"); - if (localChatTab && actorManager && config.getBoolValue("showMVP")) + if (localChatTab != nullptr && + actorManager != nullptr && + config.getBoolValue("showMVP")) { const Being *const being = actorManager->findBeing(id); - if (!being) + if (being == nullptr) NotifyManager::notify(NotifyTypes::MVP_PLAYER, ""); else NotifyManager::notify(NotifyTypes::MVP_PLAYER, being->getName()); @@ -144,7 +146,7 @@ void ChatRecv::processIgnoreAllResponse(Net::MessageIn &msg) BLOCK_START("ChatRecv::processIgnoreAllResponse") const uint8_t action = msg.readUInt8("action"); const uint8_t fail = msg.readUInt8("result"); - if (!localChatTab) + if (localChatTab == nullptr) { BLOCK_END("ChatRecv::processIgnoreAllResponse") return; diff --git a/src/net/ea/equipbackend.h b/src/net/ea/equipbackend.h index 7641a5a2e..49d2b0377 100644 --- a/src/net/ea/equipbackend.h +++ b/src/net/ea/equipbackend.h @@ -51,7 +51,7 @@ class EquipBackend final : public Equipment::Backend return nullptr; const Inventory *const inv = PlayerInfo::getInventory(); - if (inv) + if (inv != nullptr) return inv->getItem(invyIndex); else return nullptr; @@ -60,14 +60,14 @@ class EquipBackend final : public Equipment::Backend void clear() override final { Inventory *const inv = PlayerInfo::getInventory(); - if (!inv) + if (inv == nullptr) return; for (int i = 0; i < EQUIPMENT_SIZE; i++) { if (mEquipment[i] != -1) { Item* item = inv->getItem(i); - if (item) + if (item != nullptr) item->setEquipped(Equipped_false); } @@ -78,7 +78,7 @@ class EquipBackend final : public Equipment::Backend void setEquipment(const int index, const int inventoryIndex) { Inventory *const inv = PlayerInfo::getInventory(); - if (!inv) + if (inv == nullptr) return; if (index < 0 || index >= EQUIPMENT_SIZE) @@ -87,17 +87,17 @@ class EquipBackend final : public Equipment::Backend // Unequip existing item Item *item = inv->getItem(mEquipment[index]); - if (item) + if (item != nullptr) item->setEquipped(Equipped_false); // not checking index because it must be safe mEquipment[index] = inventoryIndex; item = inv->getItem(inventoryIndex); - if (item) + if (item != nullptr) item->setEquipped(Equipped_true); - if (inventoryWindow) + if (inventoryWindow != nullptr) inventoryWindow->updateButtons(); } diff --git a/src/net/ea/gamerecv.cpp b/src/net/ea/gamerecv.cpp index 5078436d0..230e3e012 100644 --- a/src/net/ea/gamerecv.cpp +++ b/src/net/ea/gamerecv.cpp @@ -54,13 +54,13 @@ void GameRecv::processWhoAnswer(Net::MessageIn &msg) void GameRecv::processCharSwitchResponse(Net::MessageIn &msg) { - if (msg.readUInt8("response")) + if (msg.readUInt8("response") != 0u) client->setState(State::SWITCH_CHARACTER); } void GameRecv::processMapQuitResponse(Net::MessageIn &msg) { - if (msg.readInt16("response")) + if (msg.readInt16("response") != 0) { CREATEWIDGET(OkDialog, // TRANSLATORS: error header diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 30b282bb4..fcee70676 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -46,7 +46,7 @@ InventoryHandler::InventoryHandler() : InventoryHandler::~InventoryHandler() { - if (storageWindow) + if (storageWindow != nullptr) { storageWindow->close(); storageWindow = nullptr; @@ -100,7 +100,7 @@ size_t InventoryHandler::getSize(const InventoryTypeT type) const void InventoryHandler::destroyStorage() const { BLOCK_START("InventoryHandler::closeStorage") - if (storageWindow) + if (storageWindow != nullptr) { InventoryWindow *const inv = storageWindow; storageWindow->close(); diff --git a/src/net/ea/inventoryitem.h b/src/net/ea/inventoryitem.h index 3b2799b62..6daa26eb7 100644 --- a/src/net/ea/inventoryitem.h +++ b/src/net/ea/inventoryitem.h @@ -86,7 +86,7 @@ class InventoryItem final favorite(favorite0), equip(equip0) { - if (!cards0) + if (cards0 == nullptr) return; for (int f = 0; f < 4; f ++) cards[f] = cards0[f]; diff --git a/src/net/ea/inventoryrecv.cpp b/src/net/ea/inventoryrecv.cpp index 6ef9f0086..0ccde29d4 100644 --- a/src/net/ea/inventoryrecv.cpp +++ b/src/net/ea/inventoryrecv.cpp @@ -58,7 +58,7 @@ namespace InventoryRecv void InventoryRecv::processPlayerInventoryUse(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerInventoryUse") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; const int index = msg.readInt16("index") - INVENTORY_OFFSET; @@ -67,11 +67,11 @@ void InventoryRecv::processPlayerInventoryUse(Net::MessageIn &msg) const int amount = msg.readInt16("amount"); msg.readUInt8("type"); - if (inventory) + if (inventory != nullptr) { if (Item *const item = inventory->getItem(index)) { - if (amount) + if (amount != 0) item->setQuantity(amount); else inventory->removeItemAt(index); @@ -83,7 +83,7 @@ void InventoryRecv::processPlayerInventoryUse(Net::MessageIn &msg) void InventoryRecv::processItemUseResponse(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processItemUseResponse") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; const int index = msg.readInt16("index") - INVENTORY_OFFSET; @@ -95,11 +95,11 @@ void InventoryRecv::processItemUseResponse(Net::MessageIn &msg) } else { - if (inventory) + if (inventory != nullptr) { if (Item *const item = inventory->getItem(index)) { - if (amount) + if (amount != 0) item->setQuantity(amount); else inventory->removeItemAt(index); @@ -120,7 +120,7 @@ void InventoryRecv::processPlayerStorageStatus(Net::MessageIn &msg) msg.readInt16("used count"); const int size = msg.readInt16("max size"); - if (!mStorage) + if (mStorage == nullptr) mStorage = new Inventory(InventoryType::Storage, size); FOR_EACH (Ea::InventoryItems::const_iterator, it, mInventoryItems) @@ -139,7 +139,7 @@ void InventoryRecv::processPlayerStorageStatus(Net::MessageIn &msg) } mInventoryItems.clear(); - if (!storageWindow) + if (storageWindow == nullptr) { CREATEWIDGETV(storageWindow, InventoryWindow, mStorage); } @@ -151,14 +151,14 @@ void InventoryRecv::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED) BLOCK_START("InventoryRecv::processPlayerStorageClose") // Storage access has been closed // Storage window deletes itself - if (storageWindow) + if (storageWindow != nullptr) { storageWindow->unsetInventory(); storageWindow->close(); } storageWindow = nullptr; - if (mStorage) + if (mStorage != nullptr) mStorage->clear(); delete2(mStorage); @@ -169,7 +169,7 @@ void InventoryRecv::processPlayerAttackRange(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerAttackRange") const int range = msg.readInt16("range"); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->setAttackRange(range); PlayerInfo::setStatBase(Attributes::PLAYER_ATTACK_RANGE, range); PlayerInfo::setStatMod(Attributes::PLAYER_ATTACK_RANGE, 0); diff --git a/src/net/ea/itemrecv.cpp b/src/net/ea/itemrecv.cpp index 11339e7a9..59256535d 100644 --- a/src/net/ea/itemrecv.cpp +++ b/src/net/ea/itemrecv.cpp @@ -35,7 +35,7 @@ namespace Ea void ItemRecv::processItemRemove(Net::MessageIn &msg) { - if (actorManager) + if (actorManager != nullptr) { if (FloorItem *const item = actorManager ->findItem(msg.readBeingId("floor item id"))) diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 68b45ecc8..0596e9952 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -66,7 +66,7 @@ void LoginHandler::getRegistrationDetails() const void LoginHandler::loginAccount(LoginData *const loginData1) const { - if (loginData1) + if (loginData1 != nullptr) { loginData1->resetCharacterSlots(); sendLoginRegister(loginData1->username, loginData1->password, ""); @@ -77,13 +77,13 @@ void LoginHandler::chooseServer(const unsigned int server, const bool persistentIp) const { if (CAST_SIZE(server) >= LoginRecv::mWorlds.size() || - !LoginRecv::mWorlds[server]) + (LoginRecv::mWorlds[server] == nullptr)) { return; } ServerInfo *const charServer = getCharServer(); - if (charServer) + if (charServer != nullptr) { if (config.getBoolValue("usePersistentIP") || persistentIp) { @@ -102,7 +102,7 @@ void LoginHandler::chooseServer(const unsigned int server, void LoginHandler::registerAccount(const LoginData *const loginData1) const { - if (!loginData1) + if (loginData1 == nullptr) return; std::string username = loginData1->username; @@ -138,7 +138,7 @@ void LoginHandler::clearWorlds() const void LoginHandler::loginOrRegister(LoginData *const data) const { - if (!data) + if (data == nullptr) return; logger->log("Username is %s", data->username.c_str()); diff --git a/src/net/ea/maprecv.cpp b/src/net/ea/maprecv.cpp index fce4e975b..dbe9d4559 100644 --- a/src/net/ea/maprecv.cpp +++ b/src/net/ea/maprecv.cpp @@ -41,10 +41,10 @@ void MapRecv::processSetTilesType(Net::MessageIn &msg) const BlockTypeT mask = static_cast<BlockTypeT>(msg.readInt32("mask")); const int layer = msg.readInt32("layer"); const std::string name = msg.readString(16, "map name"); - if (layer) + if (layer != 0) return; Map *const map = viewport->getMap(); - if (map && map->getGatName() == name) + if ((map != nullptr) && map->getGatName() == name) { for (int y = y1; y <= y2; y ++) { diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index 47a09ca97..949d82cf6 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -51,7 +51,7 @@ int networkThread(void *data) { Network *const network = static_cast<Network *>(data); - if (!network || !network->realConnect()) + if ((network == nullptr) || !network->realConnect()) return -1; network->receive(); @@ -125,7 +125,7 @@ bool Network::connect(const ServerInfo &server) mState = CONNECTING; mWorkerThread = SDL::createThread(&networkThread, "network", this); - if (!mWorkerThread) + if (mWorkerThread == nullptr) { setError("Unable to create network worker thread"); return false; @@ -139,13 +139,13 @@ void Network::disconnect() BLOCK_START("Network::disconnect") mState = IDLE; - if (mWorkerThread && SDL_GetThreadID(mWorkerThread)) + if ((mWorkerThread != nullptr) && (SDL_GetThreadID(mWorkerThread) != 0u)) { SDL_WaitThread(mWorkerThread, nullptr); mWorkerThread = nullptr; } - if (mSocket) + if (mSocket != nullptr) { TcpNet::closeSocket(mSocket); mSocket = nullptr; @@ -157,7 +157,7 @@ void Network::disconnect() void Network::flush() { - if (!mOutSize || mState != CONNECTED) + if ((mOutSize == 0u) || mState != CONNECTED) return; SDL_mutexP(mMutexOut); @@ -183,7 +183,7 @@ void Network::skip(const int len) { SDL_mutexP(mMutexIn); mToSkip += len; - if (!mInSize) + if (mInSize == 0u) { SDL_mutexV(mMutexIn); return; @@ -227,7 +227,7 @@ bool Network::realConnect() mState = CONNECTING; mSocket = TcpNet::open(&ipAddress); - if (!mSocket) + if (mSocket == nullptr) { logger->log_r("Error in TcpNet::open(): %s", TcpNet::getError()); setError(TcpNet::getError()); @@ -246,7 +246,7 @@ void Network::receive() { TcpNet::SocketSet set; - if (!(set = TcpNet::allocSocketSet(1))) + if ((set = TcpNet::allocSocketSet(1)) == nullptr) { setError("Error in TcpNet::allocSocketSet(): " + std::string(TcpNet::getError())); @@ -287,7 +287,7 @@ void Network::receive() mInBuffer + CAST_SIZE(mInSize), BUFFER_SIZE - mInSize); - if (!ret) + if (ret == 0) { // We got disconnected mState = IDLE; @@ -303,7 +303,7 @@ void Network::receive() { // DEBUGLOG("Receive " + toString(ret) + " bytes"); mInSize += ret; - if (mToSkip) + if (mToSkip != 0u) { if (mInSize >= mToSkip) { diff --git a/src/net/ea/npcrecv.cpp b/src/net/ea/npcrecv.cpp index 10322085a..16060d6fa 100644 --- a/src/net/ea/npcrecv.cpp +++ b/src/net/ea/npcrecv.cpp @@ -48,7 +48,7 @@ void NpcRecv::processNpcChoice(Net::MessageIn &msg) npcHandler->getNpc(msg, NpcAction::Other); mRequestLang = false; - if (mDialog) + if (mDialog != nullptr) { mDialog->choiceRequest(); mDialog->parseListItems(msg.readString(msg.getLength() - 8, @@ -70,7 +70,7 @@ void NpcRecv::processNpcMessage(Net::MessageIn &msg) // ignore future legacy npc commands. if (message.size() > 3 && message.substr(0, 3) == "###") return; - if (mDialog) + if (mDialog != nullptr) mDialog->addText(message); } @@ -79,7 +79,7 @@ void NpcRecv::processNpcClose(Net::MessageIn &msg) // Show the close button npcHandler->getNpc(msg, NpcAction::Close); mRequestLang = false; - if (mDialog) + if (mDialog != nullptr) mDialog->showCloseButton(); } @@ -88,7 +88,7 @@ void NpcRecv::processNpcNext(Net::MessageIn &msg) // Show the next button npcHandler->getNpc(msg, NpcAction::Next); mRequestLang = false; - if (mDialog) + if (mDialog != nullptr) mDialog->showNextButton(); } @@ -97,7 +97,7 @@ void NpcRecv::processNpcIntInput(Net::MessageIn &msg) // Request for an integer npcHandler->getNpc(msg, NpcAction::Other); mRequestLang = false; - if (mDialog) + if (mDialog != nullptr) mDialog->integerRequest(0); } @@ -110,7 +110,7 @@ void NpcRecv::processNpcStrInput(Net::MessageIn &msg) mRequestLang = false; npcHandler->stringInput(npcId, getLangSimple()); } - else if (mDialog) + else if (mDialog != nullptr) { mDialog->textRequest(""); } @@ -132,12 +132,12 @@ void NpcRecv::processNpcCommand(Net::MessageIn &msg) break; case 1: - if (viewport) + if (viewport != nullptr) viewport->moveCameraToActor(npcId); break; case 2: - if (viewport) + if (viewport != nullptr) { if (id == BeingId_zero) viewport->moveCameraToPosition(x, y); @@ -147,29 +147,29 @@ void NpcRecv::processNpcCommand(Net::MessageIn &msg) break; case 3: - if (viewport) + if (viewport != nullptr) viewport->returnCamera(); break; case 4: - if (viewport) + if (viewport != nullptr) { viewport->moveCameraRelative(x, y); } break; case 5: // close dialog - if (mDialog) + if (mDialog != nullptr) mDialog->restoreCamera(); npcHandler->closeDialog(npcId); break; case 6: // show avatar - if (mDialog) + if (mDialog != nullptr) { mDialog->showAvatar(fromInt(id, BeingTypeId)); } break; case 7: // set avatar direction - if (mDialog) + if (mDialog != nullptr) { mDialog->setAvatarDirection( Net::MessageIn::fromServerDirection( @@ -177,37 +177,37 @@ void NpcRecv::processNpcCommand(Net::MessageIn &msg) } break; case 8: // set avatar action - if (mDialog) + if (mDialog != nullptr) mDialog->setAvatarAction(toInt(id, int)); break; case 9: // clear npc dialog - if (mDialog) + if (mDialog != nullptr) mDialog->clearRows(); break; case 10: // send selected item id { int invSize = toInt(id, int); - if (!invSize) + if (invSize == 0) invSize = 1; - if (mDialog) + if (mDialog != nullptr) mDialog->itemRequest(invSize); break; } case 11: // send selected item index { int invSize = toInt(id, int); - if (!invSize) + if (invSize == 0) invSize = 1; - if (mDialog) + if (mDialog != nullptr) mDialog->itemIndexRequest(invSize); break; } case 12: // send complex items { int invSize = toInt(id, int); - if (!invSize) + if (invSize == 0) invSize = 1; - if (mDialog) + if (mDialog != nullptr) mDialog->itemCraftRequest(invSize); break; } @@ -217,7 +217,7 @@ void NpcRecv::processNpcCommand(Net::MessageIn &msg) 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; @@ -237,7 +237,7 @@ void NpcRecv::processChangeTitle(Net::MessageIn &msg) npcHandler->getNpc(msg, NpcAction::Other); mRequestLang = false; const std::string str = msg.readString(-1, "title"); - if (mDialog) + if (mDialog != nullptr) mDialog->setCaption(str); } diff --git a/src/net/ea/partyrecv.cpp b/src/net/ea/partyrecv.cpp index 23acf0685..d81bb4295 100644 --- a/src/net/ea/partyrecv.cpp +++ b/src/net/ea/partyrecv.cpp @@ -54,7 +54,7 @@ namespace PartyRecv void PartyRecv::processPartyCreate(Net::MessageIn &msg) { - if (msg.readUInt8("flag")) + if (msg.readUInt8("flag") != 0u) NotifyManager::notify(NotifyTypes::PARTY_CREATE_FAILED); else NotifyManager::notify(NotifyTypes::PARTY_CREATED); @@ -125,7 +125,7 @@ void PartyRecv::processPartyLeave(Net::MessageIn &msg) const BeingId id = msg.readBeingId("account id"); const std::string nick = msg.readString(24, "nick"); const int reason = msg.readUInt8("flag"); - if (!localPlayer) + if (localPlayer == nullptr) return; if (id == localPlayer->getId()) @@ -153,7 +153,7 @@ void PartyRecv::processPartyLeave(Net::MessageIn &msg) if (reason >= 2) return; - if (Ea::taParty) + if (Ea::taParty != nullptr) { Ea::taParty->removeFromMembers(); Ea::taParty->clearMembers(); @@ -161,7 +161,7 @@ void PartyRecv::processPartyLeave(Net::MessageIn &msg) delete2(partyTab) - if (socialWindow && Ea::taParty) + if ((socialWindow != nullptr) && (Ea::taParty != nullptr)) socialWindow->removeTab(Ea::taParty); localPlayer->setPartyName(""); } @@ -190,16 +190,16 @@ void PartyRecv::processPartyLeave(Net::MessageIn &msg) if (reason >= 2) return; - if (actorManager) + if (actorManager != nullptr) { Being *const b = actorManager->findBeing(id); - if (b && b->getType() == ActorType::Player) + if ((b != nullptr) && b->getType() == ActorType::Player) { b->setParty(nullptr); b->setPartyName(""); } } - if (Ea::taParty) + if (Ea::taParty != nullptr) Ea::taParty->removeMember(id); } } @@ -208,9 +208,9 @@ void PartyRecv::processPartyUpdateCoords(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("account id"); PartyMember *m = nullptr; - if (Ea::taParty) + if (Ea::taParty != nullptr) m = Ea::taParty->getMember(id); - if (m) + if (m != nullptr) { m->setX(msg.readInt16("x")); m->setY(msg.readInt16("y")); diff --git a/src/net/ea/playerrecv.cpp b/src/net/ea/playerrecv.cpp index 623a23b7c..93108b39d 100644 --- a/src/net/ea/playerrecv.cpp +++ b/src/net/ea/playerrecv.cpp @@ -64,18 +64,18 @@ void PlayerRecv::processPlayerWarp(Net::MessageIn &msg) logger->log("Warping to %s (%d, %d)", mapPath.c_str(), x, y); - if (!localPlayer) + if (localPlayer == nullptr) logger->log1("SMSG_PLAYER_WARP localPlayer null"); /* * We must clear the local player's target *before* the call * to changeMap, as it deletes all beings. */ - if (localPlayer) + if (localPlayer != nullptr) localPlayer->stopAttack(); Game *const game = Game::instance(); - if (!game) + if (game == nullptr) { BLOCK_END("PlayerRecv::processPlayerWarp") return; @@ -91,10 +91,10 @@ void PlayerRecv::processPlayerWarp(Net::MessageIn &msg) int scrollOffsetX = 0; int scrollOffsetY = 0; - if (localPlayer) + if (localPlayer != nullptr) { const Map *const map = game->getCurrentMap(); - if (map) + if (map != nullptr) { if (x >= map->getWidth()) x = map->getWidth() - 1; @@ -126,7 +126,7 @@ void PlayerRecv::processPlayerWarp(Net::MessageIn &msg) logger->log("Adjust scrolling by %d:%d", scrollOffsetX, scrollOffsetY); - if (viewport) + if (viewport != nullptr) { viewport->returnCamera(); viewport->scrollBy(scrollOffsetX, scrollOffsetY); @@ -139,7 +139,7 @@ void PlayerRecv::processPlayerStatUpdate1(Net::MessageIn &msg) BLOCK_START("PlayerRecv::processPlayerStatUpdate1") const int type = msg.readInt16("type"); const int value = msg.readInt32("value"); - if (!localPlayer) + if (localPlayer == nullptr) { BLOCK_END("PlayerRecv::processPlayerStatUpdate1") return; @@ -195,7 +195,7 @@ void PlayerRecv::processPlayerStatUpdate6(Net::MessageIn &msg) BLOCK_START("PlayerRecv::processPlayerStatUpdate6") const int type = msg.readInt16("type"); const int value = msg.readUInt8("value"); - if (statusWindow) + if (statusWindow != nullptr) playerHandler->setStat(msg, type, value, NoStat, Notify_true); BLOCK_END("PlayerRecv::processPlayerStatUpdate6") } @@ -227,7 +227,7 @@ void PlayerRecv::processMapMusic(Net::MessageIn &msg) SkipError_false); Map *const map = viewport->getMap(); - if (map) + if (map != nullptr) map->setMusicFile(music); } @@ -236,7 +236,7 @@ void PlayerRecv::processMapMask(Net::MessageIn &msg) const int mask = msg.readInt32("mask"); msg.readInt32("unused"); Map *const map = Game::instance()->getCurrentMap(); - if (map) + if (map != nullptr) map->setMask(mask); } diff --git a/src/net/ea/skillrecv.cpp b/src/net/ea/skillrecv.cpp index 79388eb2a..58a083478 100644 --- a/src/net/ea/skillrecv.cpp +++ b/src/net/ea/skillrecv.cpp @@ -41,10 +41,10 @@ void SkillRecv::processPlayerSkillUp(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)) diff --git a/src/net/ea/traderecv.cpp b/src/net/ea/traderecv.cpp index 558d7094f..dc2d60322 100644 --- a/src/net/ea/traderecv.cpp +++ b/src/net/ea/traderecv.cpp @@ -72,7 +72,7 @@ void TradeRecv::processTradeResponseContinue(const uint8_t type) NotifyManager::notify(NotifyTypes::TRADE_CANCELLED_ERROR); break; case 3: // Trade accepted - if (tradeWindow) + if (tradeWindow != nullptr) { tradeWindow->reset(); // TRANSLATORS: trade header @@ -91,7 +91,7 @@ void TradeRecv::processTradeResponseContinue(const uint8_t type) } // otherwise ignore silently - if (tradeWindow) + if (tradeWindow != nullptr) { tradeWindow->setVisible(Visible_false); // tradeWindow->clear(); @@ -105,7 +105,7 @@ void TradeRecv::processTradeResponseContinue(const uint8_t type) default: // Shouldn't happen as well, but to be sure NotifyManager::notify(NotifyTypes::TRADE_ERROR_UNKNOWN, tradePartnerName); - if (tradeWindow) + if (tradeWindow != nullptr) tradeWindow->clear(); break; } @@ -114,7 +114,7 @@ void TradeRecv::processTradeResponseContinue(const uint8_t type) void TradeRecv::processTradeOk(Net::MessageIn &msg) { // 0 means ok from myself, 1 means ok from other; - if (tradeWindow) + if (tradeWindow != nullptr) tradeWindow->receivedOk(msg.readUInt8("status") == 0U); else msg.readUInt8("status"); @@ -123,7 +123,7 @@ void TradeRecv::processTradeOk(Net::MessageIn &msg) void TradeRecv::processTradeCancel(Net::MessageIn &msg A_UNUSED) { NotifyManager::notify(NotifyTypes::TRADE_CANCELLED); - if (tradeWindow) + if (tradeWindow != nullptr) { tradeWindow->setVisible(Visible_false); tradeWindow->reset(); @@ -134,7 +134,7 @@ void TradeRecv::processTradeCancel(Net::MessageIn &msg A_UNUSED) void TradeRecv::processTradeComplete(Net::MessageIn &msg A_UNUSED) { NotifyManager::notify(NotifyTypes::TRADE_COMPLETE); - if (tradeWindow) + if (tradeWindow != nullptr) tradeWindow->completeTrade(); PlayerInfo::setTrading(Trading_false); } @@ -144,7 +144,7 @@ void TradeRecv::processTradeRequestContinue(const std::string &partner) if (player_relations.hasPermission(partner, PlayerRelation::TRADE)) { - if (PlayerInfo::isTrading() == Trading_true || confirmDlg) + if (PlayerInfo::isTrading() == Trading_true || (confirmDlg != nullptr)) { tradeHandler->respond(false); return; @@ -152,7 +152,7 @@ void TradeRecv::processTradeRequestContinue(const std::string &partner) tradePartnerName = partner; PlayerInfo::setTrading(Trading_true); - if (tradeWindow) + if (tradeWindow != nullptr) { if (tradePartnerName.empty() || tradeWindow->getAutoTradeNick() != tradePartnerName) 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(); diff --git a/src/net/ipc.cpp b/src/net/ipc.cpp index e77cad713..19eace240 100644 --- a/src/net/ipc.cpp +++ b/src/net/ipc.cpp @@ -49,7 +49,7 @@ IPC::IPC() : IPC::~IPC() { mListen = false; - if (mSocket) + if (mSocket != nullptr) { TcpNet::closeSocket(mSocket); mSocket = nullptr; @@ -57,7 +57,7 @@ IPC::~IPC() SDL_DestroyMutex(mMutex); mMutex = nullptr; int status; - if (mThread && SDL_GetThreadID(mThread)) + if ((mThread != nullptr) && (SDL_GetThreadID(mThread) != 0u)) SDL_WaitThread(mThread, &status); mThread = nullptr; } @@ -73,14 +73,14 @@ bool IPC::init() } mSocket = TcpNet::open(&ip); - if (!mSocket) + if (mSocket == nullptr) { logger->log("IPC: open error: %s", TcpNet::getError()); return false; } mThread = SDL::createThread(&acceptLoop, "ipc", this); - if (!mThread) + if (mThread == nullptr) { logger->log("IPC: unable to create acceptLoop thread"); return false; @@ -90,7 +90,7 @@ bool IPC::init() int IPC::acceptLoop(void *ptr) { - if (!ptr) + if (ptr == nullptr) return 1; IPC *const ipc1 = reinterpret_cast<IPC*>(ptr); @@ -101,11 +101,11 @@ int IPC::acceptLoop(void *ptr) while (ipc1->mListen) { TcpNet::checkSockets(set, 250); - if (!TcpNet::socketReady(ipc1->mSocket)) + if (TcpNet::socketReady(ipc1->mSocket) == 0) continue; const TcpNet::Socket sock = TcpNet::accept(ipc1->mSocket); - if (!sock) + if (sock == nullptr) { logger->log_r("IPC: unable to accept connection"); continue; @@ -153,7 +153,7 @@ int IPC::acceptLoop(void *ptr) void IPC::stop() { - if (!ipc) + if (ipc == nullptr) return; logger->log("Stopping IPC..."); @@ -162,11 +162,11 @@ void IPC::stop() void IPC::start() { - if (ipc) + if (ipc != nullptr) return; unsigned short port(44007); - if (getenv("IPC_PORT")) + if (getenv("IPC_PORT") != nullptr) port = static_cast<unsigned short>(atoi(getenv("IPC_PORT"))); logger->log("Starting IPC..."); @@ -195,7 +195,7 @@ void IPC::flush() SDL_mutexP(mMutex); #ifndef DYECMD // probably need enable only commands in tool - if (chatWindow) + if (chatWindow != nullptr) { FOR_EACH (std::vector<std::string>::const_iterator, it, mDelayedCommands) diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index fbf3f9c4e..11b28d510 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -51,7 +51,7 @@ MessageIn::MessageIn(const char *const data, MessageIn::~MessageIn() { - if (mLength) + if (mLength != 0u) { if (mPos != mLength && mPos != 2) { @@ -207,7 +207,7 @@ void MessageIn::skip(const unsigned int length, const char *const str) void MessageIn::skipToEnd(const char *const str) { const int diff = CAST_S32(mLength - mPos); - if (diff) + if (diff != 0) { DEBUGLOG2("skip: " + toString(diff), mPos, str); mPos = mLength; @@ -234,7 +234,7 @@ std::string MessageIn::readString(int length, const char *const dstr) const char *const stringEnd = static_cast<const char *>(memchr(stringBeg, '\0', length)); - const std::string str(stringBeg, stringEnd + const std::string str(stringBeg, stringEnd != nullptr ? stringEnd - stringBeg : CAST_SIZE(length)); DEBUGLOG2("readString: " + str, mPos, dstr); mPos += length; @@ -259,12 +259,12 @@ std::string MessageIn::readRawString(int length, const char *const dstr) const char *const stringBeg = mData + CAST_SIZE(mPos); const char *const stringEnd = static_cast<const char *>(memchr(stringBeg, '\0', length)); - std::string str(stringBeg, stringEnd + std::string str(stringBeg, stringEnd != nullptr ? stringEnd - stringBeg : CAST_SIZE(length)); DEBUGLOG2("readString: " + str, mPos, dstr); - if (stringEnd) + if (stringEnd != nullptr) { const size_t len2 = CAST_SIZE(length) - (stringEnd - stringBeg) - 1; @@ -272,7 +272,7 @@ std::string MessageIn::readRawString(int length, const char *const dstr) const char *const stringEnd2 = static_cast<const char *>(memchr(stringBeg2, '\0', len2)); const std::string hiddenPart = std::string(stringBeg2, - stringEnd2 ? stringEnd2 - stringBeg2 : len2); + stringEnd2 != nullptr ? stringEnd2 - stringBeg2 : len2); if (hiddenPart.length() > 0) { DEBUGLOG2("readString2: " + hiddenPart, mPos, dstr); @@ -314,12 +314,12 @@ unsigned char *MessageIn::readBytes(int length, const char *const dstr) str += " "; for (int f = 0; f < length; f ++) { - if (buf[f]) + if (buf[f] != 0u) str.append(strprintf("%c", buf[f])); else str.append("_"); } - if (dstr) + if (dstr != nullptr) logger->dlog(dstr); logger->dlog("ReadBytes: " + str); #endif // ENABLEDEBUGLOG diff --git a/src/net/net.cpp b/src/net/net.cpp index 65f00812e..d6b6e2945 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -113,13 +113,13 @@ std::set<int> ignorePackets; void connectToServer(const ServerInfo &server) { BLOCK_START("Net::connectToServer") - if (networkType == server.type && generalHandler) + if (networkType == server.type && (generalHandler != nullptr)) { generalHandler->reload(); } else { - if (networkType != ServerType::UNKNOWN && generalHandler) + if (networkType != ServerType::UNKNOWN && (generalHandler != nullptr)) generalHandler->unload(); switch (server.type) @@ -146,7 +146,7 @@ void connectToServer(const ServerInfo &server) networkType = server.type; } - if (loginHandler) + if (loginHandler != nullptr) { loginHandler->setServer(server); loginHandler->connect(); @@ -157,7 +157,7 @@ void connectToServer(const ServerInfo &server) void unload() { const GeneralHandler *const handler = generalHandler; - if (handler) + if (handler != nullptr) handler->unload(); ignorePackets.clear(); } diff --git a/src/net/packetlimiter.cpp b/src/net/packetlimiter.cpp index f155d8399..b6eee37ae 100644 --- a/src/net/packetlimiter.cpp +++ b/src/net/packetlimiter.cpp @@ -180,7 +180,7 @@ void PacketLimiter::initPacketLimiter() std::ifstream inPacketFile; struct stat statbuf; - if (stat(packetLimitsName.c_str(), &statbuf) + if ((stat(packetLimitsName.c_str(), &statbuf) != 0) || !S_ISREG(statbuf.st_mode)) { // wtiting new file @@ -253,7 +253,7 @@ bool PacketLimiter::checkPackets(const PacketTypeT type) const PacketLimit &limit = mPacketLimits[CAST_SIZE(type)]; const int timeLimit = limit.timeLimit; - if (!timeLimit) + if (timeLimit == 0) return true; const int time = tick_time; @@ -296,7 +296,7 @@ bool PacketLimiter::limitPackets(const PacketTypeT type) PacketLimit &pack = mPacketLimits[CAST_SIZE(type)]; const int timeLimit = pack.timeLimit; - if (!timeLimit) + if (timeLimit == 0) return true; const int time = tick_time; diff --git a/src/net/sdltcpnet.cpp b/src/net/sdltcpnet.cpp index 182263ee5..4e01fe15a 100644 --- a/src/net/sdltcpnet.cpp +++ b/src/net/sdltcpnet.cpp @@ -104,13 +104,13 @@ TcpNet::Socket TcpNet::open(IPaddress *const ip) #if !defined(__native_client__) \ && (defined(TCP_THIN_LINEAR_TIMEOUTS) \ || defined(TCP_THIN_DUPACK)) - if (sock && ip) + if ((sock != nullptr) && (ip != nullptr)) { const TCPsocketHack *const hack = reinterpret_cast<const TCPsocketHack *>(sock); // here we using some magic to compare TCPsocket and own padding // because actual struct TCPsocket not in headers - if (hack) + if (hack != nullptr) { const IPaddress &addr = hack->remoteAddress; if (addr.host == ip->host && addr.port == ip->port) @@ -118,14 +118,14 @@ TcpNet::Socket TcpNet::open(IPaddress *const ip) const int val = 1; #ifdef TCP_THIN_LINEAR_TIMEOUTS if (setsockopt(hack->channel, IPPROTO_TCP, - TCP_THIN_LINEAR_TIMEOUTS, &val, sizeof(val))) + TCP_THIN_LINEAR_TIMEOUTS, &val, sizeof(val)) != 0) { logger->log_r("error on set TCP_THIN_LINEAR_TIMEOUTS"); } #endif // TCP_THIN_LINEAR_TIMEOUTS #ifdef TCP_THIN_DUPACK if (setsockopt(hack->channel, IPPROTO_TCP, - TCP_THIN_DUPACK, &val, sizeof(val))) + TCP_THIN_DUPACK, &val, sizeof(val)) != 0) { logger->log_r("error on set TCP_THIN_DUPACK"); } diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index e9f9eb748..de2a42134 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -47,7 +47,7 @@ void BeingHandler::requestNameById(const BeingId id) const void BeingHandler::undress(Being *const being) const { - if (!being) + if (being == nullptr) return; being->unSetSprite(SPRITE_WEAPON); being->unSetSprite(SPRITE_HEAD_BOTTOM); diff --git a/src/net/tmwa/beingrecv.cpp b/src/net/tmwa/beingrecv.cpp index 4b1bb631b..cb02e690e 100644 --- a/src/net/tmwa/beingrecv.cpp +++ b/src/net/tmwa/beingrecv.cpp @@ -61,7 +61,7 @@ namespace TmwAthena void BeingRecv::processBeingChangeLook(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingChangeLook") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingChangeLook") return; @@ -74,7 +74,7 @@ void BeingRecv::processBeingChangeLook(Net::MessageIn &msg) const int16_t id = CAST_S16(msg.readUInt8("id")); const int id2 = 1; - if (!localPlayer || !dstBeing) + if ((localPlayer == nullptr) || (dstBeing == nullptr)) { BLOCK_END("BeingRecv::processBeingChangeLook") return; @@ -86,7 +86,7 @@ void BeingRecv::processBeingChangeLook(Net::MessageIn &msg) void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingChangeLook") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingChangeLook") return; @@ -109,7 +109,7 @@ void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg) id2 = 1; } - if (!localPlayer || !dstBeing) + if ((localPlayer == nullptr) || (dstBeing == nullptr)) { BLOCK_END("BeingRecv::processBeingChangeLook") return; @@ -223,7 +223,7 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg, void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerMoveUpdate") - if (!actorManager || !localPlayer) + if ((actorManager == nullptr) || (localPlayer == nullptr)) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; @@ -241,7 +241,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) disguiseId = job; Being *dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { if (actorManager->isBlocked(id) == true) { @@ -251,20 +251,20 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) dstBeing = Ea::BeingRecv::createBeing(id, job); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; } } - else if (disguiseId) + else if (disguiseId != 0) { actorManager->undelete(dstBeing); beingHandler->requestNameById(id); } uint8_t dir = dstBeing->getDirectionDelayed(); - if (dir) + if (dir != 0u) { if (dir != dstBeing->getDirection()) dstBeing->setDirection(dir); @@ -294,7 +294,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) const int guild = msg.readInt32("guild"); - if (!guildManager || !GuildManager::getEnableGuildBot()) + if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) { if (guild == 0) dstBeing->clearGuilds(); @@ -310,7 +310,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) dstBeing->setGender(Being::intToGender( CAST_U8(msg.readUInt8("gender") & 3))); - if (!disguiseId) + if (disguiseId == 0) { // Set these after the gender, as the sprites may be gender-specific dstBeing->updateSprite(SPRITE_BODY, @@ -346,12 +346,12 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) const uint16_t gmstatus = msg.readInt16("gm status"); - if (gmstatus & 0x80) + if ((gmstatus & 0x80) != 0) dstBeing->setGM(true); applyPlayerAction(msg, dstBeing, msg.readUInt8("action type")); const int level = CAST_S32(msg.readUInt8("level")); - if (level) + if (level != 0) dstBeing->setLevel(level); msg.readUInt8("unused"); @@ -369,7 +369,7 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg) void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerMoveUpdate") - if (!actorManager || !localPlayer) + if ((actorManager == nullptr) || (localPlayer == nullptr)) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; @@ -387,7 +387,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) disguiseId = job; Being *dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { if (actorManager->isBlocked(id) == true) { @@ -397,20 +397,20 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) dstBeing = Ea::BeingRecv::createBeing(id, job); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; } } - else if (disguiseId) + else if (disguiseId != 0) { actorManager->undelete(dstBeing); beingHandler->requestNameById(id); } uint8_t dir = dstBeing->getDirectionDelayed(); - if (dir) + if (dir != 0u) { if (dir != dstBeing->getDirection()) dstBeing->setDirection(dir); @@ -439,7 +439,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) const int guild = msg.readInt32("guild"); - if (!guildManager || !GuildManager::getEnableGuildBot()) + if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) { if (guild == 0) dstBeing->clearGuilds(); @@ -455,7 +455,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) dstBeing->setGender(Being::intToGender( CAST_U8(msg.readUInt8("gender") & 3))); - if (!disguiseId) + if (disguiseId == 0) { // Set these after the gender, as the sprites may be gender-specific dstBeing->updateSprite(SPRITE_BODY, @@ -491,12 +491,12 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) const uint16_t gmstatus = msg.readInt16("gm status"); - if (gmstatus & 0x80) + if ((gmstatus & 0x80) != 0) dstBeing->setGM(true); applyPlayerAction(msg, dstBeing, msg.readUInt8("action type")); const int level = CAST_S32(msg.readUInt8("level")); - if (level) + if (level != 0) dstBeing->setLevel(level); dstBeing->setActionTime(tick_time); @@ -511,7 +511,7 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg) void BeingRecv::processPlayerMove(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerMoveUpdate") - if (!actorManager || !localPlayer) + if ((actorManager == nullptr) || (localPlayer == nullptr)) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; @@ -529,7 +529,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) disguiseId = job; Being *dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { if (actorManager->isBlocked(id) == true) { @@ -539,20 +539,20 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) dstBeing = Ea::BeingRecv::createBeing(id, job); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processPlayerMoveUpdate") return; } } - else if (disguiseId) + else if (disguiseId != 0) { actorManager->undelete(dstBeing); beingHandler->requestNameById(id); } const uint8_t dir = dstBeing->getDirectionDelayed(); - if (dir) + if (dir != 0u) { if (dir != dstBeing->getDirection()) dstBeing->setDirection(dir); @@ -584,7 +584,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) const int guild = msg.readInt32("guild"); - if (!guildManager || !GuildManager::getEnableGuildBot()) + if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) { if (guild == 0) dstBeing->clearGuilds(); @@ -600,7 +600,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) dstBeing->setGender(Being::intToGender( CAST_U8(msg.readUInt8("gender") & 3))); - if (!disguiseId) + if (disguiseId == 0) { // Set these after the gender, as the sprites may be gender-specific dstBeing->updateSprite(SPRITE_BODY, @@ -642,7 +642,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) { const int d = dstBeing->calcDirection(dstX, dstY); - if (d && dstBeing->getDirection() != d) + if ((d != 0) && dstBeing->getDirection() != d) dstBeing->setDirectionDelayed(CAST_U8(d)); } @@ -656,13 +656,13 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) const uint16_t gmstatus = msg.readInt16("gm status"); - if (gmstatus & 0x80) + if ((gmstatus & 0x80) != 0) dstBeing->setGM(true); msg.readUInt8("unused"); const int level = CAST_S32(msg.readUInt8("level")); - if (level) + if (level != 0) dstBeing->setLevel(level); msg.readUInt8("unused"); @@ -683,7 +683,7 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg) void BeingRecv::processBeingVisible(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingVisibleOrMove") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingVisibleOrMove") return; @@ -709,7 +709,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) Being *dstBeing = actorManager->findBeing(id); - if (dstBeing && dstBeing->getType() == ActorType::Monster + if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster && !dstBeing->isAlive()) { actorManager->destroy(dstBeing); @@ -717,7 +717,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) dstBeing = nullptr; } - if (!dstBeing) + if (dstBeing == nullptr) { // Being with id >= 110000000 and job 0 are better // known as ghosts, so don't create those. @@ -735,7 +735,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) dstBeing = Ea::BeingRecv::createBeing(id, job); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processBeingVisibleOrMove") return; @@ -771,7 +771,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) const uint8_t hairStyle = msg.readUInt8("hair style"); const uint16_t look = msg.readUInt8("look"); dstBeing->setSubtype(fromInt(job, BeingTypeId), look); - if (dstBeing->getType() == ActorType::Monster && localPlayer) + if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr)) localPlayer->checkNewName(dstBeing); dstBeing->setWalkSpeed(speed); const uint16_t weapon = msg.readInt16("weapon"); @@ -792,11 +792,11 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) { const int hp = msg.readInt32("hp"); const int maxHP = msg.readInt32("max hp"); - if (hp && maxHP) + if ((hp != 0) && (maxHP != 0)) { dstBeing->setMaxHP(maxHP); const int oldHP = dstBeing->getHP(); - if (!oldHP || oldHP > hp) + if ((oldHP == 0) || oldHP > hp) dstBeing->setHP(hp); } } @@ -829,7 +829,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) } uint8_t gender = msg.readUInt8("gender"); - if (!disguiseId && dstBeing->getType() == ActorType::Player) + if ((disguiseId == 0) && dstBeing->getType() == ActorType::Player) { // reserving bits for future usage gender &= 3; @@ -866,7 +866,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) msg.readCoordinates(x, y, dir, "position"); dstBeing->setTileCoords(x, y); - if (job == 45 && socialWindow && outfitWindow) + if (job == 45 && (socialWindow != nullptr) && (outfitWindow != nullptr)) { const int num = socialWindow->getPortalIndex(x, y); if (num >= 0) @@ -898,7 +898,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) void BeingRecv::processBeingMove(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingVisibleOrMove") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingVisibleOrMove") return; @@ -924,7 +924,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) Being *dstBeing = actorManager->findBeing(id); - if (dstBeing && dstBeing->getType() == ActorType::Monster + if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster && !dstBeing->isAlive()) { actorManager->destroy(dstBeing); @@ -932,7 +932,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) dstBeing = nullptr; } - if (!dstBeing) + if (dstBeing == nullptr) { // Being with id >= 110000000 and job 0 are better // known as ghosts, so don't create those. @@ -950,7 +950,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) dstBeing = Ea::BeingRecv::createBeing(id, job); - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processBeingVisibleOrMove") return; @@ -978,7 +978,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) const uint8_t hairStyle = msg.readUInt8("hair style"); const uint16_t look = msg.readUInt8("look"); dstBeing->setSubtype(fromInt(job, BeingTypeId), look); - if (dstBeing->getType() == ActorType::Monster && localPlayer) + if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr)) localPlayer->checkNewName(dstBeing); dstBeing->setWalkSpeed(speed); const uint16_t weapon = msg.readInt16("weapon"); @@ -1001,11 +1001,11 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) { const int hp = msg.readInt32("hp"); const int maxHP = msg.readInt32("max hp"); - if (hp && maxHP) + if ((hp != 0) && (maxHP != 0)) { dstBeing->setMaxHP(maxHP); const int oldHP = dstBeing->getHP(); - if (!oldHP || oldHP > hp) + if ((oldHP == 0) || oldHP > hp) dstBeing->setHP(hp); } } @@ -1038,7 +1038,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) } uint8_t gender = msg.readUInt8("gender"); - if (!disguiseId && dstBeing->getType() == ActorType::Player) + if ((disguiseId == 0) && dstBeing->getType() == ActorType::Player) { // reserving bits for future usage gender &= 3; @@ -1072,7 +1072,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) uint16_t srcX, srcY, dstX, dstY; msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path"); - if (!disguiseId) + if (disguiseId == 0) { dstBeing->setAction(BeingAction::STAND, 0); dstBeing->setTileCoords(srcX, srcY); @@ -1123,7 +1123,7 @@ void BeingRecv::processSkillCasting(Net::MessageIn &msg) void BeingRecv::processBeingStatusChange(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingStatusChange") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingStatusChange") return; @@ -1136,7 +1136,7 @@ void BeingRecv::processBeingStatusChange(Net::MessageIn &msg) msg.readUInt8("flag: 0: stop, 1: start"), Enable); Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) { // dont know on legacy servers is effect really started // or not. Because this always sending IsStart_true @@ -1148,7 +1148,7 @@ void BeingRecv::processBeingStatusChange(Net::MessageIn &msg) void BeingRecv::processBeingMove2(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingMove2") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingMove2") return; @@ -1168,7 +1168,7 @@ void BeingRecv::processBeingMove2(Net::MessageIn &msg) * we'll just pretend the packet didn't happen */ - if (!dstBeing) + if (dstBeing == nullptr) { BLOCK_END("BeingRecv::processBeingMove2") return; @@ -1189,7 +1189,7 @@ void BeingRecv::processBeingMove2(Net::MessageIn &msg) void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingChangeDirection") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processBeingChangeDirection") return; @@ -1198,7 +1198,7 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("being id")); - if (!dstBeing) + if (dstBeing == nullptr) { DEBUGLOGSTR("invisible player?"); msg.readInt16("unused"); @@ -1212,7 +1212,7 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg) const uint8_t dir = Net::MessageIn::fromServerDirection( CAST_U8(msg.readUInt8("direction") & 0x0FU)); dstBeing->setDirection(dir); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->imitateDirection(dstBeing, dir); BLOCK_END("BeingRecv::processBeingChangeDirection") } @@ -1220,7 +1220,7 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg) void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerStop") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processPlayerStop") return; @@ -1229,7 +1229,7 @@ void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg) // Change in players' flags const BeingId id = msg.readBeingId("account id"); Being *const dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { DEBUGLOGSTR("invisible player?"); msg.readInt16("stun mode"); @@ -1253,7 +1253,7 @@ void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg) void BeingRecv::processBeingResurrect(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingResurrect") - if (!actorManager || !localPlayer) + if ((actorManager == nullptr) || (localPlayer == nullptr)) { BLOCK_END("BeingRecv::processBeingResurrect") return; @@ -1263,7 +1263,7 @@ void BeingRecv::processBeingResurrect(Net::MessageIn &msg) const BeingId id = msg.readBeingId("being id"); Being *const dstBeing = actorManager->findBeing(id); - if (!dstBeing) + if (dstBeing == nullptr) { DEBUGLOGSTR("insible player?"); msg.readInt16("flag?"); @@ -1283,7 +1283,7 @@ void BeingRecv::processBeingResurrect(Net::MessageIn &msg) void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processPlayerGuilPartyInfo") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processPlayerGuilPartyInfo") return; @@ -1292,10 +1292,10 @@ void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("being id")); - if (dstBeing) + if (dstBeing != nullptr) { dstBeing->setPartyName(msg.readString(24, "party name")); - if (!guildManager || !GuildManager::getEnableGuildBot()) + if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot()) { dstBeing->setGuildName(msg.readString(24, "guild name")); dstBeing->setGuildPos(msg.readString(24, "guild pos")); @@ -1321,7 +1321,7 @@ void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg) void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processBeingSelfEffect") - if (!effectManager || !actorManager) + if ((effectManager == nullptr) || (actorManager == nullptr)) { BLOCK_END("BeingRecv::processBeingSelfEffect") return; @@ -1329,7 +1329,7 @@ void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg) const BeingId id = msg.readBeingId("being id"); Being *const being = actorManager->findBeing(id); - if (!being) + if (being == nullptr) { DEBUGLOGSTR("insible player?"); msg.readInt32("effect type"); @@ -1344,7 +1344,7 @@ void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg) // +++ need dehard code effectType == 3 if (effectType == 3 && being->getType() == ActorType::Player - && socialWindow) + && (socialWindow != nullptr)) { // reset received damage socialWindow->resetDamage(being->getName()); } @@ -1359,7 +1359,7 @@ void BeingRecv::processSkillCastCancel(Net::MessageIn &msg) void BeingRecv::processIpResponse(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processIpResponse") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processIpResponse") return; @@ -1368,7 +1368,7 @@ void BeingRecv::processIpResponse(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("being id")); const std::string ip = ipToString(msg.readInt32("ip address")); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->setIp(ip); else DEBUGLOGSTR("invisible player?"); @@ -1383,10 +1383,10 @@ void BeingRecv::processPvpSet(Net::MessageIn &msg) const int rank = msg.readInt32("rank"); int teamId = 0; teamId = msg.readInt32("team"); - if (actorManager) + if (actorManager != nullptr) { Being *const dstBeing = actorManager->findBeing(id); - if (dstBeing) + if (dstBeing != nullptr) { dstBeing->setPvpRank(rank); dstBeing->setTeamId(CAST_U16(teamId)); @@ -1400,7 +1400,7 @@ void BeingRecv::applyPlayerAction(Net::MessageIn &msg, Being *const being, const uint8_t type) { - if (!being) + if (being == nullptr) return; switch (type) { @@ -1431,7 +1431,7 @@ void BeingRecv::applyPlayerAction(Net::MessageIn &msg, void BeingRecv::processSkillDamage(Net::MessageIn &msg) { BLOCK_START("BeingRecv::processSkillDamage") - if (!actorManager) + if (actorManager == nullptr) { BLOCK_END("BeingRecv::processSkillDamage") return; @@ -1449,9 +1449,9 @@ void BeingRecv::processSkillDamage(Net::MessageIn &msg) const int level = msg.readInt16("skill level"); msg.readInt16("div"); msg.readUInt8("skill hit/type?"); - if (srcBeing) + if (srcBeing != nullptr) srcBeing->handleSkill(dstBeing, param1, id, level); - if (dstBeing) + if (dstBeing != nullptr) dstBeing->takeDamage(srcBeing, param1, AttackType::SKILL, id, level); BLOCK_END("BeingRecv::processSkillDamage") } @@ -1459,7 +1459,7 @@ void BeingRecv::processSkillDamage(Net::MessageIn &msg) void BeingRecv::setServerGender(Being *const being, const uint8_t gender) { - if (!being) + if (being == nullptr) return; switch (gender) { diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp index 232d9492e..7f48fb89c 100644 --- a/src/net/tmwa/buysellhandler.cpp +++ b/src/net/tmwa/buysellhandler.cpp @@ -49,7 +49,7 @@ BuySellHandler::BuySellHandler() : void BuySellHandler::requestSellList(const std::string &nick) const { - if (nick.empty() != 0 || !shopWindow) + if (nick.empty() || shopWindow == nullptr) return; const std::string data("!selllist " + toString(tick_time)); @@ -60,14 +60,14 @@ void BuySellHandler::requestSellList(const std::string &nick) const } else { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); } } void BuySellHandler::requestBuyList(const std::string &nick) const { - if (nick.empty() || !shopWindow) + if (nick.empty() || (shopWindow == nullptr)) return; const std::string data("!buylist " + toString(tick_time)); @@ -79,7 +79,7 @@ void BuySellHandler::requestBuyList(const std::string &nick) const } else { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); } } @@ -88,7 +88,7 @@ void BuySellHandler::sendBuyRequest(const std::string &nick, const ShopItem *const item, const int amount) const { - if (!chatWindow || nick.empty() || !item || + if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) || amount < 1 || amount > item->getQuantity()) { return; @@ -106,7 +106,7 @@ void BuySellHandler::sendSellRequest(const std::string &nick, const ShopItem *const item, const int amount) const { - if (!chatWindow || nick.empty() || !item || + if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) || amount < 1 || amount > item->getQuantity()) { return; diff --git a/src/net/tmwa/buysellrecv.cpp b/src/net/tmwa/buysellrecv.cpp index c4fac1416..004837e50 100644 --- a/src/net/tmwa/buysellrecv.cpp +++ b/src/net/tmwa/buysellrecv.cpp @@ -95,7 +95,7 @@ void BuySellRecv::processNpcBuyResponse(Net::MessageIn &msg) } // Reset player money since buy dialog already assumed purchase // would go fine - if (Ea::BuySellRecv::mBuyDialog) + if (Ea::BuySellRecv::mBuyDialog != nullptr) { Ea::BuySellRecv::mBuyDialog->setMoney( PlayerInfo::getAttribute(Attributes::MONEY)); diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 958f08cc1..faaf89bc6 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -56,7 +56,7 @@ CharServerHandler::CharServerHandler() : void CharServerHandler::chooseCharacter(Net::Character *const character) const { - if (!character) + if (character == nullptr) return; mSelectedCharacter = character; @@ -91,7 +91,7 @@ void CharServerHandler::deleteCharacter(Net::Character *const character, const std::string &email A_UNUSED) const { - if (!character) + if (character == nullptr) return; mSelectedCharacter = character; @@ -113,7 +113,7 @@ void CharServerHandler::connect() const const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken(); - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; Network::mInstance->disconnect(); @@ -137,7 +137,7 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window) { mCharCreateDialog = window; - if (!mCharCreateDialog) + if (mCharCreateDialog == nullptr) return; StringVect attributes; @@ -157,13 +157,13 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window) const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken(); int minStat = CharDB::getMinStat(); - if (!minStat) + if (minStat == 0) minStat = 1; int maxStat = CharDB::getMaxStat(); - if (!maxStat) + if (maxStat == 0) maxStat = 9; int sumStat = CharDB::getSumStat(); - if (!sumStat) + if (sumStat == 0) sumStat = 30; mCharCreateDialog->setAttributes(attributes, sumStat, minStat, maxStat); diff --git a/src/net/tmwa/charserverrecv.cpp b/src/net/tmwa/charserverrecv.cpp index 43f405542..571ce0b3b 100644 --- a/src/net/tmwa/charserverrecv.cpp +++ b/src/net/tmwa/charserverrecv.cpp @@ -64,7 +64,7 @@ extern ServerInfo charServer; void CharServerRecv::readPlayerData(Net::MessageIn &msg, Net::Character *const character) { - if (!character) + if (character == nullptr) return; const Token &token = @@ -193,7 +193,7 @@ void CharServerRecv::processCharLogin(Net::MessageIn &msg) Net::Character *const character = new Net::Character; readPlayerData(msg, character); charServerHandler->mCharacters.push_back(character); - if (character->dummy) + if (character->dummy != nullptr) { logger->log("CharServer: Player: %s (%d)", character->dummy->getName().c_str(), character->slot); @@ -232,7 +232,7 @@ void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg) charServerHandler->clear(); charServerHandler->updateCharSelectDialog(); - if (network) + if (network != nullptr) network->disconnect(); client->setState(State::CONNECT_GAME); BLOCK_END("CharServerRecv::processCharMapInfo") @@ -244,7 +244,7 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) ServerInfo &server = mapServer; BLOCK_START("CharServerRecv::processChangeMapServer") GameHandler *const gh = static_cast<GameHandler*>(gameHandler); - if (!gh || !network) + if ((gh == nullptr) || (network == nullptr)) { BLOCK_END("CharServerRecv::processChangeMapServer") return; @@ -265,7 +265,7 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) network->disconnect(); client->setState(State::CHANGE_MAP); - if (localPlayer) + if (localPlayer != nullptr) { localPlayer->setTileCoords(x, y); localPlayer->setMap(nullptr); @@ -283,7 +283,7 @@ void CharServerRecv::processCharCreate(Net::MessageIn &msg) charServerHandler->updateCharSelectDialog(); // Close the character create dialog - if (charServerHandler->mCharCreateDialog) + if (charServerHandler->mCharCreateDialog != nullptr) { charServerHandler->mCharCreateDialog->scheduleDelete(); charServerHandler->mCharCreateDialog = nullptr; diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index f985d12e1..2bc869d92 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -51,7 +51,7 @@ ChatHandler::ChatHandler() : void ChatHandler::talk(const std::string &restrict text, const std::string &restrict channel A_UNUSED) const { - if (!localPlayer) + if (localPlayer == nullptr) return; if (tmwServerVersion >= 0x100408) diff --git a/src/net/tmwa/chatrecv.cpp b/src/net/tmwa/chatrecv.cpp index 40331db5f..116674c53 100644 --- a/src/net/tmwa/chatrecv.cpp +++ b/src/net/tmwa/chatrecv.cpp @@ -68,7 +68,7 @@ void ChatRecv::processChatContinue(std::string chatMsg, const size_t pos = chatMsg.find(" : ", 0); bool allow(true); - if (chatWindow) + if (chatWindow != nullptr) { allow = chatWindow->resortChatLog(chatMsg, ChatMsgType::BY_PLAYER, @@ -80,7 +80,7 @@ void ChatRecv::processChatContinue(std::string chatMsg, if (channel.empty()) { const std::string senseStr("You sense the following: "); - if (actorManager && !chatMsg.find(senseStr)) + if ((actorManager != nullptr) && (chatMsg.find(senseStr) == 0u)) { actorManager->parseLevels( chatMsg.substr(senseStr.size())); @@ -111,9 +111,9 @@ void ChatRecv::processChatContinue(std::string chatMsg, trim(chatMsg); - if (localPlayer) + if (localPlayer != nullptr) { - if ((chatWindow || Ea::ChatRecv::mShowMotd) && allow) + if (((chatWindow != nullptr) || Ea::ChatRecv::mShowMotd) && allow) localPlayer->setSpeech(chatMsg, channel); } BLOCK_END("ChatRecv::processChat") @@ -131,9 +131,9 @@ void ChatRecv::processGmChat(Net::MessageIn &msg) std::string chatMsg = msg.readRawString(chatMsgLength, "message"); - if (localChatTab) + if (localChatTab != nullptr) { - if (chatWindow) + if (chatWindow != nullptr) chatWindow->addGlobalMessage(chatMsg); } BLOCK_END("ChatRecv::processChat") @@ -177,7 +177,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick, if (nick != "Server") { - if (guildManager && GuildManager::getEnableGuildBot() + if ((guildManager != nullptr) && GuildManager::getEnableGuildBot() && nick == "guild" && guildManager->processGuildMessage(chatMsg)) { BLOCK_END("ChatRecv::processWhisper") @@ -190,13 +190,13 @@ void ChatRecv::processWhisperContinue(const std::string &nick, const bool showMsg = !config.getBoolValue("hideShopMessages"); if (player_relations.hasPermission(nick, PlayerRelation::TRADE)) { - if (shopWindow) + if (shopWindow != nullptr) { // commands to shop from player if (chatMsg.find("!selllist ") == 0) { if (tradeBot) { - if (showMsg && chatWindow) + if (showMsg && (chatWindow != nullptr)) chatWindow->addWhisper(nick, chatMsg); shopWindow->giveList(nick, ShopWindow::SELL); } @@ -205,14 +205,14 @@ void ChatRecv::processWhisperContinue(const std::string &nick, { if (tradeBot) { - if (showMsg && chatWindow) + if (showMsg && (chatWindow != nullptr)) chatWindow->addWhisper(nick, chatMsg); shopWindow->giveList(nick, ShopWindow::BUY); } } else if (chatMsg.find("!buyitem ") == 0) { - if (showMsg && chatWindow) + if (showMsg && (chatWindow != nullptr)) chatWindow->addWhisper(nick, chatMsg); if (tradeBot) { @@ -222,7 +222,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick, } else if (chatMsg.find("!sellitem ") == 0) { - if (showMsg && chatWindow) + if (showMsg && (chatWindow != nullptr)) chatWindow->addWhisper(nick, chatMsg); if (tradeBot) { @@ -234,24 +234,24 @@ void ChatRecv::processWhisperContinue(const std::string &nick, && chatMsg.find("\302\202") == 0) { chatMsg = chatMsg.erase(0, 2); - if (showMsg && chatWindow) + if (showMsg && (chatWindow != nullptr)) chatWindow->addWhisper(nick, chatMsg); if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0) shopWindow->showList(nick, chatMsg); } - else if (chatWindow) + else if (chatWindow != nullptr) { chatWindow->addWhisper(nick, chatMsg); } } - else if (chatWindow) + else if (chatWindow != nullptr) { chatWindow->addWhisper(nick, chatMsg); } } else { - if (chatWindow && (showMsg || (chatMsg.find("!selllist") != 0 + if ((chatWindow != nullptr) && (showMsg || (chatMsg.find("!selllist") != 0 && chatMsg.find("!buylist") != 0))) { chatWindow->addWhisper(nick, chatMsg); @@ -259,9 +259,9 @@ void ChatRecv::processWhisperContinue(const std::string &nick, } } } - else if (localChatTab) + else if (localChatTab != nullptr) { - if (gmChatTab && strStartWith(chatMsg, "[GM] ")) + if ((gmChatTab != nullptr) && strStartWith(chatMsg, "[GM] ")) { chatMsg = chatMsg.substr(5); const size_t pos = chatMsg.find(": ", 0); @@ -285,7 +285,7 @@ void ChatRecv::processWhisperContinue(const std::string &nick, void ChatRecv::processBeingChat(Net::MessageIn &msg) { - if (!actorManager) + if (actorManager == nullptr) return; BLOCK_START("ChatRecv::processBeingChat") @@ -301,7 +301,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) std::string chatMsg = msg.readRawString(chatMsgLength, "message"); - if (being && being->getType() == ActorType::Player) + if ((being != nullptr) && being->getType() == ActorType::Player) being->setTalkTime(); const size_t pos = chatMsg.find(" : ", 0); @@ -311,7 +311,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) if (serverFeatures->haveIncompleteChatMessages()) { // work around for "new" tmw server - if (being) + if (being != nullptr) sender_name = being->getName(); if (sender_name.empty()) { @@ -321,7 +321,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) sender_name.append(" ").append(name); } } - else if (being && + else if ((being != nullptr) && sender_name != being->getName() && being->getType() == ActorType::Player) { @@ -339,9 +339,9 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) // We use getIgnorePlayer instead of ignoringPlayer here // because ignorePlayer' side effects are triggered // right below for Being::IGNORE_SPEECH_FLOAT. - if (player_relations.checkPermissionSilently(sender_name, - PlayerRelation::SPEECH_LOG) && - chatWindow) + if ((player_relations.checkPermissionSilently(sender_name, + PlayerRelation::SPEECH_LOG) != 0u) && + (chatWindow != nullptr)) { allow = chatWindow->resortChatLog( removeColors(sender_name).append(" : ").append(chatMsg), @@ -352,7 +352,7 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) } if (allow && - being && + (being != nullptr) && player_relations.hasPermission(sender_name, PlayerRelation::SPEECH_FLOAT)) { diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index 2eb505431..d01acd178 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -57,7 +57,7 @@ void GameHandler::mapLoadedEvent() const void GameHandler::connect() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; BLOCK_START("GameHandler::connect") @@ -67,7 +67,7 @@ void GameHandler::connect() const if (client->getState() == State::CONNECT_GAME) { // Change the player's ID to the account ID to match what eAthena uses - if (localPlayer) + if (localPlayer != nullptr) { Ea::GameRecv::mCharID = localPlayer->getId(); localPlayer->setId(token.account_ID); @@ -100,7 +100,7 @@ void GameHandler::connect() const bool GameHandler::isConnected() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return false; return Network::mInstance->isConnected(); } @@ -108,7 +108,7 @@ bool GameHandler::isConnected() const void GameHandler::disconnect() const { BLOCK_START("GameHandler::disconnect") - if (Network::mInstance) + if (Network::mInstance != nullptr) Network::mInstance->disconnect(); BLOCK_END("GameHandler::disconnect") } diff --git a/src/net/tmwa/gamerecv.cpp b/src/net/tmwa/gamerecv.cpp index e71bdc3b7..ab13076fb 100644 --- a/src/net/tmwa/gamerecv.cpp +++ b/src/net/tmwa/gamerecv.cpp @@ -51,12 +51,12 @@ void GameRecv::processMapLogin(Net::MessageIn &msg) mLastHost &= 0xffffff; Network *const network = Network::mInstance; - if (network) + if (network != nullptr) network->pauseDispatch(); // Switch now or we'll have problems client->setState(State::GAME); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->setTileCoords(x, y); } diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index e50ddcbb7..25e4aa1ad 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -129,7 +129,7 @@ void GeneralHandler::load() const void GeneralHandler::reload() const { - if (Network::mInstance) + if (Network::mInstance != nullptr) Network::mInstance->disconnect(); static_cast<LoginHandler*>(mLoginHandler)->clearWorlds(); @@ -152,7 +152,7 @@ void GeneralHandler::unload() const void GeneralHandler::flushSend() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; Network::mInstance->flush(); @@ -160,7 +160,7 @@ void GeneralHandler::flushSend() const void GeneralHandler::flushNetwork() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; BLOCK_START("GeneralHandler::flushNetwork 1") @@ -188,19 +188,19 @@ void GeneralHandler::flushNetwork() const void GeneralHandler::clearHandlers() const { - if (Network::mInstance) + if (Network::mInstance != nullptr) Network::mInstance->clearHandlers(); } void GeneralHandler::gameStarted() const { - if (skillDialog) + if (skillDialog != nullptr) skillDialog->loadSkills(); } void GeneralHandler::gameEnded() const { - if (socialWindow) + if (socialWindow != nullptr) socialWindow->removeTab(Ea::taParty); delete2(partyTab); diff --git a/src/net/tmwa/guildmanager.cpp b/src/net/tmwa/guildmanager.cpp index 7615b02ab..d3670cdac 100644 --- a/src/net/tmwa/guildmanager.cpp +++ b/src/net/tmwa/guildmanager.cpp @@ -80,15 +80,15 @@ void GuildManager::init() val = 0; serverConfig.setValue("enableGuildBot", val); } - mEnableGuildBot = val; + mEnableGuildBot = (val != 0); if (mEnableGuildBot) { - if (!guildManager) + if (guildManager == nullptr) guildManager = new GuildManager; else guildManager->reload(); } - else if (guildManager) + else if (guildManager != nullptr) { delete2(guildManager); } @@ -106,10 +106,10 @@ void GuildManager::reload() mRequestTime = 0; mTempList.clear(); - if (socialWindow) + if (socialWindow != nullptr) { Guild *const guild = Guild::getGuild(1); - if (guild && socialWindow) + if ((guild != nullptr) && (socialWindow != nullptr)) socialWindow->removeTab(guild); } delete2(mTab); @@ -122,7 +122,7 @@ void GuildManager::send(const std::string &msg) void GuildManager::chat(const std::string &msg) { - if (!localPlayer || !mTab) + if ((localPlayer == nullptr) || (mTab == nullptr)) return; chatHandler->privateMessage("guild", msg); @@ -132,7 +132,7 @@ void GuildManager::chat(const std::string &msg) void GuildManager::getNames(StringVect &names) const { const Guild *const guild = createGuild(); - if (guild) + if (guild != nullptr) guild->getNames(names); } @@ -177,7 +177,7 @@ void GuildManager::slowLogic() void GuildManager::updateList() { Guild *const guild = Guild::getGuild(1); - if (guild) + if (guild != nullptr) { guild->setServerGuild(false); StringVectCIter it = mTempList.begin(); @@ -194,17 +194,18 @@ void GuildManager::updateList() name = name.substr(0, sz - 1); GuildMember *const m = guild->addMember( fromInt(i, BeingId), 0, name); - if (m) + if (m != nullptr) { - m->setOnline(status & 1); + m->setOnline((status & 1) != 0); m->setGender(Gender::UNSPECIFIED); - if (status & 2) + if ((status & 2) != 0) m->setPos(10); else m->setPos(0); - if (localPlayer && name == localPlayer->getName()) + if (localPlayer != nullptr && + name == localPlayer->getName()) { - mHavePower = (status & 2); + mHavePower = ((status & 2) != 0); m->setOnline(true); } } @@ -214,12 +215,12 @@ void GuildManager::updateList() } guild->sort(); createTab(guild); - if (actorManager) + if (actorManager != nullptr) { actorManager->updatePlayerGuild(); actorManager->updatePlayerColors(); } - if (socialWindow) + if (socialWindow != nullptr) socialWindow->updateGuildCounter(); } mTempList.clear(); @@ -229,12 +230,12 @@ void GuildManager::updateList() void GuildManager::createTab(Guild *const guild) { - if (!mTab) + if (mTab == nullptr) { mTab = new EmulateGuildTab(chatWindow); if (config.getBoolValue("showChatHistory")) mTab->loadFromLogFile("#Guild"); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->addGuild(guild); } } @@ -242,7 +243,7 @@ void GuildManager::createTab(Guild *const guild) Guild *GuildManager::createGuild() const { Guild *const guild = Guild::getGuild(1); - if (!guild) + if (guild == nullptr) return nullptr; guild->setServerGuild(false); @@ -269,7 +270,7 @@ bool GuildManager::process(std::string msg) if (!haveNick && findCutLast(msg, " is now Offline.")) { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; if (msg.size() < 4) return false; @@ -277,40 +278,40 @@ bool GuildManager::process(std::string msg) msg = msg.substr(3); GuildMember *const m = guild->addMember(msg); - if (m) + if (m != nullptr) m->setOnline(false); guild->sort(); mRequest = false; - if (mTab) + if (mTab != nullptr) mTab->showOnline(msg, Online_false); - if (socialWindow) + if (socialWindow != nullptr) socialWindow->updateGuildCounter(); return true; } else if (!haveNick && findCutLast(msg, " is now Online.")) { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; if (msg.size() < 4) return false; if (msg[0] == '#' && msg[1] == '#') msg = msg.substr(3); GuildMember *const m = guild->addMember(msg); - if (m) + if (m != nullptr) m->setOnline(true); guild->sort(); mRequest = false; - if (mTab) + if (mTab != nullptr) mTab->showOnline(msg, Online_true); - if (socialWindow) + if (socialWindow != nullptr) socialWindow->updateGuildCounter(); return true; } else if (findCutFirst(msg, "Welcome to the ")) { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; // logger->log("welcome message: %s", msg.c_str()); const size_t pos = msg.find("! ("); @@ -318,7 +319,7 @@ bool GuildManager::process(std::string msg) return false; msg = msg.substr(0, pos); guild->setName(msg); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->setGuildName(msg); mGotName = true; mSentNameRequest = false; @@ -328,7 +329,7 @@ bool GuildManager::process(std::string msg) else if (findCutFirst(msg, "Player name: ")) { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; size_t pos = msg.find("Access Level: "); if (pos == std::string::npos) @@ -357,7 +358,7 @@ bool GuildManager::process(std::string msg) // logger->log("guild name: %s", msg.c_str()); guild->setName(msg); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->setGuildName(msg); mGotName = true; mSentNameRequest = false; @@ -396,7 +397,7 @@ bool GuildManager::process(std::string msg) && findCutLast(msg, " guild chat. If you would like to accept " "this invitation please reply \"yes\" and if not then \"no\" .")) { - if (socialWindow) + if (socialWindow != nullptr) socialWindow->showGuildInvite(msg, 1, ""); return true; } @@ -404,19 +405,19 @@ bool GuildManager::process(std::string msg) "from the Guild.") || findCutLast(msg, " has left the Guild."))) { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; if (msg.size() < 4) return false; if (msg[0] == '#' && msg[1] == '#') msg = msg.substr(3); - if (actorManager) + if (actorManager != nullptr) { Being *const b = actorManager->findBeingByName( msg, ActorType::Player); - if (b) + if (b != nullptr) { b->clearGuilds(); b->setGuildName(""); @@ -435,19 +436,19 @@ bool GuildManager::process(std::string msg) else { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; - if (!mTab) + if (mTab == nullptr) { createTab(guild); } - if (mTab) + if (mTab != nullptr) { const size_t pos = msg.find(": ", 0); if (pos != std::string::npos) { const std::string sender_name = msg.substr(0, pos); - if (!guild->getMember(sender_name)) + if (guild->getMember(sender_name) == nullptr) { mTab->chatLog(msg, ChatMsgType::BY_SERVER); return true; @@ -495,10 +496,10 @@ void GuildManager::notice(const std::string &msg) void GuildManager::clear() { - if (socialWindow) + if (socialWindow != nullptr) { Guild *const guild = Guild::getGuild(1); - if (guild) + if (guild != nullptr) socialWindow->removeTab(guild); } } @@ -514,11 +515,11 @@ void GuildManager::inviteResponse(const bool response) bool GuildManager::afterRemove() { Guild *const guild = createGuild(); - if (!guild) + if (guild == nullptr) return false; guild->removeFromMembers(); guild->clearMembers(); - if (localPlayer) + if (localPlayer != nullptr) { localPlayer->setGuildName(""); localPlayer->clearGuilds(); @@ -526,9 +527,9 @@ bool GuildManager::afterRemove() NotifyManager::notify(NotifyTypes::GUILD_LEFT); delete2(mTab); - if (socialWindow) + if (socialWindow != nullptr) socialWindow->removeTab(guild); - if (actorManager) + if (actorManager != nullptr) { actorManager->updatePlayerGuild(); actorManager->updatePlayerColors(); diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index e3172c583..2d555fb84 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -69,7 +69,7 @@ InventoryHandler::~InventoryHandler() void InventoryHandler::equipItem(const Item *const item) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_PLAYER_EQUIP); @@ -80,7 +80,7 @@ void InventoryHandler::equipItem(const Item *const item) const void InventoryHandler::unequipItem(const Item *const item) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_PLAYER_UNEQUIP); @@ -90,7 +90,7 @@ void InventoryHandler::unequipItem(const Item *const item) const void InventoryHandler::useItem(const Item *const item) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_PLAYER_INVENTORY_USE); @@ -101,7 +101,7 @@ void InventoryHandler::useItem(const Item *const item) const void InventoryHandler::dropItem(const Item *const item, const int amount) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_PLAYER_INVENTORY_DROP); diff --git a/src/net/tmwa/inventoryrecv.cpp b/src/net/tmwa/inventoryrecv.cpp index 974fd40c8..b699fe49e 100644 --- a/src/net/tmwa/inventoryrecv.cpp +++ b/src/net/tmwa/inventoryrecv.cpp @@ -77,12 +77,12 @@ namespace InventoryRecv void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerEquipment") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; msg.readInt16("len"); Equipment *const equipment = PlayerInfo::getEquipment(); - if (equipment && !equipment->getBackend()) + if ((equipment != nullptr) && (equipment->getBackend() == nullptr)) { // look like SMSG_PLAYER_INVENTORY was not received Ea::InventoryRecv::mEquips.clear(); equipment->setBackend(&Ea::InventoryRecv::mEquips); @@ -110,7 +110,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) index, itemId, CAST_S32(itemType), identified); } - if (inventory) + if (inventory != nullptr) { inventory->setItem(index, itemId, @@ -126,7 +126,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) inventory->setCards(index, cards, 4); } - if (equipType) + if (equipType != 0) { Ea::InventoryRecv::mEquips.setEquipment( InventoryRecv::getSlot(equipType), @@ -139,11 +139,11 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerInventoryAdd") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; - if (PlayerInfo::getEquipment() - && !PlayerInfo::getEquipment()->getBackend()) + if ((PlayerInfo::getEquipment() != nullptr) + && (PlayerInfo::getEquipment()->getBackend() == nullptr)) { // look like SMSG_PLAYER_INVENTORY was not received Ea::InventoryRecv::mEquips.clear(); PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips); @@ -171,7 +171,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) Ea::InventoryRecv::mSentPickups.pop(); } - if (err) + if (err != 0u) { PickupT pickup; switch (err) @@ -199,7 +199,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) UNIMPLEMENTEDPACKETFIELD(err); break; } - if (localPlayer) + if (localPlayer != nullptr) { if (itemId == 0) { @@ -221,7 +221,7 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) } else { - if (localPlayer) + if (localPlayer != nullptr) { if (itemId == 0) { @@ -241,11 +241,11 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) } } - if (inventory) + if (inventory != nullptr) { const Item *const item = inventory->getItem(index); - if (item && item->getId() == itemId) + if ((item != nullptr) && item->getId() == itemId) amount += item->getQuantity(); inventory->setItem(index, @@ -269,17 +269,17 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerInventory") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; - if (PlayerInfo::getEquipment()) + if (PlayerInfo::getEquipment() != nullptr) { // Clear inventory - this will be a complete refresh Ea::InventoryRecv::mEquips.clear(); PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips); } - if (inventory) + if (inventory != nullptr) inventory->clear(); msg.readInt16("len"); @@ -307,9 +307,9 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) } // Trick because arrows are not considered equipment - const bool isEquipment = arrow & 0x8000; + const bool isEquipment = (arrow & 0x8000) != 0; - if (inventory) + if (inventory != nullptr) { inventory->setItem(index, itemId, @@ -381,7 +381,7 @@ void InventoryRecv::processPlayerEquip(Net::MessageIn &msg) const int equipType = msg.readInt16("equip type"); const uint8_t flag = msg.readUInt8("flag"); - if (!flag) + if (flag == 0u) { NotifyManager::notify(NotifyTypes::EQUIP_FAILED); } @@ -401,13 +401,13 @@ void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg) const int equipType = msg.readInt16("equip type"); const uint8_t flag = msg.readUInt8("flag"); - if (flag) + if (flag != 0u) { Ea::InventoryRecv::mEquips.setEquipment( InventoryRecv::getSlot(equipType), -1); } - if (equipType & 0x8000) + if ((equipType & 0x8000) != 0) ArrowsListener::distributeEvent(); BLOCK_END("InventoryRecv::processPlayerUnEquip") } @@ -482,7 +482,7 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg) } else { - if (Ea::InventoryRecv::mStorage) + if (Ea::InventoryRecv::mStorage != nullptr) { Ea::InventoryRecv::mStorage->setItem(index, itemId, @@ -507,7 +507,7 @@ void InventoryRecv::processPlayerStorageRemove(Net::MessageIn &msg) // Move an item out of storage const int index = msg.readInt16("index") - STORAGE_OFFSET; const int amount = msg.readInt32("amount"); - if (Ea::InventoryRecv::mStorage) + if (Ea::InventoryRecv::mStorage != nullptr) { if (Item *const item = Ea::InventoryRecv::mStorage->getItem(index)) { @@ -522,12 +522,12 @@ void InventoryRecv::processPlayerStorageRemove(Net::MessageIn &msg) void InventoryRecv::processPlayerInventoryRemove(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerInventoryRemove") - Inventory *const inventory = localPlayer + Inventory *const inventory = localPlayer != nullptr ? PlayerInfo::getInventory() : nullptr; const int index = msg.readInt16("index") - INVENTORY_OFFSET; const int amount = msg.readInt16("amount"); - if (inventory) + if (inventory != nullptr) { if (Item *const item = inventory->getItem(index)) { @@ -545,12 +545,12 @@ int InventoryRecv::getSlot(const int eAthenaSlot) if (eAthenaSlot == 0) return EquipSlot::VECTOREND; - if (eAthenaSlot & 0x8000) + if ((eAthenaSlot & 0x8000) != 0) return inventoryHandler->getProjectileSlot(); unsigned int mask = 1; int position = 0; - while (!(eAthenaSlot & mask)) + while ((eAthenaSlot & mask) == 0u) { mask <<= 1; position++; diff --git a/src/net/tmwa/itemrecv.cpp b/src/net/tmwa/itemrecv.cpp index 1fe1d866c..53d3a19bc 100644 --- a/src/net/tmwa/itemrecv.cpp +++ b/src/net/tmwa/itemrecv.cpp @@ -42,7 +42,7 @@ void ItemRecv::processItemDropped(Net::MessageIn &msg) const int subY = CAST_S32(msg.readInt8("sub y")); const int amount = msg.readInt16("amount"); - if (actorManager) + if (actorManager != nullptr) { actorManager->createItem(id, itemId, @@ -70,7 +70,7 @@ void ItemRecv::processItemVisible(Net::MessageIn &msg) const int subX = CAST_S32(msg.readInt8("sub x")); const int subY = CAST_S32(msg.readInt8("sub y")); - if (actorManager) + if (actorManager != nullptr) { actorManager->createItem(id, itemId, diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 392598161..393935f1a 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -52,7 +52,7 @@ LoginHandler::~LoginHandler() void LoginHandler::connect() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return; Network::mInstance->connect(mServer); @@ -64,7 +64,7 @@ void LoginHandler::connect() const bool LoginHandler::isConnected() const { - if (!Network::mInstance) + if (Network::mInstance == nullptr) return false; return Ea::LoginRecv::mVersionResponse && @@ -73,8 +73,11 @@ bool LoginHandler::isConnected() const void LoginHandler::disconnect() const { - if (Network::mInstance && Network::mInstance->getServer() == mServer) + if (Network::mInstance != nullptr && + Network::mInstance->getServer() == mServer) + { Network::mInstance->disconnect(); + } } void LoginHandler::changePassword(const std::string &restrict oldPassword, diff --git a/src/net/tmwa/loginrecv.cpp b/src/net/tmwa/loginrecv.cpp index 050bd68c1..05b4aaba3 100644 --- a/src/net/tmwa/loginrecv.cpp +++ b/src/net/tmwa/loginrecv.cpp @@ -62,21 +62,24 @@ void LoginRecv::processServerVersion(Net::MessageIn &msg) if (b1 == 255) { // old TMWA const unsigned int options = msg.readInt32("options"); - Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION; + Ea::LoginRecv::mRegistrationEnabled = + ((options & FLAG_REGISTRATION) != 0u); serverVersion = 0; tmwServerVersion = 0; } else if (b1 >= 0x0d) { // new TMWA const unsigned int options = msg.readInt32("options"); - Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION; + Ea::LoginRecv::mRegistrationEnabled = + ((options & FLAG_REGISTRATION) != 0u); serverVersion = 0; tmwServerVersion = (b1 << 16) | (b2 << 8) | b3; } else { // eAthena const unsigned int options = msg.readInt32("options"); - Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION; + Ea::LoginRecv::mRegistrationEnabled = + ((options & FLAG_REGISTRATION) != 0u); serverVersion = 0; tmwServerVersion = 0; } diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index c3b9d45d3..30ec6e8ec 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -132,7 +132,7 @@ void Network::dispatchMessages() if (msgId < messagesSize) { const PacketFuncPtr func = mPackets[msgId].func; - if (func) + if (func != nullptr) func(msg); else logger->log("Unhandled packet: %u 0x%x", msgId, msgId); diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 898e9fff4..0c0b13116 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -52,7 +52,7 @@ NpcHandler::NpcHandler() : void NpcHandler::talk(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_NPC_TALK); outMsg.writeBeingId(being->getId(), "npc id"); @@ -74,7 +74,7 @@ void NpcHandler::closeDialog(const BeingId npcId) if (it != NpcDialog::mNpcDialogs.end()) { NpcDialog *const dialog = (*it).second; - if (dialog) + if (dialog != nullptr) dialog->close(); if (dialog == Ea::NpcRecv::mDialog) Ea::NpcRecv::mDialog = nullptr; @@ -110,7 +110,7 @@ void NpcHandler::stringInput(const BeingId npcId, void NpcHandler::buy(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_NPC_BUY_SELL_REQUEST); outMsg.writeBeingId(being->getId(), "npc id"); @@ -223,7 +223,7 @@ BeingId NpcHandler::getNpc(Net::MessageIn &msg, { CREATEWIDGETV(Ea::NpcRecv::mDialog, NpcDialog, npcId); Ea::NpcRecv::mDialog->saveCamera(); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->stopWalking(false); NpcDialog::mNpcDialogs[npcId] = Ea::NpcRecv::mDialog; } @@ -231,10 +231,10 @@ BeingId NpcHandler::getNpc(Net::MessageIn &msg, else { NpcDialog *const dialog = diag->second; - if (Ea::NpcRecv::mDialog && Ea::NpcRecv::mDialog != dialog) + if (Ea::NpcRecv::mDialog != nullptr && Ea::NpcRecv::mDialog != dialog) Ea::NpcRecv::mDialog->restoreCamera(); Ea::NpcRecv::mDialog = dialog; - if (Ea::NpcRecv::mDialog) + if (Ea::NpcRecv::mDialog != nullptr) Ea::NpcRecv::mDialog->saveCamera(); } return npcId; diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index ae93238f4..54c808556 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -59,12 +59,12 @@ void PartyHandler::create(const std::string &name) const void PartyHandler::invite(const std::string &name) const { - if (!actorManager) + if (actorManager == nullptr) return; const Being *const being = actorManager->findBeingByName( name, ActorType::Player); - if (being) + if (being != nullptr) { createOutPacket(CMSG_PARTY_INVITE); outMsg.writeBeingId(being->getId(), "account id"); @@ -74,7 +74,7 @@ void PartyHandler::invite(const std::string &name) const void PartyHandler::inviteResponse(const int partyId A_UNUSED, const bool accept) const { - if (localPlayer) + if (localPlayer != nullptr) { createOutPacket(CMSG_PARTY_INVITED); outMsg.writeBeingId(localPlayer->getId(), "account id"); @@ -89,7 +89,7 @@ void PartyHandler::leave() const void PartyHandler::kick(const Being *const being) const { - if (being) + if (being != nullptr) { createOutPacket(CMSG_PARTY_KICK); outMsg.writeBeingId(being->getId(), "account id"); @@ -99,11 +99,11 @@ void PartyHandler::kick(const Being *const being) const void PartyHandler::kick(const std::string &name) const { - if (!Ea::taParty) + if (Ea::taParty == nullptr) return; const PartyMember *const m = Ea::taParty->getMember(name); - if (!m) + if (m == nullptr) { NotifyManager::notify(NotifyTypes::PARTY_USER_NOT_IN_PARTY, name); return; diff --git a/src/net/tmwa/partyrecv.cpp b/src/net/tmwa/partyrecv.cpp index a54e35cc0..78c012652 100644 --- a/src/net/tmwa/partyrecv.cpp +++ b/src/net/tmwa/partyrecv.cpp @@ -45,9 +45,9 @@ namespace TmwAthena void PartyRecv::processPartySettings(Net::MessageIn &msg) { - if (!partyTab) + if (partyTab == nullptr) { - if (!chatWindow) + if (chatWindow == nullptr) return; Ea::PartyRecv::createTab(); @@ -67,12 +67,12 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg) bool isOldParty = false; std::set<std::string> names; std::set<std::string> onlineNames; - if (!Ea::taParty) + if (Ea::taParty == nullptr) { logger->log1("error: party empty in SMSG_PARTY_INFO"); Ea::taParty = Party::getParty(1); } - if (Ea::taParty) + if (Ea::taParty != nullptr) { if (Ea::taParty->getNumberOfElements() > 1) { @@ -84,23 +84,23 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg) if ((*it)->getOnline()) onlineNames.insert((*it)->getName()); } - if (localPlayer) + if (localPlayer != nullptr) onlineNames.insert(localPlayer->getName()); } } - if (!localPlayer) + if (localPlayer == nullptr) logger->log1("error: localPlayer==0 in SMSG_PARTY_INFO"); - if (Ea::taParty) + if (Ea::taParty != nullptr) Ea::taParty->clearMembers(); const int length = msg.readInt16("len"); - if (Ea::taParty) + if (Ea::taParty != nullptr) Ea::taParty->setName(msg.readString(24, "party name")); const int count = (length - 28) / 46; - if (localPlayer && Ea::taParty) + if ((localPlayer != nullptr) && (Ea::taParty != nullptr)) { localPlayer->setParty(Ea::taParty); localPlayer->setPartyName(Ea::taParty->getName()); @@ -114,7 +114,7 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg) const bool leader = msg.readUInt8("leader") == 0U; const bool online = msg.readUInt8("online") == 0U; - if (Ea::taParty) + if (Ea::taParty != nullptr) { bool joined(false); @@ -128,9 +128,9 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg) } } PartyMember *const member = Ea::taParty->addMember(id, nick); - if (member) + if (member != nullptr) { - if (!joined && partyTab) + if (!joined && (partyTab != nullptr)) { if (!names.empty() && ((onlineNames.find(nick) == onlineNames.end() && online) @@ -154,14 +154,14 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg) } } - if (Ea::taParty) + if (Ea::taParty != nullptr) Ea::taParty->sort(); - if (localPlayer && Ea::taParty) + if ((localPlayer != nullptr) && (Ea::taParty != nullptr)) { localPlayer->setParty(Ea::taParty); localPlayer->setPartyName(Ea::taParty->getName()); - if (socialWindow) + if (socialWindow != nullptr) socialWindow->updateParty(); } } @@ -175,10 +175,10 @@ void PartyRecv::processPartyMessage(Net::MessageIn &msg) const BeingId id = msg.readBeingId("id"); const std::string chatMsg = msg.readString(msgLength, "message"); - if (Ea::taParty && partyTab) + if ((Ea::taParty != nullptr) && (partyTab != nullptr)) { const PartyMember *const member = Ea::taParty->getMember(id); - if (member) + if (member != nullptr) { partyTab->chatLog(member->getName(), chatMsg); } @@ -192,7 +192,7 @@ void PartyRecv::processPartyMessage(Net::MessageIn &msg) void PartyRecv::processPartyInviteResponse(Net::MessageIn &msg) { - if (!partyTab) + if (partyTab == nullptr) return; const std::string nick = msg.readString(24, "nick"); @@ -225,17 +225,17 @@ void PartyRecv::processPartyInvited(Net::MessageIn &msg) const std::string partyName = msg.readString(24, "party name"); std::string nick; - if (actorManager) + if (actorManager != nullptr) { const Being *const being = actorManager->findBeing(id); - if (being) + if (being != nullptr) { if (being->getType() == ActorType::Player) nick = being->getName(); } } - if (socialWindow) + if (socialWindow != nullptr) socialWindow->showPartyInvite(partyName, nick, 0); } @@ -243,9 +243,9 @@ void PartyRecv::processPartyMove(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("id"); PartyMember *m = nullptr; - if (Ea::taParty) + if (Ea::taParty != nullptr) m = Ea::taParty->getMember(id); - if (m) + if (m != nullptr) { msg.readInt32("unused"); m->setX(msg.readInt16("x")); @@ -276,9 +276,9 @@ void PartyRecv::processPartyUpdateHp(Net::MessageIn &msg) const int hp = msg.readInt16("hp"); const int maxhp = msg.readInt16("max hp"); PartyMember *m = nullptr; - if (Ea::taParty) + if (Ea::taParty != nullptr) m = Ea::taParty->getMember(id); - if (m) + if (m != nullptr) { m->setHp(hp); m->setMaxHp(maxhp); @@ -286,7 +286,7 @@ void PartyRecv::processPartyUpdateHp(Net::MessageIn &msg) // The server only sends this when the member is in range, so // lets make sure they get the party hilight. - if (actorManager && Ea::taParty) + if ((actorManager != nullptr) && (Ea::taParty != nullptr)) { if (Being *const b = actorManager->findBeing(id)) b->setParty(Ea::taParty); diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index d9ec46fe3..66bd1a037 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -99,14 +99,14 @@ void PlayerHandler::increaseSkill(const uint16_t skillId) const void PlayerHandler::pickUp(const FloorItem *const floorItem) const { - if (!floorItem) + if (floorItem == nullptr) return; createOutPacket(CMSG_ITEM_PICKUP); outMsg.writeBeingId(floorItem->getId(), "object id"); TmwAthena::InventoryHandler *const handler = static_cast<TmwAthena::InventoryHandler*>(inventoryHandler); - if (handler) + if (handler != nullptr) handler->pushPickup(floorItem->getId()); } @@ -245,11 +245,11 @@ void PlayerHandler::setStat(Net::MessageIn &msg, break; case Sp::HP: PlayerInfo::setAttribute(Attributes::PLAYER_HP, base); - if (localPlayer->isInParty() && Party::getParty(1)) + if (localPlayer->isInParty() && (Party::getParty(1) != nullptr)) { PartyMember *const m = Party::getParty(1) ->getMember(localPlayer->getId()); - if (m) + if (m != nullptr) { m->setHp(base); m->setMaxHp(PlayerInfo::getAttribute( @@ -260,11 +260,11 @@ void PlayerHandler::setStat(Net::MessageIn &msg, case Sp::MAXHP: PlayerInfo::setAttribute(Attributes::PLAYER_MAX_HP, base); - if (localPlayer->isInParty() && Party::getParty(1)) + if (localPlayer->isInParty() && (Party::getParty(1) != nullptr)) { PartyMember *const m = Party::getParty(1)->getMember( localPlayer->getId()); - if (m) + if (m != nullptr) { m->setHp(PlayerInfo::getAttribute(Attributes::PLAYER_HP)); m->setMaxHp(base); @@ -282,7 +282,7 @@ void PlayerHandler::setStat(Net::MessageIn &msg, break; case Sp::BASELEVEL: PlayerInfo::setAttribute(Attributes::PLAYER_LEVEL, base); - if (localPlayer) + if (localPlayer != nullptr) { localPlayer->setLevel(base); localPlayer->updateName(); @@ -290,7 +290,7 @@ void PlayerHandler::setStat(Net::MessageIn &msg, break; case Sp::SKILLPOINT: PlayerInfo::setAttribute(Attributes::PLAYER_SKILL_POINTS, base); - if (skillDialog) + if (skillDialog != nullptr) skillDialog->update(); break; case Sp::STR: diff --git a/src/net/tmwa/playerrecv.cpp b/src/net/tmwa/playerrecv.cpp index 20a1d0d9f..b6b23403f 100644 --- a/src/net/tmwa/playerrecv.cpp +++ b/src/net/tmwa/playerrecv.cpp @@ -42,7 +42,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) unsigned int val = msg.readUInt8("str"); PlayerInfo::setStatBase(Attributes::PLAYER_STR, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_STR, msg.readUInt8("str cost")); @@ -54,7 +54,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) val = msg.readUInt8("agi"); PlayerInfo::setStatBase(Attributes::PLAYER_AGI, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_AGI, msg.readUInt8("agi cost")); @@ -66,7 +66,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) val = msg.readUInt8("vit"); PlayerInfo::setStatBase(Attributes::PLAYER_VIT, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_VIT, msg.readUInt8("vit cost")); @@ -78,7 +78,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) val = msg.readUInt8("int"); PlayerInfo::setStatBase(Attributes::PLAYER_INT, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_INT, msg.readUInt8("int cost")); @@ -90,7 +90,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) val = msg.readUInt8("dex"); PlayerInfo::setStatBase(Attributes::PLAYER_DEX, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_DEX, msg.readUInt8("dex cost")); @@ -102,7 +102,7 @@ void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg) val = msg.readUInt8("luk"); PlayerInfo::setStatBase(Attributes::PLAYER_LUK, val); - if (statusWindow) + if (statusWindow != nullptr) { statusWindow->setPointsNeeded(Attributes::PLAYER_LUK, msg.readUInt8("luk cost")); @@ -157,7 +157,7 @@ void PlayerRecv::processWalkResponse(Net::MessageIn &msg) msg.readInt32("tick"); msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path"); msg.readUInt8("unused"); - if (localPlayer) + if (localPlayer != nullptr) localPlayer->setRealPos(dstX, dstY); BLOCK_END("PlayerRecv::processWalkResponse") } diff --git a/src/net/tmwa/questrecv.cpp b/src/net/tmwa/questrecv.cpp index 7f732514c..d38012a69 100644 --- a/src/net/tmwa/questrecv.cpp +++ b/src/net/tmwa/questrecv.cpp @@ -36,12 +36,12 @@ void QuestRecv::processSetQuestVar(Net::MessageIn &msg) { const int var = msg.readInt16("variable"); const int val = msg.readInt32("value"); - if (questsWindow) + if (questsWindow != nullptr) { questsWindow->updateQuest(var, val, 0, 0, 0); questsWindow->rebuild(true); } - if (skillDialog) + if (skillDialog != nullptr) { skillDialog->updateQuest(var, val, 0, 0, 0); skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID); @@ -55,12 +55,12 @@ void QuestRecv::processPlayerQuests(Net::MessageIn &msg) { const int var = msg.readInt16("variable"); const int val = msg.readInt32("value"); - if (questsWindow) + if (questsWindow != nullptr) questsWindow->updateQuest(var, val, 0, 0, 0); - if (skillDialog) + if (skillDialog != nullptr) skillDialog->updateQuest(var, val, 0, 0, 0); } - if (questsWindow) + if (questsWindow != nullptr) questsWindow->rebuild(false); } diff --git a/src/net/tmwa/skillrecv.cpp b/src/net/tmwa/skillrecv.cpp index 546a94b2c..faea79059 100644 --- a/src/net/tmwa/skillrecv.cpp +++ b/src/net/tmwa/skillrecv.cpp @@ -60,10 +60,10 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg) msg.skip(24, "unused"); const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable); const int oldLevel = PlayerInfo::getSkillLevel(skillId); - if (oldLevel && oldLevel != level) + if ((oldLevel != 0) && oldLevel != level) updateSkill = skillId; PlayerInfo::setSkillLevel(skillId, level); - if (skillDialog) + if (skillDialog != nullptr) { if (!skillDialog->updateSkill(skillId, range, up, inf, sp)) { @@ -72,10 +72,10 @@ void SkillRecv::processPlayerSkills(Net::MessageIn &msg) } } } - if (skillDialog) + if (skillDialog != nullptr) { skillDialog->update(); - if (updateSkill) + if (updateSkill != 0) skillDialog->playUpdateEffect(updateSkill); } } @@ -99,7 +99,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) if (success == CAST_S32(SKILL_FAILED) && skillId == CAST_S32(SKILL_BASIC)) { - if (localPlayer && + if ((localPlayer != nullptr) && bskill == CAST_S32(BSKILL_EMOTE) && reason == CAST_S32(RFAIL_SKILLDEP)) { diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index 4310d4c4a..28ecb15df 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -48,7 +48,7 @@ TradeHandler::TradeHandler() : void TradeHandler::request(const Being *const being) const { - if (!being) + if (being == nullptr) return; createOutPacket(CMSG_TRADE_REQUEST); @@ -66,7 +66,7 @@ void TradeHandler::respond(const bool accept) const void TradeHandler::addItem(const Item *const item, const int amount) const { - if (!item) + if (item == nullptr) return; createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST); diff --git a/src/net/tmwa/traderecv.cpp b/src/net/tmwa/traderecv.cpp index a8233ef50..f846de3c0 100644 --- a/src/net/tmwa/traderecv.cpp +++ b/src/net/tmwa/traderecv.cpp @@ -68,7 +68,7 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) for (int f = 0; f < maxCards; f++) cards[f] = msg.readUInt16("card"); - if (tradeWindow) + if (tradeWindow != nullptr) { if (type == 0) { @@ -98,12 +98,12 @@ void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg) // Trade: New Item add response (was 0x00ea, now 01b1) const int index = msg.readInt16("index") - INVENTORY_OFFSET; Item *item = nullptr; - if (PlayerInfo::getInventory()) + if (PlayerInfo::getInventory() != nullptr) item = PlayerInfo::getInventory()->getItem(index); - if (!item) + if (item == nullptr) { - if (tradeWindow) + if (tradeWindow != nullptr) tradeWindow->receivedOk(true); return; } @@ -114,7 +114,7 @@ void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg) { case 0: // Successfully added item - if (tradeWindow) + if (tradeWindow != nullptr) { tradeWindow->addItem2(item->getId(), item->getType(), diff --git a/src/net/tmwa/updateprotocol.cpp b/src/net/tmwa/updateprotocol.cpp index cbf514c94..3928cc101 100644 --- a/src/net/tmwa/updateprotocol.cpp +++ b/src/net/tmwa/updateprotocol.cpp @@ -35,7 +35,7 @@ void updateProtocol() #include "net/tmwa/packetsout.inc" #undef packet Network *const network = Network::mInstance; - if (network) + if (network != nullptr) { network->clearHandlers(); network->registerHandlers(); |