summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actormanager.cpp58
-rw-r--r--src/gui/viewport.cpp81
-rw-r--r--src/net/eathena/beingrecv.cpp230
3 files changed, 228 insertions, 141 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index befd952e6..b557f3e36 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -276,31 +276,41 @@ Being *ActorManager::createBeing(const BeingId id,
mActorsIdMap[being->getId()] = being;
- if (type == ActorType::Player
- || type == ActorType::Mercenary
- || type == ActorType::Pet
- || type == ActorType::Homunculus
- || type == ActorType::Npc)
+ switch (type)
{
- being->updateFromCache();
- if (beingHandler)
- beingHandler->requestNameById(id);
- if (localPlayer)
- localPlayer->checkNewName(being);
- }
- else if (type == ActorType::Monster)
- {
- if (serverFeatures && serverFeatures->haveMonsterName())
- beingHandler->requestNameById(id);
- }
- else if (type == ActorType::Portal)
- {
- if (beingHandler &&
- serverFeatures &&
- serverFeatures->haveServerWarpNames())
- {
- beingHandler->requestNameById(id);
- }
+ case ActorType::Player:
+ case ActorType::Mercenary:
+ case ActorType::Pet:
+ case ActorType::Homunculus:
+ case ActorType::Npc:
+ being->updateFromCache();
+ if (beingHandler)
+ beingHandler->requestNameById(id);
+ if (localPlayer)
+ localPlayer->checkNewName(being);
+ break;
+ case ActorType::Monster:
+ if (serverFeatures && serverFeatures->haveMonsterName())
+ beingHandler->requestNameById(id);
+ break;
+ case ActorType::Portal:
+ if (beingHandler &&
+ serverFeatures &&
+ serverFeatures->haveServerWarpNames())
+ {
+ beingHandler->requestNameById(id);
+ }
+ break;
+ case ActorType::SkillUnit:
+ case ActorType::Elemental:
+ break;
+ default:
+ case ActorType::FloorItem:
+ case ActorType::LocalPet:
+ case ActorType::Avatar:
+ case ActorType::Unknown:
+ reportAlways("CreateBeing for unknown type %d", CAST_S32(type));
+ break;
}
if (type == ActorType::Player)
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 485c93e44..8e43dd38f 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -49,6 +49,8 @@
#include "input/inputmanager.h"
+#include "utils/checkutils.h"
+
#include "resources/map/map.h"
#include "resources/map/mapitem.h"
#include "resources/map/speciallayer.h"
@@ -432,44 +434,61 @@ bool Viewport::leftMouseAction()
else
{
const ActorTypeT type = mHoverBeing->getType();
- if (type == ActorType::Player)
- {
- validateSpeed();
- if (actorManager)
- {
- if (localPlayer != mHoverBeing || mSelfMouseHeal)
- actorManager->heal(mHoverBeing);
- if (localPlayer == mHoverBeing && mHoverItem)
- localPlayer->pickUp(mHoverItem);
- return true;
- }
- }
- else if (!stopAttack &&
- (type == ActorType::Monster ||
- type == ActorType::Npc ||
- type == ActorType::SkillUnit))
+ switch (type)
{
- if ((localPlayer->withinAttackRange(mHoverBeing) ||
- inputManager.isActionActive(InputAction::ATTACK)))
- {
+ case ActorType::Player:
validateSpeed();
- if (!mStatsReUpdated && localPlayer != mHoverBeing)
+ if (actorManager)
{
- localPlayer->attack(mHoverBeing,
- !inputManager.isActionActive(
- InputAction::STOP_ATTACK));
+ if (localPlayer != mHoverBeing || mSelfMouseHeal)
+ actorManager->heal(mHoverBeing);
+ if (localPlayer == mHoverBeing && mHoverItem)
+ localPlayer->pickUp(mHoverItem);
return true;
}
- }
- else if (!inputManager.isActionActive(InputAction::ATTACK))
- {
- validateSpeed();
- if (!mStatsReUpdated && localPlayer != mHoverBeing)
+ break;
+ case ActorType::Monster:
+ case ActorType::Npc:
+ case ActorType::SkillUnit:
+ if (!stopAttack)
{
- localPlayer->setGotoTarget(mHoverBeing);
- return true;
+ if ((localPlayer->withinAttackRange(mHoverBeing) ||
+ inputManager.isActionActive(InputAction::ATTACK)))
+ {
+ validateSpeed();
+ if (!mStatsReUpdated && localPlayer != mHoverBeing)
+ {
+ localPlayer->attack(mHoverBeing,
+ !inputManager.isActionActive(
+ InputAction::STOP_ATTACK));
+ return true;
+ }
+ }
+ else if (!inputManager.isActionActive(InputAction::ATTACK))
+ {
+ validateSpeed();
+ if (!mStatsReUpdated && localPlayer != mHoverBeing)
+ {
+ localPlayer->setGotoTarget(mHoverBeing);
+ return true;
+ }
+ }
}
- }
+ break;
+ case ActorType::FloorItem:
+ case ActorType::Portal:
+ case ActorType::Pet:
+ case ActorType::Mercenary:
+ case ActorType::Homunculus:
+ case ActorType::Elemental:
+ break;
+ case ActorType::Unknown:
+ case ActorType::LocalPet:
+ case ActorType::Avatar:
+ default:
+ reportAlways("Left click on unknown actor type: %d",
+ CAST_S32(type));
+ break;
}
}
}
diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp
index 426003c7f..4885e3c05 100644
--- a/src/net/eathena/beingrecv.cpp
+++ b/src/net/eathena/beingrecv.cpp
@@ -60,6 +60,7 @@
#include "resources/map/map.h"
+#include "utils/checkutils.h"
#include "utils/timer.h"
#include "debug.h"
@@ -407,36 +408,55 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
dstBeing->setKarma(msg.readUInt8("karma"));
const uint8_t gender = CAST_U8(msg.readUInt8("gender") & 3);
- if (dstBeing->getType() == ActorType::Player)
- {
- dstBeing->setGender(Being::intToGender(gender));
- dstBeing->setHairColor(hairColor);
- // Set these after the gender, as the sprites may be gender-specific
- if (hairStyle == 0)
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- 0,
- std::string());
- }
- else
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
- dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
- dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- dstBeing->updateSprite(SPRITE_HAIR, shoes);
- dstBeing->updateSprite(SPRITE_SHOES, gloves);
- dstBeing->updateSprite(SPRITE_BODY, weapon);
- dstBeing->setWeaponId(weapon);
-// Ea::BeingRecv::setSprite(dstBeing, SPRITE_FLOOR, shield);
- }
- else if (dstBeing->getType() == ActorType::Npc
- && serverFeatures->haveNpcGender())
+ const ActorTypeT actorType = dstBeing->getType();
+ switch (actorType)
{
- dstBeing->setGender(Being::intToGender(gender));
+ case ActorType::Player:
+ dstBeing->setGender(Being::intToGender(gender));
+ dstBeing->setHairColor(hairColor);
+ // Set these after the gender, as the sprites may be gender-specific
+ if (hairStyle == 0)
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR,
+ 0,
+ std::string());
+ }
+ else
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR,
+ hairStyle * -1,
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ }
+ dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
+ dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
+ dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
+ dstBeing->updateSprite(SPRITE_HAIR, shoes);
+ dstBeing->updateSprite(SPRITE_SHOES, gloves);
+ dstBeing->updateSprite(SPRITE_BODY, weapon);
+ dstBeing->setWeaponId(weapon);
+ break;
+ case ActorType::Npc:
+ if (serverFeatures->haveNpcGender())
+ {
+ dstBeing->setGender(Being::intToGender(gender));
+ }
+ break;
+ default:
+ case ActorType::Monster:
+ case ActorType::Portal:
+ case ActorType::Pet:
+ case ActorType::Mercenary:
+ case ActorType::Homunculus:
+ case ActorType::SkillUnit:
+ case ActorType::Elemental:
+ break;
+ case ActorType::FloorItem:
+ case ActorType::LocalPet:
+ case ActorType::Avatar:
+ case ActorType::Unknown:
+ reportAlways("Wrong being type detected: %d",
+ CAST_S32(actorType));
+ break;
}
uint8_t dir;
@@ -605,37 +625,56 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
dstBeing->setKarma(msg.readUInt8("karma"));
const uint8_t gender = CAST_U8(msg.readUInt8("gender") & 3);
- if (dstBeing->getType() == ActorType::Player)
- {
- dstBeing->setGender(Being::intToGender(gender));
- dstBeing->setHairColor(hairColor);
- // Set these after the gender, as the sprites may be gender-specific
- if (hairStyle == 0)
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR, 0);
- }
- else
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- if (!serverFeatures->haveMove3())
- {
- dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
- dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
- dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- dstBeing->updateSprite(SPRITE_HAIR, shoes);
- dstBeing->updateSprite(SPRITE_SHOES, gloves);
- dstBeing->updateSprite(SPRITE_BODY, weapon);
- dstBeing->setWeaponId(weapon);
- }
-// Ea::BeingRecv::setSprite(dstBeing, SPRITE_FLOOR, shield);
- }
- else if (dstBeing->getType() == ActorType::Npc
- && serverFeatures->haveNpcGender())
+ const ActorTypeT actorType = dstBeing->getType();
+ switch (actorType)
{
- dstBeing->setGender(Being::intToGender(gender));
+ case ActorType::Player:
+ dstBeing->setGender(Being::intToGender(gender));
+ dstBeing->setHairColor(hairColor);
+ // Set these after the gender, as the sprites may be gender-specific
+ if (hairStyle == 0)
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR, 0);
+ }
+ else
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR,
+ hairStyle * -1,
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ }
+ if (!serverFeatures->haveMove3())
+ {
+ dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
+ dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
+ dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
+ dstBeing->updateSprite(SPRITE_HAIR, shoes);
+ dstBeing->updateSprite(SPRITE_SHOES, gloves);
+ dstBeing->updateSprite(SPRITE_BODY, weapon);
+ dstBeing->setWeaponId(weapon);
+ }
+ break;
+ case ActorType::Npc:
+ if (serverFeatures->haveNpcGender())
+ {
+ dstBeing->setGender(Being::intToGender(gender));
+ }
+ break;
+ default:
+ case ActorType::Monster:
+ case ActorType::Portal:
+ case ActorType::Pet:
+ case ActorType::Mercenary:
+ case ActorType::Homunculus:
+ case ActorType::SkillUnit:
+ case ActorType::Elemental:
+ break;
+ case ActorType::FloorItem:
+ case ActorType::LocalPet:
+ case ActorType::Avatar:
+ case ActorType::Unknown:
+ reportAlways("Wrong being type detected: %d",
+ CAST_S32(actorType));
+ break;
}
uint16_t srcX, srcY, dstX, dstY;
@@ -803,34 +842,53 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
dstBeing->setKarma(msg.readUInt8("karma"));
const uint8_t gender = CAST_U8(msg.readUInt8("gender") & 3);
- if (dstBeing->getType() == ActorType::Player)
+ const ActorTypeT actorType = dstBeing->getType();
+ switch (actorType)
{
- dstBeing->setGender(Being::intToGender(gender));
- dstBeing->setHairColor(hairColor);
- // Set these after the gender, as the sprites may be gender-specific
- if (hairStyle == 0)
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR, 0);
- }
- else
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
- dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
- dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- dstBeing->updateSprite(SPRITE_HAIR, shoes);
- dstBeing->updateSprite(SPRITE_SHOES, gloves);
- dstBeing->updateSprite(SPRITE_BODY, weapon);
- dstBeing->setWeaponId(weapon);
-// Ea::BeingRecv::setSprite(dstBeing, SPRITE_FLOOR, shield);
- }
- else if (dstBeing->getType() == ActorType::Npc
- && serverFeatures->haveNpcGender())
- {
- dstBeing->setGender(Being::intToGender(gender));
+ case ActorType::Player:
+ dstBeing->setGender(Being::intToGender(gender));
+ dstBeing->setHairColor(hairColor);
+ // Set these after the gender, as the sprites may be gender-specific
+ if (hairStyle == 0)
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR, 0);
+ }
+ else
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR,
+ hairStyle * -1,
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ }
+ dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
+ dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
+ dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
+ dstBeing->updateSprite(SPRITE_HAIR, shoes);
+ dstBeing->updateSprite(SPRITE_SHOES, gloves);
+ dstBeing->updateSprite(SPRITE_BODY, weapon);
+ dstBeing->setWeaponId(weapon);
+ break;
+ case ActorType::Npc:
+ if (serverFeatures->haveNpcGender())
+ {
+ dstBeing->setGender(Being::intToGender(gender));
+ }
+ break;
+ default:
+ case ActorType::Monster:
+ case ActorType::Portal:
+ case ActorType::Pet:
+ case ActorType::Mercenary:
+ case ActorType::Homunculus:
+ case ActorType::SkillUnit:
+ case ActorType::Elemental:
+ break;
+ case ActorType::FloorItem:
+ case ActorType::LocalPet:
+ case ActorType::Avatar:
+ case ActorType::Unknown:
+ reportAlways("Wrong being type detected: %d",
+ CAST_S32(actorType));
+ break;
}
uint8_t dir;