summaryrefslogtreecommitdiff
path: root/src/net/ea/beinghandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/ea/beinghandler.cpp')
-rw-r--r--src/net/ea/beinghandler.cpp82
1 files changed, 39 insertions, 43 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 4a5cfb841..8fca76353 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -58,7 +58,7 @@ namespace Ea
{
const int EMOTION_TIME = 500; /**< Duration of emotion icon */
-BeingHandler::BeingHandler(bool enableSync):
+BeingHandler::BeingHandler(bool enableSync) :
mSync(enableSync),
mSpawnId(0)
{
@@ -133,8 +133,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
speed = msg.readInt16();
stunMode = msg.readInt16(); // opt1
statusEffects = msg.readInt16(); // opt2
- statusEffects |= (static_cast<Uint32>(
- msg.readInt16())) << 16; // option
+ statusEffects |= (static_cast<Uint32>(msg.readInt16())) << 16; // option
job = msg.readInt16(); // class
dstBeing = actorSpriteManager->findBeing(id);
@@ -210,14 +209,22 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
if (dstBeing->getType() == ActorSprite::MONSTER)
{
- int hp = msg.readInt32();
- int maxHP = msg.readInt32();
- if (hp && maxHP)
+ if (serverVersion > 0)
{
- int oldHP = dstBeing->getHP();
- if (!oldHP || oldHP > hp)
- dstBeing->setHP(hp);
- dstBeing->setMaxHP(maxHP);
+ int hp = msg.readInt32();
+ int maxHP = msg.readInt32();
+ if (hp && maxHP)
+ {
+ int oldHP = dstBeing->getHP();
+ if (!oldHP || oldHP > hp)
+ dstBeing->setHP(hp);
+ dstBeing->setMaxHP(maxHP);
+ }
+ }
+ else
+ {
+ msg.readInt32();
+ msg.readInt32();
}
gloves = 0;
}
@@ -237,19 +244,26 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
msg.readInt16(); // manner
dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3
- msg.readInt8(); // karma
+ if (serverVersion > 0 && dstBeing->getType() == ActorSprite::MONSTER)
+ {
+ int attackRange = msg.readInt8(); // karma
+ dstBeing->setAttackRange(attackRange);
+ }
+ else
+ {
+ msg.readInt8(); // karma
+ }
gender = msg.readInt8();
// reserving bits for future usage
- gender &= 1;
if (dstBeing->getType() == ActorSprite::PLAYER)
{
- dstBeing->setGender((gender == 0)
- ? GENDER_FEMALE : GENDER_MALE);
+ gender &= 1;
+ dstBeing->setGender((gender == 0) ? GENDER_FEMALE : GENDER_MALE);
// Set these after the gender, as the sprites may be gender-specific
setSprite(dstBeing, EA_SPRITE_HAIR, hairStyle * -1,
- ColorDB::getHairColor(hairColor));
+ ColorDB::getHairColor(hairColor));
setSprite(dstBeing, EA_SPRITE_BOTTOMCLOTHES, headBottom);
setSprite(dstBeing, EA_SPRITE_TOPCLOTHES, headMid);
setSprite(dstBeing, EA_SPRITE_HAT, headTop);
@@ -283,8 +297,6 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
dstBeing->setAction(Being::STAND);
dstBeing->setTileCoords(srcX, srcY);
dstBeing->setDestination(dstX, dstY);
-// if (player_node && player_node->getTarget() == dstBeing)
-// player_node->targetMoved();
}
else
{
@@ -293,7 +305,6 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
msg.readCoordinates(x, y, dir);
dstBeing->setTileCoords(x, y);
-
if (job == 45 && socialWindow && outfitWindow)
{
int num = socialWindow->getPortalIndex(x, y);
@@ -379,7 +390,7 @@ void BeingHandler::processBeingRemove(Net::MessageIn &msg)
return;
player_node->followMoveTo(dstBeing, player_node->getNextDestX(),
- player_node->getNextDestY());
+ player_node->getNextDestY());
// If this is player's current target, clear it.
if (dstBeing == player_node->getTarget())
@@ -464,20 +475,15 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg)
if (!actorSpriteManager)
return;
- Being *srcBeing;
- Being *dstBeing;
- int param1;
- int type;
-
- srcBeing = actorSpriteManager->findBeing(msg.readInt32());
- dstBeing = actorSpriteManager->findBeing(msg.readInt32());
+ Being *srcBeing = actorSpriteManager->findBeing(msg.readInt32());
+ Being *dstBeing = actorSpriteManager->findBeing(msg.readInt32());
msg.readInt32(); // server tick
int srcSpeed = msg.readInt32(); // src speed
msg.readInt32(); // dst speed
- param1 = msg.readInt16();
+ int param1 = msg.readInt16();
msg.readInt16(); // param 2
- type = msg.readInt8();
+ int type = msg.readInt8();
msg.readInt16(); // param 3
switch (type)
@@ -513,10 +519,7 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg)
{
srcBeing->setMoveTime();
if (player_node)
- {
- player_node->imitateAction(
- srcBeing, Being::SIT);
- }
+ player_node->imitateAction(srcBeing, Being::SIT);
}
}
break;
@@ -529,23 +532,18 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg)
{
srcBeing->setMoveTime();
if (player_node)
- {
- player_node->imitateAction(
- srcBeing, Being::STAND);
- }
+ player_node->imitateAction(srcBeing, Being::STAND);
}
}
break;
default:
- break;
-/*
logger->log("QQQ1 SMSG_BEING_ACTION:");
if (srcBeing)
logger->log("srcBeing:" + toString(srcBeing->getId()));
if (dstBeing)
logger->log("dstBeing:" + toString(dstBeing->getId()));
logger->log("type: " + toString(type));
-*/
+ break;
}
}
@@ -584,8 +582,7 @@ void BeingHandler::processBeingEmotion(Net::MessageIn &msg)
if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
return;
- if (player_relations.hasPermission(dstBeing,
- PlayerRelation::EMOTE))
+ if (player_relations.hasPermission(dstBeing, PlayerRelation::EMOTE))
{
unsigned char emote = msg.readInt8();
if (emote)
@@ -626,8 +623,7 @@ void BeingHandler::processNameResponse(Net::MessageIn &msg)
Party *party = player_node->getParty();
if (party && party->isMember(dstBeing->getId()))
{
- PartyMember *member = party->getMember(
- dstBeing->getId());
+ PartyMember *member = party->getMember(dstBeing->getId());
if (member)
member->setName(dstBeing->getName());