summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/net/beinghandler.h4
-rw-r--r--src/net/ea/beinghandler.cpp125
-rw-r--r--src/net/ea/beinghandler.h32
-rw-r--r--src/net/eathena/beinghandler.cpp114
-rw-r--r--src/net/eathena/beinghandler.h15
-rw-r--r--src/net/tmwa/beinghandler.cpp65
-rw-r--r--src/net/tmwa/beinghandler.h12
7 files changed, 164 insertions, 203 deletions
diff --git a/src/net/beinghandler.h b/src/net/beinghandler.h
index 6e7e477cf..fcbf0bb5a 100644
--- a/src/net/beinghandler.h
+++ b/src/net/beinghandler.h
@@ -36,9 +36,9 @@ class BeingHandler
virtual void handleMessage(Net::MessageIn &msg) = 0;
- virtual void requestNameById(int id) = 0;
+ virtual void requestNameById(const int id) const = 0;
- virtual void undress(Being *being) = 0;
+ virtual void undress(Being *const being) const = 0;
};
} // namespace Net
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 45645af31..618c1b056 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -61,11 +61,12 @@ const int EMOTION_TIME = 500; /**< Duration of emotion icon */
BeingHandler::BeingHandler(bool enableSync) :
mSync(enableSync),
- mSpawnId(0)
+ mSpawnId(0),
+ mHideShield(config.getBoolValue("hideShield"))
{
}
-Being *BeingHandler::createBeing(int id, short job)
+Being *BeingHandler::createBeing(const int id, const short job) const
{
if (!actorSpriteManager)
return nullptr;
@@ -96,7 +97,7 @@ Being *BeingHandler::createBeing(int id, short job)
if (socialWindow)
socialWindow->updateActiveList();
}
- if (type == Being::NPC)
+ else if (type == Being::NPC)
{
if (questsWindow)
questsWindow->addEffect(being);
@@ -104,46 +105,39 @@ Being *BeingHandler::createBeing(int id, short job)
return being;
}
-void BeingHandler::setSprite(Being *being, unsigned int slot, int id,
- std::string color, unsigned char colorId,
- bool isWeapon, bool isTempSprite)
+void BeingHandler::setSprite(Being *const being, const unsigned int slot,
+ const int id, const std::string &color,
+ const unsigned char colorId,
+ const bool isWeapon,
+ const bool isTempSprite) const
{
if (!being)
return;
being->setSprite(slot, id, color, colorId, isWeapon, isTempSprite);
}
-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;
- uint8_t 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;
// Information about a being in range
- id = msg.readInt32();
+ const int id = msg.readInt32();
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())
@@ -201,19 +195,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)
{
if (serverVersion > 0)
@@ -242,12 +237,6 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
msg.readInt16(); // guild emblem
}
// logger->log("being guild: " + toString(guild));
-/*
- if (guild == 0)
- dstBeing->clearGuilds();
- else
- dstBeing->setGuild(Guild::getGuild(static_cast<short>(guild)));
-*/
msg.readInt16(); // manner
dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3
@@ -260,7 +249,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
{
msg.readInt8(); // karma
}
- gender = msg.readInt8();
+ uint8_t gender = msg.readInt8();
// reserving bits for future usage
@@ -278,7 +267,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
setSprite(dstBeing, EA_SPRITE_SHOE, shoes);
setSprite(dstBeing, EA_SPRITE_GLOVES, gloves);
setSprite(dstBeing, EA_SPRITE_WEAPON, weapon, "", 1, true);
- if (!config.getBoolValue("hideShield"))
+ if (!mHideShield)
setSprite(dstBeing, EA_SPRITE_SHIELD, shield);
}
else if (dstBeing->getType() == ActorSprite::NPC)
@@ -334,7 +323,6 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
msg.readInt8(); // unknown
msg.readInt8(); // unknown
-// msg.readInt8(); // unknown / sit
msg.readInt16();
dstBeing->setStunMode(stunMode);
@@ -344,7 +332,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
statusEffects & 0xffff));
}
-void BeingHandler::processBeingMove2(Net::MessageIn &msg)
+void BeingHandler::processBeingMove2(Net::MessageIn &msg) const
{
if (!actorSpriteManager)
return;
@@ -387,7 +375,7 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
msg.readInt16(); // disguise
}
-void BeingHandler::processBeingRemove(Net::MessageIn &msg)
+void BeingHandler::processBeingRemove(Net::MessageIn &msg) const
{
if (!actorSpriteManager || !player_node)
return;
@@ -429,7 +417,7 @@ void BeingHandler::processBeingRemove(Net::MessageIn &msg)
}
}
-void BeingHandler::processBeingResurrect(Net::MessageIn &msg)
+void BeingHandler::processBeingResurrect(Net::MessageIn &msg) const
{
if (!actorSpriteManager || !player_node)
return;
@@ -450,22 +438,18 @@ void BeingHandler::processBeingResurrect(Net::MessageIn &msg)
}
-void BeingHandler::processSkillDamage(Net::MessageIn &msg)
+void BeingHandler::processSkillDamage(Net::MessageIn &msg) const
{
if (!actorSpriteManager)
return;
- Being *srcBeing;
- Being *dstBeing;
- int param1;
-
const int id = msg.readInt16(); // Skill Id
- srcBeing = actorSpriteManager->findBeing(msg.readInt32());
- dstBeing = actorSpriteManager->findBeing(msg.readInt32());
+ Being *const srcBeing = actorSpriteManager->findBeing(msg.readInt32());
+ Being *const dstBeing = actorSpriteManager->findBeing(msg.readInt32());
msg.readInt32(); // Server tick
msg.readInt32(); // src speed
msg.readInt32(); // dst speed
- param1 = msg.readInt32(); // Damage
+ const int param1 = msg.readInt32(); // Damage
const int level = msg.readInt16(); // Skill level
msg.readInt16(); // Div
msg.readInt8(); // Skill hit/type (?)
@@ -484,7 +468,7 @@ void BeingHandler::processSkillDamage(Net::MessageIn &msg)
}
}
-void BeingHandler::processBeingAction(Net::MessageIn &msg)
+void BeingHandler::processBeingAction(Net::MessageIn &msg) const
{
if (!actorSpriteManager)
return;
@@ -572,7 +556,7 @@ void BeingHandler::processBeingSelfEffect(Net::MessageIn &msg)
if (!effectManager || !actorSpriteManager)
return;
- int id = static_cast<uint32_t>(msg.readInt32());
+ const int id = static_cast<uint32_t>(msg.readInt32());
Being *const being = actorSpriteManager->findBeing(id);
if (!being)
return;
@@ -582,8 +566,7 @@ void BeingHandler::processBeingSelfEffect(Net::MessageIn &msg)
effectManager->trigger(effectType, being);
//+++ need dehard code effectType == 3
- if (being && effectType == 3
- && being->getType() == Being::PLAYER
+ if (effectType == 3 && being->getType() == Being::PLAYER
&& socialWindow)
{ //reset received damage
socialWindow->resetDamage(being->getName());
@@ -595,9 +578,8 @@ void BeingHandler::processBeingEmotion(Net::MessageIn &msg)
if (!player_node || !actorSpriteManager)
return;
- Being *dstBeing;
-
- if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
+ Being *const dstBeing = actorSpriteManager->findBeing(msg.readInt32());
+ if (!dstBeing)
return;
if (player_relations.hasPermission(dstBeing, PlayerRelation::EMOTE))
@@ -618,10 +600,10 @@ void BeingHandler::processNameResponse(Net::MessageIn &msg)
if (!player_node || !actorSpriteManager)
return;
- Being *dstBeing;
-
const int beingId = msg.readInt32();
- if ((dstBeing = actorSpriteManager->findBeing(beingId)))
+ Being *const dstBeing = actorSpriteManager->findBeing(beingId);
+
+ if (dstBeing)
{
if (beingId == player_node->getId())
{
@@ -658,13 +640,9 @@ void BeingHandler::processIpResponse(Net::MessageIn &msg)
if (!actorSpriteManager)
return;
- Being *dstBeing;
-
- if ((dstBeing = actorSpriteManager->findBeing(
- msg.readInt32())))
- {
+ Being *const dstBeing = actorSpriteManager->findBeing(msg.readInt32());
+ if (dstBeing)
dstBeing->setIp(ipToString(msg.readInt32()));
- }
}
void BeingHandler::processPlayerGuilPartyInfo(Net::MessageIn &msg)
@@ -672,9 +650,9 @@ void BeingHandler::processPlayerGuilPartyInfo(Net::MessageIn &msg)
if (!actorSpriteManager)
return;
- Being *dstBeing;
+ Being *const dstBeing = actorSpriteManager->findBeing(msg.readInt32());
- if ((dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
+ if (dstBeing)
{
dstBeing->setPartyName(msg.readString(24));
if (!guildManager || !GuildManager::getEnableGuildBot())
@@ -690,9 +668,9 @@ void BeingHandler::processBeingChangeDirection(Net::MessageIn &msg)
if (!actorSpriteManager)
return;
- Being *dstBeing;
+ Being *const dstBeing = actorSpriteManager->findBeing(msg.readInt32());
- if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
+ if (!dstBeing)
return;
msg.readInt16(); // unused
@@ -727,9 +705,8 @@ void BeingHandler::processPlayerStop(Net::MessageIn &msg)
Being *const dstBeing = actorSpriteManager->findBeing(id);
if (dstBeing)
{
- uint16_t x, y;
- x = msg.readInt16();
- y = msg.readInt16();
+ const uint16_t x = msg.readInt16();
+ const uint16_t y = msg.readInt16();
dstBeing->setTileCoords(x, y);
if (dstBeing->getCurrentAction() == Being::MOVE)
dstBeing->setAction(Being::STAND);
diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h
index 46e9f2bbb..7af57af18 100644
--- a/src/net/ea/beinghandler.h
+++ b/src/net/ea/beinghandler.h
@@ -37,37 +37,36 @@ class BeingHandler : public Net::BeingHandler
A_DELETE_COPY(BeingHandler)
protected:
- virtual void requestNameById(int id) = 0;
+ virtual Being *createBeing(int id, short job) const A_WARN_UNUSED;
- virtual Being *createBeing(int id, short job) A_WARN_UNUSED;
-
- virtual void setSprite(Being *being, unsigned int slot, int id,
- std::string color = "",
- unsigned char colorId = 1,
- bool isWeapon = false,
- bool isTempSprite = false);
+ virtual void setSprite(Being *const being, const unsigned int slot,
+ const int id,
+ const std::string &color = "",
+ const unsigned char colorId = 1,
+ const bool isWeapon = false,
+ const bool isTempSprite = false) const;
virtual void processBeingVisibleOrMove(Net::MessageIn &msg,
- bool visible);
+ const bool visible);
- virtual void processBeingMove2(Net::MessageIn &msg);
+ virtual void processBeingMove2(Net::MessageIn &msg) const;
virtual void processBeingSpawn(Net::MessageIn &msg);
- virtual void processBeingRemove(Net::MessageIn &msg);
+ virtual void processBeingRemove(Net::MessageIn &msg) const;
- virtual void processBeingResurrect(Net::MessageIn &msg);
+ virtual void processBeingResurrect(Net::MessageIn &msg) const;
- virtual void processSkillDamage(Net::MessageIn &msg);
+ virtual void processSkillDamage(Net::MessageIn &msg) const;
- virtual void processBeingAction(Net::MessageIn &msg);
+ virtual void processBeingAction(Net::MessageIn &msg) const;
virtual void processBeingSelfEffect(Net::MessageIn &msg);
virtual void processBeingEmotion(Net::MessageIn &msg);
virtual void processBeingChangeLook(Net::MessageIn &msg,
- bool look2) = 0;
+ const bool look2) const = 0;
virtual void processNameResponse(Net::MessageIn &msg);
@@ -78,7 +77,7 @@ class BeingHandler : public Net::BeingHandler
virtual void processBeingChangeDirection(Net::MessageIn &msg);
virtual void processPlayerMoveUpdate(Net::MessageIn &msg,
- int type) = 0;
+ const int type) const = 0;
virtual void processPlayerStop(Net::MessageIn &msg);
@@ -100,6 +99,7 @@ class BeingHandler : public Net::BeingHandler
// Should we honor server "Stop Walking" packets
bool mSync;
int mSpawnId;
+ bool mHideShield;
};
} // namespace Ea
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)
diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h
index 5bdf593ca..ac266f3b7 100644
--- a/src/net/eathena/beinghandler.h
+++ b/src/net/eathena/beinghandler.h
@@ -42,20 +42,23 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler
virtual void handleMessage(Net::MessageIn &msg);
- virtual void requestNameById(int id);
+ virtual void requestNameById(const int id) const;
- virtual void undress(Being *being);
+ virtual void undress(Being *const being) const;
- void processBeingVisibleOrMove(Net::MessageIn &msg, bool visible);
+ void processBeingVisibleOrMove(Net::MessageIn &msg,
+ const bool visible);
void processBeingSpawn(Net::MessageIn &msg);
protected:
- virtual void processBeingChangeLook(Net::MessageIn &msg, bool look2);
+ virtual void processBeingChangeLook(Net::MessageIn &msg,
+ const bool look2) const;
- void processNameResponse2(Net::MessageIn &msg);
+ void processNameResponse2(Net::MessageIn &msg) const;
- virtual void processPlayerMoveUpdate(Net::MessageIn &msg, int type);
+ virtual void processPlayerMoveUpdate(Net::MessageIn &msg,
+ const int type) const;
};
} // namespace EAthena
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 13e2c9c21..a7300f601 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/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));
@@ -239,7 +239,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
BLOCK_END("BeingHandler::handleMessage")
}
-void BeingHandler::undress(Being *being)
+void BeingHandler::undress(Being *const being) const
{
being->setSprite(SPRITE_BOTTOMCLOTHES, 0);
being->setSprite(SPRITE_TOPCLOTHES, 0);
@@ -249,12 +249,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
@@ -267,13 +267,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)
{
@@ -287,7 +288,6 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, bool look2)
id2 = msg.readInt16();
else
id2 = 1;
- color.clear();
}
if (dstBeing->getType() == Being::PLAYER)
@@ -306,7 +306,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;
@@ -332,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));
@@ -386,17 +386,17 @@ 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())
{
@@ -428,21 +428,12 @@ 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;
- unsigned char colors[9];
-
-
// An update about a player, potentially including movement.
const int id = msg.readInt32();
const short speed = msg.readInt16();
@@ -452,7 +443,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
<< 16; // status.options; Aethyra uses this as misc2
const short job = msg.readInt16();
- dstBeing = actorSpriteManager->findBeing(id);
+ Being *dstBeing = actorSpriteManager->findBeing(id);
if (!dstBeing)
{
@@ -480,18 +471,20 @@ 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();
+ unsigned char colors[9];
colors[0] = msg.readInt8();
colors[1] = msg.readInt8();
colors[2] = msg.readInt8();
@@ -500,7 +493,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())
{
@@ -520,7 +513,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);
if (serverVersion > 0)
@@ -586,7 +579,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);
@@ -634,7 +627,7 @@ 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);
diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h
index 9ba801e1e..3d6716a0f 100644
--- a/src/net/tmwa/beinghandler.h
+++ b/src/net/tmwa/beinghandler.h
@@ -42,16 +42,18 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler
virtual void handleMessage(Net::MessageIn &msg);
- virtual void requestNameById(int id);
+ virtual void requestNameById(const int id) const;
- virtual void undress(Being *being);
+ virtual void undress(Being *const being) const;
protected:
- virtual void processBeingChangeLook(Net::MessageIn &msg, bool look2);
+ virtual void processBeingChangeLook(Net::MessageIn &msg,
+ const bool look2) const;
- void processNameResponse2(Net::MessageIn &msg);
+ void processNameResponse2(Net::MessageIn &msg) const;
- virtual void processPlayerMoveUpdate(Net::MessageIn &msg, int type);
+ virtual void processPlayerMoveUpdate(Net::MessageIn &msg,
+ const int type) const;
};
} // namespace TmwAthena