diff options
Diffstat (limited to 'src/net/ea')
-rw-r--r-- | src/net/ea/beingrecv.cpp | 64 | ||||
-rw-r--r-- | src/net/ea/buysellrecv.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/charserverrecv.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/chathandler.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/chatrecv.cpp | 14 | ||||
-rw-r--r-- | src/net/ea/equipbackend.h | 14 | ||||
-rw-r--r-- | src/net/ea/gamerecv.cpp | 4 | ||||
-rw-r--r-- | src/net/ea/inventoryhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/ea/inventoryitem.h | 2 | ||||
-rw-r--r-- | src/net/ea/inventoryrecv.cpp | 22 | ||||
-rw-r--r-- | src/net/ea/itemrecv.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/loginhandler.cpp | 10 | ||||
-rw-r--r-- | src/net/ea/maprecv.cpp | 4 | ||||
-rw-r--r-- | src/net/ea/network.cpp | 20 | ||||
-rw-r--r-- | src/net/ea/npcrecv.cpp | 46 | ||||
-rw-r--r-- | src/net/ea/partyrecv.cpp | 18 | ||||
-rw-r--r-- | src/net/ea/playerrecv.cpp | 20 | ||||
-rw-r--r-- | src/net/ea/skillrecv.cpp | 4 | ||||
-rw-r--r-- | src/net/ea/traderecv.cpp | 16 |
19 files changed, 136 insertions, 134 deletions
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) |