diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-04-30 19:53:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-04-30 19:53:09 +0300 |
commit | 237449794444d60ecc4a669d78becac5372da723 (patch) | |
tree | 694f439d43e303065220df02ec5a1df9ea5b57fe /src/net | |
parent | 2c13c60e916768fe09bcfff1d0b568a4c5397a99 (diff) | |
download | manaplus-237449794444d60ecc4a669d78becac5372da723.tar.gz manaplus-237449794444d60ecc4a669d78becac5372da723.tar.bz2 manaplus-237449794444d60ecc4a669d78becac5372da723.tar.xz manaplus-237449794444d60ecc4a669d78becac5372da723.zip |
Fix code style in net.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/beinghandler.cpp | 17 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.cpp | 19 | ||||
-rw-r--r-- | src/net/eathena/messageout.cpp | 5 | ||||
-rw-r--r-- | src/net/eathena/partyhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/eathena/tradehandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 10 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwa/messageout.cpp | 2 |
8 files changed, 31 insertions, 36 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index a5cc7cb75..bc98b9be6 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -194,7 +194,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, speed = 150; const int hairStyle = msg.readInt8(); - const int look = msg.readInt8(); + const uint8_t look = msg.readInt8(); dstBeing->setSubtype(job, look); if (dstBeing->getType() == ActorSprite::MONSTER && player_node) player_node->checkNewName(dstBeing); @@ -678,7 +678,8 @@ void BeingHandler::processBeingChangeDirection(Net::MessageIn &msg) const msg.readInt16(); // unused - const unsigned char dir = msg.readInt8() & 0x0f; + const unsigned char dir = static_cast<unsigned char>( + msg.readInt8() & 0x0f); dstBeing->setDirection(dir); if (player_node) player_node->imitateDirection(dstBeing, dir); @@ -689,18 +690,6 @@ void BeingHandler::processPlayerStop(Net::MessageIn &msg) const if (!actorManager || !player_node) return; - /* - * Instruction from server to stop walking at x, y. - * - * Some people like having this enabled. Others absolutely - * despise it. So I'm setting to so that it only affects the - * local player if the person has set a key "EnableSync" to "1" - * in their config.xml file. - * - * This packet will be honored for all other beings, regardless - * of the config setting. - */ - const int id = msg.readInt32(); if (mSync || id != player_node->getId()) diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index df25f40cf..efa22e490 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -432,7 +432,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, const int16_t speed = msg.readInt16(); const uint16_t stunMode = msg.readInt16(); // opt1 uint32_t statusEffects = msg.readInt16(); // opt2 - statusEffects |= (static_cast<uint32_t>(msg.readInt16())) + statusEffects |= (static_cast<uint16_t>(msg.readInt16())) << 16; // status.options; Aethyra uses this as misc2 const int16_t job = msg.readInt16(); int disguiseId = 0; @@ -506,7 +506,8 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3 msg.readInt8(); // karma // reserving bit for future usage - dstBeing->setGender(Being::intToGender(msg.readInt8() & 3)); + dstBeing->setGender(Being::intToGender( + static_cast<uint8_t>(msg.readInt8() & 3))); if (!disguiseId) { @@ -618,8 +619,9 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setStunMode(stunMode); dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>( - (statusEffects >> 16) & 0xffff)); - dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); + (statusEffects >> 16) & 0xffffU)); + dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>( + statusEffects & 0xffffU)); if (msgType == 3 && dstBeing->getType() == Being::PLAYER) dstBeing->setMoveTime(); @@ -645,7 +647,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, int16_t speed = msg.readInt16(); const uint16_t stunMode = msg.readInt16(); // opt1 uint32_t statusEffects = msg.readInt16(); // opt2 - statusEffects |= (static_cast<uint32_t>(msg.readInt16())) << 16; // option + statusEffects |= (static_cast<uint16_t>(msg.readInt16())) << 16; // option const int16_t job = msg.readInt16(); // class Being *dstBeing = actorManager->findBeing(id); @@ -733,7 +735,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, msg.readInt16(); // manner dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3 msg.readInt8(); // karma - int16_t gender = msg.readInt8(); + uint8_t gender = msg.readInt8(); if (dstBeing->getType() == ActorSprite::PLAYER) { @@ -808,8 +810,9 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, dstBeing->setStunMode(stunMode); dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>( - (statusEffects >> 16) & 0xffff)); - dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); + (statusEffects >> 16) & 0xffffU)); + dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>( + statusEffects & 0xffffU)); } } // namespace EAthena diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp index ff16f5dd0..07fd8093b 100644 --- a/src/net/eathena/messageout.cpp +++ b/src/net/eathena/messageout.cpp @@ -91,7 +91,10 @@ void MessageOut::writeCoordinates(const uint16_t x, const uint16_t y, unsigned char direction) { - DEBUGLOG(strprintf("writeCoordinates: %u,%u %u", x, y, direction)); + DEBUGLOG(strprintf("writeCoordinates: %u,%u %u", + static_cast<unsigned>(x), + static_cast<unsigned>(y), + static_cast<unsigned>(direction))); char *const data = mData + mPos; mNetwork->mOutSize += 3; mPos += 3; diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index cfec2fe81..dc65fb3ad 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -189,8 +189,8 @@ void PartyHandler::setShareExperience(const PartyShare share) const return; MessageOut outMsg(CMSG_PARTY_SETTINGS); - outMsg.writeInt16(share); - outMsg.writeInt16(mShareItems); + outMsg.writeInt16(static_cast<int16_t>(share)); + outMsg.writeInt16(static_cast<int16_t>(mShareItems)); } void PartyHandler::setShareItems(const PartyShare share) const @@ -199,8 +199,8 @@ void PartyHandler::setShareItems(const PartyShare share) const return; MessageOut outMsg(CMSG_PARTY_SETTINGS); - outMsg.writeInt16(mShareExp); - outMsg.writeInt16(share); + outMsg.writeInt16(static_cast<int16_t>(mShareExp)); + outMsg.writeInt16(static_cast<int16_t>(share)); } } // namespace EAthena diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp index b04446775..1e71d4a43 100644 --- a/src/net/eathena/tradehandler.cpp +++ b/src/net/eathena/tradehandler.cpp @@ -110,7 +110,7 @@ void TradeHandler::respond(const bool accept) const PlayerInfo::setTrading(false); MessageOut outMsg(CMSG_TRADE_RESPONSE); - outMsg.writeInt8(accept ? 3 : 4); + outMsg.writeInt8(static_cast<int8_t>(accept ? 3 : 4)); } void TradeHandler::addItem(const Item *const item, const int amount) const diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 76efd958e..cd3a2cc15 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -301,7 +301,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, break; case 1: // eAthena LOOK_HAIR { - const int look = id / 256; + const uint8_t look = static_cast<uint8_t>(id / 256U); const int hair = id % 256; dstBeing->setHairStyle(SPRITE_HAIR, hair * -1); dstBeing->setLook(look); @@ -378,7 +378,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, player_node->imitateOutfit(dstBeing, SPRITE_EVOL2); break; case 16: - dstBeing->setLook(id); + dstBeing->setLook(static_cast<uint8_t>(id)); break; default: logger->log("QQQ3 CHANGE_LOOKS: unsupported type: " @@ -482,7 +482,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setWalkSpeed(Vector(speed, speed, 0)); const int hairStyle = msg.readInt8(); - const int look = msg.readInt8(); + const uint8_t look = msg.readInt8(); dstBeing->setSubtype(job, look); const uint16_t weapon = msg.readInt16(); const uint16_t shield = msg.readInt16(); @@ -657,8 +657,8 @@ void BeingHandler::processBeingMove3(Net::MessageIn &msg) if (serverVersion < 10) return; - static const int dirx[8] = {0, -1, -1, -1, 0, 1, 1, 1}; - static const int diry[8] = {1, 1, 0, -1, -1, -1, 0, 1}; + static const int16_t dirx[8] = {0, -1, -1, -1, 0, 1, 1, 1}; + static const int16_t diry[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const int len = msg.readInt16() - 14; Being *const dstBeing = actorManager->findBeing(msg.readInt32()); diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index a245372c5..c4fc9001c 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -157,9 +157,9 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, data.mAttributes[PlayerInfo::MAX_MP] = msg.readInt16(); msg.readInt16(); // speed - const int race = msg.readInt16(); // class (used for race) + const uint16_t race = msg.readInt16(); // class (used for race) const int hairStyle = msg.readInt8(); - const int look = msg.readInt8(); + const uint8_t look = msg.readInt8(); tempPlayer->setSubtype(race, look); const uint16_t weapon = msg.readInt16(); // unused on server. need use? tempPlayer->setSprite(SPRITE_WEAPON, weapon, "", 1, true); diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp index 8c3ecb5ec..9962e7975 100644 --- a/src/net/tmwa/messageout.cpp +++ b/src/net/tmwa/messageout.cpp @@ -85,7 +85,7 @@ void MessageOut::writeInt32(const int32_t value) #define LOBYTE(w) (static_cast<unsigned char>(w)) #define HIBYTE(w) (static_cast<unsigned char>(( \ -static_cast<uint16_t>(w)) >> 8)) +static_cast<uint16_t>(w)) >> 8U)) void MessageOut::writeCoordinates(const uint16_t x, const uint16_t y, |