diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-07-17 23:26:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-07-17 23:26:59 +0300 |
commit | 7e0a97d2521b9ce57003176e82a0b5564aa003c2 (patch) | |
tree | 5b2cfe1afe09bea1063f783050c1fb549daee76d /src/net | |
parent | f68cbf700a99f2f184715a5b8025bcb4b6525391 (diff) | |
download | manaplus-7e0a97d2521b9ce57003176e82a0b5564aa003c2.tar.gz manaplus-7e0a97d2521b9ce57003176e82a0b5564aa003c2.tar.bz2 manaplus-7e0a97d2521b9ce57003176e82a0b5564aa003c2.tar.xz manaplus-7e0a97d2521b9ce57003176e82a0b5564aa003c2.zip |
Fix more code style and additional warnings.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/beinghandler.cpp | 10 | ||||
-rw-r--r-- | src/net/ea/guildhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/loginhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 119 | ||||
-rw-r--r-- | src/net/ea/playerhandler.h | 4 | ||||
-rw-r--r-- | src/net/ea/specialhandler.cpp | 6 | ||||
-rw-r--r-- | src/net/messagein.cpp | 4 | ||||
-rw-r--r-- | src/net/playerhandler.h | 5 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 6 | ||||
-rw-r--r-- | src/net/tmwa/messagein.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/messageout.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwa/npchandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/tmwa/tradehandler.cpp | 2 |
14 files changed, 108 insertions, 68 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index c5d722db5..0e4fefa21 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -116,7 +116,8 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) return; int id; - short job, speed, gender; + short job, speed; + uint8_t gender; uint16_t headTop, headMid, headBottom; uint16_t shoes, gloves; uint16_t weapon, shield; @@ -335,8 +336,8 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) dstBeing->setStunMode(stunMode); dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>( (statusEffects >> 16) & 0xffff)); - dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); - + dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>( + statusEffects & 0xffff)); } void BeingHandler::processBeingMove2(Net::MessageIn &msg) @@ -761,7 +762,8 @@ void BeingHandler::processPlaterStatusChange(Net::MessageIn &msg) dstBeing->setStunMode(stunMode); dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>( (statusEffects >> 16) & 0xffff)); - dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); + dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>( + statusEffects & 0xffff)); } void BeingHandler::processBeingStatusChange(Net::MessageIn &msg) diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index 75fc5af56..7c2361531 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -251,7 +251,7 @@ void GuildHandler::processGuildMemberList(Net::MessageIn &msg) m->setOnline(online); m->setID(id); m->setCharId(charId); - m->setGender(Being::intToGender(gender)); + m->setGender(Being::intToGender(static_cast<uint8_t>(gender))); m->setLevel(level); m->setExp(exp); m->setPos(pos); diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index d35e5a0d5..2a7afb189 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -195,7 +195,7 @@ void LoginHandler::processLoginData(Net::MessageIn &msg) // msg.skip(30); // unknown // reserve bits for future usage - mToken.sex = Being::intToGender(msg.readInt8() & 3); + mToken.sex = Being::intToGender(static_cast<uint8_t>(msg.readInt8() & 3)); for (int i = 0; i < worldCount; i++) { diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 4c6e894c9..130b31046 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -362,48 +362,60 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) break; case 0x0029: - PlayerInfo::setStatBase(EA_ATK, value); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( + EA_ATK), value); PlayerInfo::updateAttrs(); break; case 0x002a: - PlayerInfo::setStatMod(EA_ATK, value); + PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>( + EA_ATK), value); PlayerInfo::updateAttrs(); break; case 0x002b: - PlayerInfo::setStatBase(EA_MATK, value); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( + EA_MATK), value); break; case 0x002c: - PlayerInfo::setStatMod(EA_MATK, value); + PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>( + EA_MATK), value); break; case 0x002d: - PlayerInfo::setStatBase(EA_DEF, value); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( + EA_DEF), value); break; case 0x002e: - PlayerInfo::setStatMod(EA_DEF, value); + PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>( + EA_DEF), value); break; case 0x002f: - PlayerInfo::setStatBase(EA_MDEF, value); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( + EA_MDEF), value); break; case 0x0030: - PlayerInfo::setStatMod(EA_MDEF, value); + PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>( + EA_MDEF), value); break; case 0x0031: - PlayerInfo::setStatBase(EA_HIT, value); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( + EA_HIT), value); break; case 0x0032: - PlayerInfo::setStatBase(EA_FLEE, value); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( + EA_FLEE), value); break; case 0x0033: - PlayerInfo::setStatMod(EA_FLEE, value); + PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>( + EA_FLEE), value); break; case 0x0034: - PlayerInfo::setStatBase(EA_CRIT, value); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( + EA_CRIT), value); break; case 0x0035: @@ -414,7 +426,8 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) break; case 0x0037: - PlayerInfo::setStatBase(EA_JOB, value); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( + EA_JOB), value); break; case 500: @@ -445,8 +458,10 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg) PlayerInfo::setAttribute(PlayerInfo::EXP, msg.readInt32()); break; case 0x0002: - PlayerInfo::setStatExperience(EA_JOB, msg.readInt32(), - PlayerInfo::getStatExperience(EA_JOB).second); + PlayerInfo::setStatExperience(static_cast<PlayerInfo::Attribute>( + EA_JOB), msg.readInt32(), + PlayerInfo::getStatExperience(static_cast<PlayerInfo::Attribute>( + EA_JOB)).second); break; case 0x0014: { @@ -470,8 +485,9 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg) PlayerInfo::setAttribute(PlayerInfo::EXP_NEEDED, msg.readInt32()); break; case 0x0017: - PlayerInfo::setStatExperience(EA_JOB, - PlayerInfo::getStatExperience(EA_JOB).first, + PlayerInfo::setStatExperience(static_cast<PlayerInfo::Attribute>( + EA_JOB), PlayerInfo::getStatExperience( + static_cast<PlayerInfo::Attribute>(EA_JOB)).first, msg.readInt32()); break; default: @@ -486,8 +502,10 @@ void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg) int base = msg.readInt32(); int bonus = msg.readInt32(); - PlayerInfo::setStatBase(type, base, false); - PlayerInfo::setStatMod(type, bonus); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( + type), base, false); + PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>( + type), bonus); if (type == EA_ATK || type == PlayerInfo::ATTACK_DELAY) PlayerInfo::updateAttrs(); } @@ -500,14 +518,15 @@ void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg) if (ok != 1) { - int oldValue = PlayerInfo::getStatBase(type); + int oldValue = PlayerInfo::getStatBase( + static_cast<PlayerInfo::Attribute>(type)); int points = PlayerInfo::getAttribute(PlayerInfo::CHAR_POINTS); points += oldValue - value; PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, points); SERVER_NOTICE(_("Cannot raise skill!")) } - PlayerInfo::setStatBase(type, value); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(type), value); } void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg) @@ -515,69 +534,80 @@ void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg) PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, msg.readInt16()); int val = msg.readInt8(); - PlayerInfo::setStatBase(EA_STR, val); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_STR), val); if (statusWindow) statusWindow->setPointsNeeded(EA_STR, msg.readInt8()); else msg.readInt8(); val = msg.readInt8(); - PlayerInfo::setStatBase(EA_AGI, val); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_AGI), val); if (statusWindow) statusWindow->setPointsNeeded(EA_AGI, msg.readInt8()); else msg.readInt8(); val = msg.readInt8(); - PlayerInfo::setStatBase(EA_VIT, val); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_VIT), val); if (statusWindow) statusWindow->setPointsNeeded(EA_VIT, msg.readInt8()); else msg.readInt8(); val = msg.readInt8(); - PlayerInfo::setStatBase(EA_INT, val); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_INT), val); if (statusWindow) statusWindow->setPointsNeeded(EA_INT, msg.readInt8()); else msg.readInt8(); val = msg.readInt8(); - PlayerInfo::setStatBase(EA_DEX, val); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_DEX), val); if (statusWindow) statusWindow->setPointsNeeded(EA_DEX, msg.readInt8()); else msg.readInt8(); val = msg.readInt8(); - PlayerInfo::setStatBase(EA_LUK, val); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_LUK), val); if (statusWindow) statusWindow->setPointsNeeded(EA_LUK, msg.readInt8()); else msg.readInt8(); - PlayerInfo::setStatBase(EA_ATK, msg.readInt16(), false); - PlayerInfo::setStatMod(EA_ATK, msg.readInt16()); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_ATK), + msg.readInt16(), false); + PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_ATK), + msg.readInt16()); PlayerInfo::updateAttrs(); val = msg.readInt16(); - PlayerInfo::setStatBase(EA_MATK, val, false); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_MATK), + val, false); val = msg.readInt16(); - PlayerInfo::setStatMod(EA_MATK, val); + PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_MATK), val); - PlayerInfo::setStatBase(EA_DEF, msg.readInt16(), false); - PlayerInfo::setStatMod(EA_DEF, msg.readInt16()); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_DEF), + msg.readInt16(), false); + PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_DEF), + msg.readInt16()); - PlayerInfo::setStatBase(EA_MDEF, msg.readInt16(), false); - PlayerInfo::setStatMod(EA_MDEF, msg.readInt16()); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_MDEF), + msg.readInt16(), false); + PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_MDEF), + msg.readInt16()); - PlayerInfo::setStatBase(EA_HIT, msg.readInt16()); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_HIT), + msg.readInt16()); - PlayerInfo::setStatBase(EA_FLEE, msg.readInt16(), false); - PlayerInfo::setStatMod(EA_FLEE, msg.readInt16()); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_FLEE), + msg.readInt16(), false); + PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_FLEE), + msg.readInt16()); - PlayerInfo::setStatBase(EA_CRIT, msg.readInt16()); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_CRIT), + msg.readInt16()); msg.readInt16(); // manner } @@ -635,17 +665,18 @@ void PlayerHandler::processPlayerArrowMessage(Net::MessageIn &msg) bool PlayerHandler::canUseMagic() const { - return PlayerInfo::getStatEffective(EA_MATK) > 0; + return PlayerInfo::getStatEffective(static_cast<PlayerInfo::Attribute>( + EA_MATK)) > 0; } -int PlayerHandler::getJobLocation() const +PlayerInfo::Attribute PlayerHandler::getJobLocation() const { - return EA_JOB; + return static_cast<PlayerInfo::Attribute>(EA_JOB); } -int PlayerHandler::getAttackLocation() const +PlayerInfo::Attribute PlayerHandler::getAttackLocation() const { - return EA_ATK; + return static_cast<PlayerInfo::Attribute>(EA_ATK); } } // namespace Ea diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h index d0402ecfc..3e9d14804 100644 --- a/src/net/ea/playerhandler.h +++ b/src/net/ea/playerhandler.h @@ -47,9 +47,9 @@ class PlayerHandler : public Net::PlayerHandler Vector getDefaultWalkSpeed() const; - int getJobLocation() const; + PlayerInfo::Attribute getJobLocation() const; - int getAttackLocation() const; + PlayerInfo::Attribute getAttackLocation() const; void processWalkResponse(Net::MessageIn &msg); diff --git a/src/net/ea/specialhandler.cpp b/src/net/ea/specialhandler.cpp index dd0284ae8..7a760c5b4 100644 --- a/src/net/ea/specialhandler.cpp +++ b/src/net/ea/specialhandler.cpp @@ -94,7 +94,8 @@ void SpecialHandler::processPlayerSkills(Net::MessageIn &msg) msg.skip(24); // 0 unused int up = msg.readInt8(); - PlayerInfo::setStatBase(skillId, level); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( + skillId), level); if (skillDialog) { if (!skillDialog->updateSkill(skillId, range, up)) @@ -111,7 +112,8 @@ void SpecialHandler::processPlayerSkillUp(Net::MessageIn &msg) int range = msg.readInt16(); int up = msg.readInt8(); - PlayerInfo::setStatBase(skillId, level); + PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( + skillId), level); if (skillDialog) { if (!skillDialog->updateSkill(skillId, range, up)) diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 0af0e389f..377cca6d3 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -50,7 +50,7 @@ MessageIn::MessageIn(const char *data, unsigned int length): unsigned char MessageIn::readInt8() { - unsigned char value = -1; + unsigned char value = static_cast<unsigned char>(-1); if (mPos < mLength) value = static_cast<unsigned char>(mData[mPos]); @@ -121,7 +121,7 @@ void MessageIn::readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction) temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f); y = static_cast<unsigned short>(temp >> 4); - serverDir = data[2] & 0x000f; + serverDir = static_cast<uint8_t>(data[2] & 0x000f); direction = fromServerDirection(serverDir); } mPos += 3; diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h index 187059c02..c6a67afb2 100644 --- a/src/net/playerhandler.h +++ b/src/net/playerhandler.h @@ -25,6 +25,7 @@ #include "being.h" #include "flooritem.h" +#include "playerinfo.h" namespace Net { @@ -65,9 +66,9 @@ class PlayerHandler virtual bool canCorrectAttributes() const = 0; - virtual int getJobLocation() const = 0; + virtual PlayerInfo::Attribute getJobLocation() const = 0; - virtual int getAttackLocation() const = 0; + virtual PlayerInfo::Attribute getAttackLocation() const = 0; virtual Vector getDefaultWalkSpeed() const = 0; diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 855972b95..dc815bf1c 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -518,7 +518,8 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) 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))); // Set these after the gender, as the sprites may be gender-specific dstBeing->setSprite(SPRITE_WEAPON, weapon, "", 1, true); @@ -647,7 +648,8 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) dstBeing->setStunMode(stunMode); dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>( (statusEffects >> 16) & 0xffff)); - dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); + dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>( + statusEffects & 0xffff)); if (msgType == 3 && dstBeing->getType() == Being::PLAYER) dstBeing->setMoveTime(); diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp index 698d7211c..2b65a2a3a 100644 --- a/src/net/tmwa/messagein.cpp +++ b/src/net/tmwa/messagein.cpp @@ -77,7 +77,7 @@ int MessageIn::readInt32() } mPos += 4; PacketCounters::incInBytes(4); - DEBUGLOG(strprintf("readInt32: %u", value)); + DEBUGLOG(strprintf("readInt32: %u", static_cast<unsigned>(value))); return value; } diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp index 9e9e264eb..57cbceca3 100644 --- a/src/net/tmwa/messageout.cpp +++ b/src/net/tmwa/messageout.cpp @@ -91,7 +91,9 @@ static_cast<unsigned short>(w)) >> 8)) void MessageOut::writeCoordinates(unsigned short x, unsigned short 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 *data = mData + mPos; mNetwork->mOutSize += 3; mPos += 3; diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index be58f0bc5..c086cc7e4 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -302,7 +302,7 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg, int npcId) { mDialog->setAvatarDirection( Net::MessageIn::fromServerDirection( - msg.readInt32())); // direction + static_cast<uint8_t>(msg.readInt32()))); // direction } break; case 8: // set avatar action diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index d1429a815..74826e5cd 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -193,8 +193,8 @@ void PartyHandler::setShareExperience(PartyShare share) 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(PartyShare share) @@ -203,8 +203,8 @@ void PartyHandler::setShareItems(PartyShare share) 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 TmwAthena diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index d4c1e1e08..f572e6cff 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -109,7 +109,7 @@ void TradeHandler::respond(bool accept) 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(Item *item, int amount) |