diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-26 00:36:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-26 01:50:50 +0300 |
commit | 43be2ecae97034f764460a5932ca97e6354da89e (patch) | |
tree | ba37fe86018e58ebb61df47b5c04850d8478b6b9 /src/net/eathena/beinghandler.cpp | |
parent | 90a652e5c672b9a11b165ee939889f406b852ee1 (diff) | |
download | manaplus-43be2ecae97034f764460a5932ca97e6354da89e.tar.gz manaplus-43be2ecae97034f764460a5932ca97e6354da89e.tar.bz2 manaplus-43be2ecae97034f764460a5932ca97e6354da89e.tar.xz manaplus-43be2ecae97034f764460a5932ca97e6354da89e.zip |
inprove beinghandler class.
Diffstat (limited to 'src/net/eathena/beinghandler.cpp')
-rw-r--r-- | src/net/eathena/beinghandler.cpp | 114 |
1 files changed, 50 insertions, 64 deletions
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 0932d3ad2..8f012b2f1 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -99,7 +99,7 @@ BeingHandler::BeingHandler(bool enableSync): beingHandler = this; } -void BeingHandler::requestNameById(int id) +void BeingHandler::requestNameById(const int id) const { MessageOut outMsg(0x0094); outMsg.writeInt32(id); //readLong(2)); @@ -237,7 +237,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) } } -void BeingHandler::undress(Being *being) +void BeingHandler::undress(Being *const being) const { being->setSprite(SPRITE_BOTTOMCLOTHES, 0); being->setSprite(SPRITE_TOPCLOTHES, 0); @@ -247,12 +247,12 @@ void BeingHandler::undress(Being *being) // being->setSprite(SPRITE_WEAPON, 0, "", true); } -void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, bool look2) +void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, + const bool look2) const { if (!actorSpriteManager) return; - Being *dstBeing; /* * SMSG_BEING_CHANGE_LOOKS (0x00c3) and * SMSG_BEING_CHANGE_LOOKS2 (0x01d7) do basically the same @@ -265,13 +265,14 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, bool look2) * 16 bit value will be 0. */ - if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32()))) + Being *const dstBeing = actorSpriteManager->findBeing(msg.readInt32()); + if (!dstBeing) return; const int type = msg.readInt8(); int id = 0; int id2 = 0; - std::string color; + const std::string color; if (!look2) { @@ -285,7 +286,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, bool look2) id2 = msg.readInt16(); else id2 = 1; - color.clear(); +// color.clear(); } if (dstBeing->getType() == Being::PLAYER) @@ -304,7 +305,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, bool look2) break; case 2: // Weapon ID in id, Shield ID in id2 dstBeing->setSprite(SPRITE_WEAPON, id, "", 1, true); - if (!config.getBoolValue("hideShield")) + if (!mHideShield) dstBeing->setSprite(SPRITE_SHIELD, id2); player_node->imitateOutfit(dstBeing, SPRITE_SHIELD); break; @@ -331,7 +332,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, bool look2) // ignoring it break; case 8: // eAthena LOOK_SHIELD - if (!config.getBoolValue("hideShield")) + if (!mHideShield) { dstBeing->setSprite(SPRITE_SHIELD, id, color, static_cast<unsigned char>(id2)); @@ -385,17 +386,16 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, bool look2) } } -void BeingHandler::processNameResponse2(Net::MessageIn &msg) +void BeingHandler::processNameResponse2(Net::MessageIn &msg) const { if (!actorSpriteManager || !player_node) return; - Being *dstBeing; - const int len = msg.readInt16(); const int beingId = msg.readInt32(); - std::string str = msg.readString(len - 8); - if ((dstBeing = actorSpriteManager->findBeing(beingId))) + const std::string str = msg.readString(len - 8); + Being *const dstBeing = actorSpriteManager->findBeing(beingId); + if (dstBeing) { if (beingId == player_node->getId()) { @@ -427,30 +427,22 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg) } } -void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) +void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, + const int msgType) const { if (!actorSpriteManager || !player_node) return; - uint16_t headTop, headMid, headBottom; - uint16_t weapon, shield; - uint16_t gmstatus; - int level; - int guild; - Being *dstBeing; - int hairStyle, hairColor; - // An update about a player, potentially including movement. const int id = msg.readInt32(); const short speed = msg.readInt16(); const uint16_t stunMode = msg.readInt16(); // opt1 uint32_t statusEffects = msg.readInt16(); // opt2 - statusEffects |= (static_cast<uint32_t>(msg.readInt16())) << 16; // status.options; Aethyra uses this as misc2 const short job = msg.readInt16(); - dstBeing = actorSpriteManager->findBeing(id); + Being *dstBeing = actorSpriteManager->findBeing(id); if (!dstBeing) { @@ -478,17 +470,18 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) dstBeing->setWalkSpeed(Vector(speed, speed, 0)); dstBeing->setSubtype(job); - hairStyle = msg.readInt16(); - weapon = msg.readInt16(); - shield = msg.readInt16(); - headBottom = msg.readInt16(); + + const int hairStyle = msg.readInt16(); + const uint16_t weapon = msg.readInt16(); + const uint16_t shield = msg.readInt16(); + const uint16_t headBottom = msg.readInt16(); if (msgType == 3) msg.readInt32(); // server tick - headTop = msg.readInt16(); - headMid = msg.readInt16(); - hairColor = msg.readInt16(); + const uint16_t headTop = msg.readInt16(); + const uint16_t headMid = msg.readInt16(); + const int hairColor = msg.readInt16(); msg.readInt8(); msg.readInt8(); @@ -497,7 +490,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) // shoes = msg.readInt16(); // gloves = msg.readInt16(); //sd->head_dir - guild = msg.readInt32(); // guild + const int guild = msg.readInt32(); // guild if (!guildManager || !GuildManager::getEnableGuildBot()) { @@ -516,7 +509,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) // Set these after the gender, as the sprites may be gender-specific dstBeing->setSprite(SPRITE_WEAPON, weapon, "", 1, true); - if (!config.getBoolValue("hideShield")) + if (!mHideShield) dstBeing->setSprite(SPRITE_SHIELD, shield); //dstBeing->setSprite(SPRITE_SHOE, shoes); dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, headBottom); @@ -571,7 +564,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) player_node->imitateDirection(dstBeing, dir); } - gmstatus = msg.readInt16(); + const uint16_t gmstatus = msg.readInt16(); if (gmstatus & 0x80) dstBeing->setGM(true); @@ -619,7 +612,8 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) msg.readInt8(); // unknown } - level = msg.readInt8(); // Lv + const int level = msg.readInt8(); // Lv + if (level) dstBeing->setLevel(level); @@ -641,39 +635,30 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) dstBeing->setMoveTime(); } -void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) +void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, + const bool visible) { if (!actorSpriteManager) return; - int id; - short job, speed, gender; - uint16_t headTop, headMid, headBottom; - uint16_t shoes, gloves; - uint16_t weapon, shield; - uint16_t stunMode; - uint32_t statusEffects; - Being *dstBeing; - int hairStyle, hairColor; - int spawnId; - if (visible) msg.readInt8(); // padding? // Information about a being in range - id = msg.readInt32(); + const int id = msg.readInt32(); + int spawnId; if (id == mSpawnId) spawnId = mSpawnId; else spawnId = 0; mSpawnId = 0; - speed = msg.readInt16(); - stunMode = msg.readInt16(); // opt1 - statusEffects = msg.readInt16(); // opt2 + short 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 - job = msg.readInt16(); // class + const short job = msg.readInt16(); // class - dstBeing = actorSpriteManager->findBeing(id); + Being *dstBeing = actorSpriteManager->findBeing(id); if (dstBeing && dstBeing->getType() == Being::MONSTER && !dstBeing->isAlive()) @@ -731,19 +716,20 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) if (dstBeing->getType() == ActorSprite::MONSTER && player_node) player_node->checkNewName(dstBeing); - hairStyle = msg.readInt16(); - weapon = msg.readInt16(); - headBottom = msg.readInt16(); + const int hairStyle = msg.readInt16(); + const uint16_t weapon = msg.readInt16(); + const uint16_t headBottom = msg.readInt16(); // if (!visible) // msg.readInt32(); // server tick - shield = msg.readInt16(); - headTop = msg.readInt16(); - headMid = msg.readInt16(); - hairColor = msg.readInt16(); - shoes = msg.readInt16(); // clothes color - "abused" as shoes + const uint16_t shield = msg.readInt16(); + const uint16_t headTop = msg.readInt16(); + const uint16_t headMid = msg.readInt16(); + const int hairColor = msg.readInt16(); + const uint16_t shoes = msg.readInt16(); // clothes color - "abused" as shoes + uint16_t gloves; if (dstBeing->getType() == ActorSprite::MONSTER) { msg.readInt32(); @@ -767,7 +753,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) msg.readInt16(); // manner dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3 msg.readInt8(); // karma - gender = msg.readInt8(); + short gender = msg.readInt8(); // reserving bits for future usage @@ -784,7 +770,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) setSprite(dstBeing, SPRITE_SHOE, shoes); setSprite(dstBeing, SPRITE_GLOVES, gloves); setSprite(dstBeing, SPRITE_WEAPON, weapon, "", 1, true); - if (!config.getBoolValue("hideShield")) + if (!mHideShield) setSprite(dstBeing, SPRITE_SHIELD, shield); } else if (dstBeing->getType() == ActorSprite::NPC) |