From 566ae30ff94caf6c92fc7d64f021b567933f8a60 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 12 Sep 2014 17:07:09 +0300 Subject: fix code style. --- src/net/eathena/adminhandler.cpp | 19 +++++++------------ src/net/eathena/beinghandler.cpp | 29 ++++++++++++++++------------- src/net/eathena/charserverhandler.cpp | 18 +++++++++--------- src/net/eathena/chathandler.cpp | 7 ++++--- src/net/eathena/inventoryhandler.cpp | 16 +++++++++------- src/net/eathena/mailhandler.cpp | 4 ++-- src/net/eathena/npchandler.cpp | 16 ++++++++-------- src/net/eathena/partyhandler.cpp | 5 +++-- src/net/eathena/playerhandler.cpp | 8 ++++---- src/net/eathena/questhandler.cpp | 2 +- src/net/eathena/serverfeatures.cpp | 2 +- src/net/eathena/serverfeatures.h | 2 +- 12 files changed, 65 insertions(+), 63 deletions(-) (limited to 'src/net/eathena') diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp index c05c00771..7ef2dc645 100644 --- a/src/net/eathena/adminhandler.cpp +++ b/src/net/eathena/adminhandler.cpp @@ -24,11 +24,6 @@ #include "notifymanager.h" -#include "gui/chatconsts.h" - -#include "net/chathandler.h" -#include "net/net.h" - #include "net/eathena/messageout.h" #include "net/eathena/protocol.h" @@ -114,8 +109,8 @@ void AdminHandler::warp(const std::string &map, const int x, const int y) const { MessageOut outMsg(CMSG_PLAYER_MAPMOVE); outMsg.writeString(map, 16, "map"); - outMsg.writeInt16(x, "x"); - outMsg.writeInt16(y, "y"); + outMsg.writeInt16(static_cast(x), "x"); + outMsg.writeInt16(static_cast(y), "y"); } void AdminHandler::resetStats() const @@ -151,8 +146,8 @@ void AdminHandler::mute(const Being *const being, MessageOut outMsg(CMSG_ADMIN_MUTE); outMsg.writeInt32(being->getId(), "account id"); - outMsg.writeInt8(type, "type"); - outMsg.writeInt16(limit, "value"); + outMsg.writeInt8(static_cast(type), "type"); + outMsg.writeInt16(static_cast(limit), "value"); } void AdminHandler::muteName(const std::string &name) const @@ -174,9 +169,9 @@ void AdminHandler::setTileType(const int x, const int y, const int type) const { MessageOut outMsg(CMSG_ADMIN_SET_TILE_TYPE); - outMsg.writeInt16(x, "x"); - outMsg.writeInt16(y, "y"); - outMsg.writeInt16(type, "type"); + outMsg.writeInt16(static_cast(x), "x"); + outMsg.writeInt16(static_cast(y), "y"); + outMsg.writeInt16(static_cast(type), "type"); } void AdminHandler::unequipAll(const Being *const being) const diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 7f00dc9de..32305c4b1 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -736,7 +736,7 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg) const requestNameById(id); } - uint8_t dir = dstBeing->getDirectionDelayed(); + const uint8_t dir = dstBeing->getDirectionDelayed(); if (dir) { if (dir != dstBeing->getDirection()) @@ -874,7 +874,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg) int16_t speed = msg.readInt16("speed"); const uint16_t stunMode = msg.readInt16("opt1"); // probably wrong effect usage - uint32_t statusEffects = msg.readInt16("opt2"); + const uint32_t statusEffects = msg.readInt16("opt2"); msg.readInt32("option"); const int16_t job = msg.readInt16("class"); @@ -946,13 +946,14 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg) const int hairColor = msg.readInt16("hair color"); const uint16_t shoes = msg.readInt16("shoes or clothes color?"); - uint16_t gloves = msg.readInt16("head dir / gloves"); + const uint16_t gloves = msg.readInt16("head dir / gloves"); // may be use robe as gloves? msg.readInt16("robe"); msg.readInt32("guild id"); msg.readInt16("guild emblem"); msg.readInt16("manner"); - dstBeing->setStatusEffectBlock(32, msg.readInt32("opt3")); + dstBeing->setStatusEffectBlock(32, static_cast( + msg.readInt32("opt3"))); msg.readUInt8("karma"); uint8_t gender = msg.readUInt8("gender"); @@ -1036,7 +1037,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg) // { const uint16_t stunMode = msg.readInt16("opt1"); // probably wrong effect usage - uint32_t statusEffects = msg.readInt16("opt2"); + const uint32_t statusEffects = msg.readInt16("opt2"); // } // else // { @@ -1109,13 +1110,14 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg) const int hairColor = msg.readInt16("hair color"); const uint16_t shoes = msg.readInt16("shoes or clothes color?"); - uint16_t gloves = msg.readInt16("head dir / gloves"); + const uint16_t gloves = msg.readInt16("head dir / gloves"); // may be use robe as gloves? msg.readInt16("robe"); msg.readInt32("guild id"); msg.readInt16("guild emblem"); msg.readInt16("manner"); - dstBeing->setStatusEffectBlock(32, msg.readInt32("opt3")); + dstBeing->setStatusEffectBlock(32, static_cast( + msg.readInt32("opt3"))); msg.readUInt8("karma"); uint8_t gender = msg.readUInt8("gender"); @@ -1151,10 +1153,10 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg) // because server don't send direction in move packet, we fixing it - int d = 0; + uint8_t d = 0; if (srcX == dstX && srcY == dstY) { // if player did one step from invisible area to visible, - //move path is broken + // move path is broken int x2 = localPlayer->getTileX(); int y2 = localPlayer->getTileY(); if (abs(x2 - srcX) > abs(y2 - srcY)) @@ -1195,13 +1197,13 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg) // Information about a being in range const int id = msg.readInt32("being id"); mSpawnId = id; - int spawnId = id; + const int spawnId = id; int16_t speed = msg.readInt16("speed"); // if (visible) // { const uint16_t stunMode = msg.readInt16("opt1"); // probably wrong effect usage - uint32_t statusEffects = msg.readInt16("opt2"); + const uint32_t statusEffects = msg.readInt16("opt2"); // } // else // { @@ -1274,13 +1276,14 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg) const int hairColor = msg.readInt16("hair color"); const uint16_t shoes = msg.readInt16("shoes or clothes color?"); - uint16_t gloves = msg.readInt16("head dir / gloves"); + const uint16_t gloves = msg.readInt16("head dir / gloves"); // may be use robe as gloves? msg.readInt16("robe"); msg.readInt32("guild id"); msg.readInt16("guild emblem"); msg.readInt16("manner"); - dstBeing->setStatusEffectBlock(32, msg.readInt32("opt3")); + dstBeing->setStatusEffectBlock(32, static_cast( + msg.readInt32("opt3"))); msg.readUInt8("karma"); uint8_t gender = msg.readUInt8("gender"); diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp index 2f6898303..cea59955c 100644 --- a/src/net/eathena/charserverhandler.cpp +++ b/src/net/eathena/charserverhandler.cpp @@ -401,25 +401,25 @@ void CharServerHandler::processPincodeStatus(Net::MessageIn &msg) const uint16_t state = static_cast(msg.readInt16("state")); switch (state) { - case 0: // pin ok + case 0: // pin ok break; - case 1: // ask for pin + case 1: // ask for pin break; - case 2: // create new pin - case 4: // create new pin? + case 2: // create new pin + case 4: // create new pin? { mNeedCreatePin = true; break; } - case 3: // pin must be changed + case 3: // pin must be changed break; - case 5: // client show error? + case 5: // client show error? break; - case 6: // Unable to use your KSSN number + case 6: // Unable to use your KSSN number break; - case 7: // char select window shows a button + case 7: // char select window shows a button break; - case 8: // pincode was incorrect + case 8: // pincode was incorrect break; default: logger->log("processPincodeStatus: unknown pin state: %d", diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index 031222e3e..14c0fcea5 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -252,9 +252,10 @@ void ChatHandler::createChatRoom(const std::string &title, const bool isPublic) { MessageOut outMsg(CMSG_CREAYE_CHAT_ROOM); - outMsg.writeInt16(password.size() + title.size() + 5, "len"); + outMsg.writeInt16(static_cast( + password.size() + title.size() + 5), "len"); outMsg.writeInt16(static_cast(limit), "limit"); - outMsg.writeInt8(isPublic ? 1 : 0, "public"); + outMsg.writeInt8(static_cast(isPublic ? 1 : 0), "public"); outMsg.writeString(password, 8, "password"); outMsg.writeString(title, 36, "title"); } @@ -312,7 +313,7 @@ void ChatHandler::processChat(Net::MessageIn &msg) void ChatHandler::processGmChat2(Net::MessageIn &msg) { - int chatMsgLength = msg.readInt16("len") - 16; + const int chatMsgLength = msg.readInt16("len") - 16; msg.readInt32("font color"); msg.readInt16("font type"); msg.readInt16("font size"); diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 958866650..6b4a54abe 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -242,15 +242,17 @@ void InventoryHandler::moveItem2(const int source, void InventoryHandler::useCard(const int index) const { MessageOut outMsg(CMSG_PLAYER_USE_CARD); - outMsg.writeInt16(index + INVENTORY_OFFSET, "index"); + outMsg.writeInt16(static_cast(index + INVENTORY_OFFSET), "index"); } void InventoryHandler::insertCard(const int cardIndex, const int itemIndex) const { MessageOut outMsg(CMSG_PLAYER_INSERT_CARD); - outMsg.writeInt16(cardIndex + INVENTORY_OFFSET, "card index"); - outMsg.writeInt16(itemIndex + INVENTORY_OFFSET, "item index"); + outMsg.writeInt16(static_cast(cardIndex + INVENTORY_OFFSET), + "card index"); + outMsg.writeInt16(static_cast(itemIndex + INVENTORY_OFFSET), + "item index"); } void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) @@ -267,6 +269,7 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) equipment->setBackend(&mEquips); } const int number = (msg.getLength() - 4) / 31; + const uint8_t identified = 1; for (int loop = 0; loop < number; loop++) { @@ -288,7 +291,6 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) msg.readInt8("flags"); // need get actual identify flag - uint8_t identified = 1; if (inventory) { inventory->setItem(index, itemId, 1, refine, @@ -401,6 +403,7 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg) msg.readString(24, "storage name"); const int number = (msg.getLength() - 4) / 23; + const uint8_t identified = 1; for (int loop = 0; loop < number; loop++) { @@ -418,7 +421,6 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg) msg.readInt8("flags"); // need get actual identify flag - uint8_t identified = 1; if (playerInvintory) { // Trick because arrows are not considered equipment @@ -500,6 +502,7 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg) BLOCK_START("InventoryHandler::processPlayerStorageEquip") msg.readInt16("len"); const int number = (msg.getLength() - 4 - 24) / 31; + const uint8_t identified = 1; msg.readString(24, "storage name"); for (int loop = 0; loop < number; loop++) @@ -521,7 +524,6 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg) msg.readInt8("flags"); // need get identified from flags - uint8_t identified = 1; mInventoryItems.push_back(Ea::InventoryItem(index, itemId, amount, refine, identified, false)); } @@ -536,7 +538,7 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg) const int amount = msg.readInt32("amount"); const int itemId = msg.readInt16("item id"); msg.readUInt8("type"); - unsigned char identified = msg.readUInt8("identify"); + const unsigned char identified = msg.readUInt8("identify"); msg.readUInt8("attribute"); const uint8_t refine = msg.readUInt8("refine"); msg.readInt16("card0"); diff --git a/src/net/eathena/mailhandler.cpp b/src/net/eathena/mailhandler.cpp index 3cbefb623..4a28061a3 100644 --- a/src/net/eathena/mailhandler.cpp +++ b/src/net/eathena/mailhandler.cpp @@ -46,7 +46,7 @@ MailHandler::MailHandler() : void MailHandler::handleMessage(Net::MessageIn &msg) { - switch(msg.getId()) + switch (msg.getId()) { case SMSG_MAIL_OPEN_WINDOW: processMailOpen(msg); @@ -60,7 +60,7 @@ void MailHandler::handleMessage(Net::MessageIn &msg) void MailHandler::processMailOpen(Net::MessageIn &msg) const { const int flag = msg.readInt32("flag"); - switch(flag) + switch (flag) { case 0: // open window break; diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp index cef952252..90a441d0a 100644 --- a/src/net/eathena/npchandler.cpp +++ b/src/net/eathena/npchandler.cpp @@ -203,10 +203,10 @@ void NpcHandler::produceMix(const int nameId, const int materialId3) const { MessageOut outMsg(CMSG_NPC_PRODUCE_MIX); - outMsg.writeInt16(nameId, "name id"); - outMsg.writeInt16(materialId1, "material 1"); - outMsg.writeInt16(materialId2, "material 2"); - outMsg.writeInt16(materialId3, "material 3"); + outMsg.writeInt16(static_cast(nameId), "name id"); + outMsg.writeInt16(static_cast(materialId1), "material 1"); + outMsg.writeInt16(static_cast(materialId2), "material 2"); + outMsg.writeInt16(static_cast(materialId3), "material 3"); } void NpcHandler::cooking(const CookingType::Type type, @@ -214,7 +214,7 @@ void NpcHandler::cooking(const CookingType::Type type, { MessageOut outMsg(CMSG_NPC_COOKING); outMsg.writeInt16(static_cast(type), "type"); - outMsg.writeInt16(nameId, "name id"); + outMsg.writeInt16(static_cast(nameId), "name id"); } void NpcHandler::repair(const int index) const @@ -232,19 +232,19 @@ void NpcHandler::refine(const int index) const void NpcHandler::identify(const int index) const { MessageOut outMsg(CMSG_NPC_IDENTIFY); - outMsg.writeInt16(index, "index"); + outMsg.writeInt16(static_cast(index), "index"); } void NpcHandler::selectArrow(const int nameId) const { MessageOut outMsg(CMSG_NPC_SELECT_ARROW); - outMsg.writeInt16(nameId, "name id"); + outMsg.writeInt16(static_cast(nameId), "name id"); } void NpcHandler::selectAutoSpell(const int skillId) const { MessageOut outMsg(CMSG_NPC_SELECT_AUTO_SPELL); - outMsg.writeInt32(skillId, "skill id"); + outMsg.writeInt32(static_cast(skillId), "skill id"); } int NpcHandler::getNpc(Net::MessageIn &msg) diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index 5ef628744..ab5d17d47 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -150,7 +150,7 @@ void PartyHandler::inviteResponse(const std::string &inviter A_UNUSED, { MessageOut outMsg(CMSG_PARTY_INVITED2); outMsg.writeInt32(localPlayer->getId()); - outMsg.writeInt8(accept ? 1 : 0); + outMsg.writeInt8(static_cast(accept ? 1 : 0)); } } @@ -432,7 +432,8 @@ void PartyHandler::processPartyInviteResponse(Net::MessageIn &msg) const nick); break; case 5: - NotifyManager::notify(NotifyTypes::PARTY_INVITE_PARTY_BLOCKED_INVITE, + NotifyManager::notify( + NotifyTypes::PARTY_INVITE_PARTY_BLOCKED_INVITE, nick); break; case 7: diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp index 29aacdd47..c677cd3f8 100644 --- a/src/net/eathena/playerhandler.cpp +++ b/src/net/eathena/playerhandler.cpp @@ -241,10 +241,10 @@ void PlayerHandler::setShortcut(const int idx, const int level) const { MessageOut outMsg(CMSG_SET_SHORTCUTS); - outMsg.writeInt16(idx, "index"); - outMsg.writeInt8(type, "type"); + outMsg.writeInt16(static_cast(idx), "index"); + outMsg.writeInt8(static_cast(type), "type"); outMsg.writeInt32(id, "id"); - outMsg.writeInt16(level, "level"); + outMsg.writeInt16(static_cast(level), "level"); } void PlayerHandler::removeOption() const @@ -255,7 +255,7 @@ void PlayerHandler::removeOption() const void PlayerHandler::changeCart(const int type) const { MessageOut outMsg(CMSG_CHANGE_CART); - outMsg.writeInt16(type, "type"); + outMsg.writeInt16(static_cast(type), "type"); } void PlayerHandler::setMemo() const diff --git a/src/net/eathena/questhandler.cpp b/src/net/eathena/questhandler.cpp index 61a1704a4..ce892db88 100644 --- a/src/net/eathena/questhandler.cpp +++ b/src/net/eathena/questhandler.cpp @@ -179,4 +179,4 @@ void QuestHandler::processRemoveQuest(Net::MessageIn &msg) } } -} // namespace TmwAthena +} // namespace EAthena diff --git a/src/net/eathena/serverfeatures.cpp b/src/net/eathena/serverfeatures.cpp index e0f073cd2..a6c52491f 100644 --- a/src/net/eathena/serverfeatures.cpp +++ b/src/net/eathena/serverfeatures.cpp @@ -47,4 +47,4 @@ bool ServerFeatures::haveChangePartyLeader() const return true; } -} // EAthena +} // namespace EAthena diff --git a/src/net/eathena/serverfeatures.h b/src/net/eathena/serverfeatures.h index dbd4c756f..bca6f8f50 100644 --- a/src/net/eathena/serverfeatures.h +++ b/src/net/eathena/serverfeatures.h @@ -41,6 +41,6 @@ class ServerFeatures final : public Net::ServerFeatures bool haveChangePartyLeader() const override final; }; -} // namespace Net +} // namespace EAthena #endif // NET_EATHENA_SERVERFEATURES_H -- cgit v1.2.3-70-g09d2