summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-08-03 20:03:30 +0300
committerAndrei Karas <akaras@inbox.ru>2016-08-03 20:03:30 +0300
commitabeecf1255d28a7870aef9f70dc3353d9b5f4f2d (patch)
tree975878d832cb3b2249684569f181c519c67566a3 /src/gui/viewport.cpp
parentedb279bdc22d94a88aabdd994bed5dd2b1c5659e (diff)
downloadmanaverse-abeecf1255d28a7870aef9f70dc3353d9b5f4f2d.tar.gz
manaverse-abeecf1255d28a7870aef9f70dc3353d9b5f4f2d.tar.bz2
manaverse-abeecf1255d28a7870aef9f70dc3353d9b5f4f2d.tar.xz
manaverse-abeecf1255d28a7870aef9f70dc3353d9b5f4f2d.zip
Replace some ifs to switches.
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp81
1 files changed, 50 insertions, 31 deletions
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;
}
}
}