summaryrefslogtreecommitdiff
path: root/src
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
parente0514307bfa5d7affb3dba5c8b61bf59b8bc3b81 (diff)
downloadplus-c14af75fab3ddb45886a358e5056c2b0baee91e1.tar.gz
plus-c14af75fab3ddb45886a358e5056c2b0baee91e1.tar.bz2
plus-c14af75fab3ddb45886a358e5056c2b0baee91e1.tar.xz
plus-c14af75fab3ddb45886a358e5056c2b0baee91e1.zip
Use skill type as bit mask with skill types.
It rare but still possible.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/being/being.cpp7
-rw-r--r--src/gui/widgets/skillinfo.cpp65
-rw-r--r--src/gui/windows/skilldialog.cpp144
5 files changed, 107 insertions, 113 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a39d4c22c..af4c47d41 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -765,6 +765,8 @@ SET(SRCS
resources/sdlmusic.h
resources/sdlscreenshothelper.cpp
resources/sdlscreenshothelper.h
+ resources/skilltypeentry.h
+ resources/skilltypelist.h
const/net/skill.h
const/resources/skill.h
enums/resources/skillowner.h
diff --git a/src/Makefile.am b/src/Makefile.am
index d85db0d37..13ec19f27 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -436,6 +436,8 @@ SRC += events/actionevent.h \
resources/sdlmusic.h \
resources/sdlscreenshothelper.cpp \
resources/sdlscreenshothelper.h \
+ resources/skilltypeentry.h \
+ resources/skilltypelist.h \
const/net/skill.h \
const/resources/skill.h \
enums/resources/skillowner.h \
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 4c750f5c8..cfb182355 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -1026,10 +1026,15 @@ void Being::handleSkill(Being *restrict const victim,
if (this != localPlayer && skill)
{
const SkillType::SkillType type = skill->type;
- if (type == SkillType::Attack || type == SkillType::Ground)
+ if ((type & SkillType::Attack) != 0 ||
+ (type & SkillType::Ground) != 0)
+ {
setAction(BeingAction::ATTACK, 1);
+ }
else
+ {
setAction(BeingAction::STAND, 1);
+ }
}
reset();
diff --git a/src/gui/widgets/skillinfo.cpp b/src/gui/widgets/skillinfo.cpp
index 4174146e2..2ce169451 100644
--- a/src/gui/widgets/skillinfo.cpp
+++ b/src/gui/widgets/skillinfo.cpp
@@ -31,6 +31,8 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
+#include "resources/skilltypelist.h"
+
#include "debug.h"
SkillInfo::SkillInfo() :
@@ -113,47 +115,30 @@ void SkillInfo::update()
// TRANSLATORS: skill type
const char *const typeStr = _("Type: %s");
- switch (type)
+
+ if (type == SkillType::Unknown)
+ {
+ // TRANSLATORS: Skill type
+ skillEffect = strprintf(typeStr, _("Unknown"));
+ }
+ else
+ {
+ for (size_t f = 0; f < skillTypeListSize; f ++)
+ {
+ const SkillTypeEntry &item = skillTypeList[f];
+ if ((item.type & type) != 0)
+ {
+ if (!skillEffect.empty())
+ skillEffect.append(", ");
+ skillEffect.append(strprintf(typeStr, item.name));
+ }
+ }
+ }
+ if (skillEffect.empty())
{
- case SkillType::Unknown:
- // TRANSLATORS: Skill type
- skillEffect = strprintf(typeStr, _("Unknown"));
- break;
-
- case SkillType::Attack:
- // TRANSLATORS: Skill type
- skillEffect = strprintf(typeStr, _("Attack"));
- break;
-
- case SkillType::Ground:
- // TRANSLATORS: Skill type
- skillEffect = strprintf(typeStr, _("Ground"));
- break;
-
- case SkillType::Self:
- // TRANSLATORS: Skill type
- skillEffect = strprintf(typeStr, _("Self"));
- break;
-
- case SkillType::Unused:
- // TRANSLATORS: Skill type
- skillEffect = strprintf(typeStr, _("Unused"));
- break;
-
- case SkillType::Support:
- // TRANSLATORS: Skill type
- skillEffect = strprintf(typeStr, _("Support"));
- break;
-
- case SkillType::TargetTrap:
- // TRANSLATORS: Skill type
- skillEffect = strprintf(typeStr, _("Target trap"));
- break;
- default:
- // TRANSLATORS: Skill type
- skillEffect = strprintf(typeStr, _("Unknown:"));
- skillEffect.append(" ").append(toString(CAST_S32(type)));
- break;
+ // TRANSLATORS: Skill type
+ skillEffect = strprintf(typeStr, _("Unknown:"));
+ skillEffect.append(" ").append(toString(CAST_S32(type)));
}
if (sp)
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);
}
}