diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-08-03 20:03:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-08-03 20:03:30 +0300 |
commit | abeecf1255d28a7870aef9f70dc3353d9b5f4f2d (patch) | |
tree | 975878d832cb3b2249684569f181c519c67566a3 /src/gui | |
parent | edb279bdc22d94a88aabdd994bed5dd2b1c5659e (diff) | |
download | mv-abeecf1255d28a7870aef9f70dc3353d9b5f4f2d.tar.gz mv-abeecf1255d28a7870aef9f70dc3353d9b5f4f2d.tar.bz2 mv-abeecf1255d28a7870aef9f70dc3353d9b5f4f2d.tar.xz mv-abeecf1255d28a7870aef9f70dc3353d9b5f4f2d.zip |
Replace some ifs to switches.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/viewport.cpp | 81 |
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; } } } |