summaryrefslogtreecommitdiff
path: root/src/gui/windows/skilldialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-04 20:04:05 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-04 20:04:05 +0300
commitc14af75fab3ddb45886a358e5056c2b0baee91e1 (patch)
tree8bc0979e70665db89c49b29d938ad7de376f4115 /src/gui/windows/skilldialog.cpp
parente0514307bfa5d7affb3dba5c8b61bf59b8bc3b81 (diff)
downloadmv-c14af75fab3ddb45886a358e5056c2b0baee91e1.tar.gz
mv-c14af75fab3ddb45886a358e5056c2b0baee91e1.tar.bz2
mv-c14af75fab3ddb45886a358e5056c2b0baee91e1.tar.xz
mv-c14af75fab3ddb45886a358e5056c2b0baee91e1.zip
Use skill type as bit mask with skill types.
It rare but still possible.
Diffstat (limited to 'src/gui/windows/skilldialog.cpp')
-rw-r--r--src/gui/windows/skilldialog.cpp144
1 files changed, 72 insertions, 72 deletions
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index b61afb70f..0610e7f94 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -51,6 +51,7 @@
#include "net/playerhandler.h"
#include "net/skillhandler.h"
+#include "utils/checkutils.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
#include "utils/timer.h"
@@ -748,92 +749,91 @@ void SkillDialog::useSkill(const SkillInfo *const info,
if (!cmd.empty())
SpellManager::invokeCommand(cmd, localPlayer->getTarget());
}
- switch (info->type)
+ SkillType::SkillType type = info->type;
+ if ((type & SkillType::Attack) != 0)
{
- 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:
+ }
+ else if ((type & SkillType::Support) != 0)
+ {
+ const Being *being = localPlayer->getTarget();
+ if (!being)
+ being = localPlayer;
+ if (being)
+ {
skillHandler->useBeing(info->id,
level,
- localPlayer->getId());
- break;
-
- case SkillType::Ground:
+ being->getId());
+ }
+ }
+ else if ((type & SkillType::Self) != 0)
+ {
+ skillHandler->useBeing(info->id,
+ level,
+ localPlayer->getId());
+ }
+ else if ((type & SkillType::Ground) != 0)
+ {
+ 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;
}
-
- case SkillType::TargetTrap:
- // for now unused
- break;
-
- case SkillType::Unknown:
- case SkillType::Unused:
- default:
- break;
+ else
+ {
+ skillHandler->usePos(info->id,
+ level,
+ x, y);
+ }
+ }
+ else if ((type & SkillType::TargetTrap) != 0)
+ {
+ // for now unused
+ }
+ else if (type == SkillType::Unknown ||
+ type == SkillType::Unused)
+ {
+ // unknown / unused
+ }
+ else
+ {
+ reportAlways("Unsupported skill type: %d", type);
}
}