summaryrefslogtreecommitdiff
path: root/src/gui/windows/skilldialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-08 23:18:03 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-08 23:18:03 +0300
commit7380aa6e86b51ef62530bea5d6f6f63244dffc4a (patch)
tree1b9915284b2b9c3e0969ae05f54a53adba72e527 /src/gui/windows/skilldialog.cpp
parent7e66a4606bb15d98197f71245fe191d03152ee5f (diff)
downloadmanaplus-7380aa6e86b51ef62530bea5d6f6f63244dffc4a.tar.gz
manaplus-7380aa6e86b51ef62530bea5d6f6f63244dffc4a.tar.bz2
manaplus-7380aa6e86b51ef62530bea5d6f6f63244dffc4a.tar.xz
manaplus-7380aa6e86b51ef62530bea5d6f6f63244dffc4a.zip
Add some missing checks and remove useless checks.
Diffstat (limited to 'src/gui/windows/skilldialog.cpp')
-rw-r--r--src/gui/windows/skilldialog.cpp139
1 files changed, 68 insertions, 71 deletions
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index d8ae3ef2d..c5eb45c02 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -745,95 +745,92 @@ void SkillDialog::useSkill(const SkillInfo *const info,
if (!cmd.empty())
SpellManager::invokeCommand(cmd, localPlayer->getTarget());
}
- if (localPlayer)
+ switch (info->type)
{
- switch (info->type)
+ case SkillType::Attack:
{
- case SkillType::Attack:
+ const Being *being = localPlayer->getTarget();
+ if (!being && autoTarget == AutoTarget_true)
{
- const Being *being = localPlayer->getTarget();
- if (!being && autoTarget == AutoTarget_true)
- {
- being = localPlayer->setNewTarget(ActorType::Monster,
- AllowSort_true);
- }
- if (being)
- {
- skillHandler->useBeing(info->id,
- level,
- being->getId());
- }
- break;
+ being = localPlayer->setNewTarget(ActorType::Monster,
+ AllowSort_true);
}
- case SkillType::Support:
+ if (being)
{
- const Being *being = localPlayer->getTarget();
- if (!being)
- being = localPlayer;
- if (being)
- {
- skillHandler->useBeing(info->id,
- level,
- being->getId());
- }
- break;
+ skillHandler->useBeing(info->id,
+ level,
+ being->getId());
}
- case SkillType::Self:
+ break;
+ }
+ case SkillType::Support:
+ {
+ const Being *being = localPlayer->getTarget();
+ if (!being)
+ being = localPlayer;
+ if (being)
+ {
skillHandler->useBeing(info->id,
level,
- localPlayer->getId());
- break;
+ being->getId());
+ }
+ break;
+ }
+ case SkillType::Self:
+ skillHandler->useBeing(info->id,
+ level,
+ localPlayer->getId());
+ break;
- case SkillType::Ground:
+ case SkillType::Ground:
+ {
+ int x = 0;
+ int y = 0;
+ viewport->getMouseTile(x, y);
+ if (info->useTextParameter)
{
- int x = 0;
- int y = 0;
- viewport->getMouseTile(x, y);
- if (info->useTextParameter)
+ if (withText)
{
- if (withText)
- {
- skillHandler->usePos(info->id,
- level,
- x, y,
- text);
- }
- else
- {
- textSkillListener.setSkill(info->id,
- x,
- y,
- level);
- TextDialog *const dialog = CREATEWIDGETR(TextDialog,
- // TRANSLATORS: text skill dialog header
- strprintf(_("Add text to skill %s"),
- data->name.c_str()),
- // TRANSLATORS: text skill dialog field
- _("Text: "));
- dialog->setModal(Modal_true);
- textSkillListener.setDialog(dialog);
- dialog->setActionEventId("ok");
- dialog->addActionListener(&textSkillListener);
- }
+ skillHandler->usePos(info->id,
+ level,
+ x, y,
+ text);
}
else
{
- skillHandler->usePos(info->id,
- level,
- x, y);
+ textSkillListener.setSkill(info->id,
+ x,
+ y,
+ level);
+ TextDialog *const dialog = CREATEWIDGETR(TextDialog,
+ // TRANSLATORS: text skill dialog header
+ strprintf(_("Add text to skill %s"),
+ data->name.c_str()),
+ // TRANSLATORS: text skill dialog field
+ _("Text: "));
+ dialog->setModal(Modal_true);
+ textSkillListener.setDialog(dialog);
+ dialog->setActionEventId("ok");
+ dialog->addActionListener(&textSkillListener);
}
- break;
}
+ else
+ {
+ skillHandler->usePos(info->id,
+ level,
+ x, y);
+ }
+ break;
+ }
- case SkillType::TargetTrap:
- // for now unused
- break;
+ case SkillType::TargetTrap:
+ // for now unused
+ break;
- case SkillType::Unknown:
- case SkillType::Unused:
- default:
- break;
- }
+ case SkillType::Unknown:
+ case SkillType::Unused:
+ default:
+ break;
}
}