summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-06 01:09:47 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-06 01:09:47 +0300
commit7fa78a35307227453ab55c7452e348a40cd41d65 (patch)
tree1d3e16a94bed043877306f1c47b3992add85b3be /src
parenta87db81b6b7551a248e31e2850577aefda092538 (diff)
downloadmv-7fa78a35307227453ab55c7452e348a40cd41d65.tar.gz
mv-7fa78a35307227453ab55c7452e348a40cd41d65.tar.bz2
mv-7fa78a35307227453ab55c7452e348a40cd41d65.tar.xz
mv-7fa78a35307227453ab55c7452e348a40cd41d65.zip
Add strong typed bool type Modifiable.
Diffstat (limited to 'src')
-rw-r--r--src/enums/simpletypes.h1
-rw-r--r--src/gui/widgets/skillinfo.cpp4
-rw-r--r--src/gui/widgets/skillinfo.h4
-rw-r--r--src/gui/windows/skilldialog.cpp10
-rw-r--r--src/gui/windows/skilldialog.h4
-rw-r--r--src/gui/windows/statuswindow.cpp4
-rw-r--r--src/gui/windows/statuswindow.h2
-rw-r--r--src/net/ea/guildhandler.cpp2
-rw-r--r--src/net/ea/skillhandler.cpp2
-rw-r--r--src/net/eathena/generalhandler.cpp17
-rw-r--r--src/net/eathena/homunculushandler.cpp4
-rw-r--r--src/net/eathena/mercenaryhandler.cpp2
-rw-r--r--src/net/eathena/skillhandler.cpp6
-rw-r--r--src/net/tmwa/generalhandler.cpp17
-rw-r--r--src/net/tmwa/skillhandler.cpp2
15 files changed, 47 insertions, 34 deletions
diff --git a/src/enums/simpletypes.h b/src/enums/simpletypes.h
index cd9c51a58..5fa747c56 100644
--- a/src/enums/simpletypes.h
+++ b/src/enums/simpletypes.h
@@ -58,5 +58,6 @@ defBoolEnum(Notify);
defBoolEnum(Trading);
defBoolEnum(Sfx);
defBoolEnum(Keep);
+defBoolEnum(Modifiable);
#endif // ENUMS_SIMPLETYPES_H
diff --git a/src/gui/widgets/skillinfo.cpp b/src/gui/widgets/skillinfo.cpp
index 864d973ea..80783a4b2 100644
--- a/src/gui/widgets/skillinfo.cpp
+++ b/src/gui/widgets/skillinfo.cpp
@@ -58,7 +58,7 @@ SkillInfo::SkillInfo() :
castingDstEffectId(-1),
type(SkillType::Unknown),
owner(SkillOwner::Player),
- modifiable(false),
+ modifiable(Modifiable_false),
visible(false),
alwaysVisible(false)
{
@@ -78,7 +78,7 @@ void SkillInfo::update()
const int baseLevel = PlayerInfo::getSkillLevel(id);
const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
- if (!modifiable && baseLevel == 0 && exp.second == 0)
+ if (modifiable == Modifiable_false && baseLevel == 0 && exp.second == 0)
{
if (visible)
{
diff --git a/src/gui/widgets/skillinfo.h b/src/gui/widgets/skillinfo.h
index 3e4d99820..9cec3aa49 100644
--- a/src/gui/widgets/skillinfo.h
+++ b/src/gui/widgets/skillinfo.h
@@ -23,6 +23,8 @@
#ifndef GUI_WIDGETS_SKILLINFO_H
#define GUI_WIDGETS_SKILLINFO_H
+#include "enums/simpletypes.h"
+
#include "gui/color.h"
#include "resources/skillowner.h"
@@ -66,7 +68,7 @@ struct SkillInfo final
int castingDstEffectId;
SkillType::SkillType type;
SkillOwner::Type owner;
- bool modifiable;
+ Modifiable modifiable;
bool visible;
bool alwaysVisible;
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index b9af88a06..a11ba562b 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -195,7 +195,7 @@ void SkillDialog::update()
FOR_EACH (SkillMap::const_iterator, it, mSkills)
{
SkillInfo *const info = (*it).second;
- if (info && info->modifiable)
+ if (info && info->modifiable == Modifiable_true)
info->update();
}
}
@@ -314,7 +314,7 @@ void SkillDialog::loadXmlFile(const std::string &fileName)
{
skill = new SkillInfo;
skill->id = static_cast<unsigned int>(id);
- skill->modifiable = false;
+ skill->modifiable = Modifiable_false;
skill->model = model;
skill->update();
skill->useButton = XML::getProperty(
@@ -421,7 +421,7 @@ void SkillDialog::removeSkill(const int id)
bool SkillDialog::updateSkill(const int id,
const int range,
- const bool modifiable,
+ const Modifiable modifiable,
const SkillType::SkillType type,
const int sp)
{
@@ -448,7 +448,7 @@ void SkillDialog::addSkill(const SkillOwner::Type owner,
const std::string &name,
const int level,
const int range,
- const bool modifiable,
+ const Modifiable modifiable,
const SkillType::SkillType type,
const int sp)
{
@@ -515,7 +515,7 @@ void SkillDialog::setSkillDuration(const SkillOwner::Type owner,
SkillInfo *info = nullptr;
if (it == mSkills.end())
{
- addSkill(owner, id, "", 0, 0, false, SkillType::Unknown, 0);
+ addSkill(owner, id, "", 0, 0, Modifiable_false, SkillType::Unknown, 0);
it = mSkills.find(id);
}
if (it != mSkills.end())
diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h
index 7a55c691b..d067643f4 100644
--- a/src/gui/windows/skilldialog.h
+++ b/src/gui/windows/skilldialog.h
@@ -84,7 +84,7 @@ class SkillDialog final : public Window,
bool updateSkill(const int id,
const int range,
- const bool modifiable,
+ const Modifiable modifiable,
const SkillType::SkillType type,
const int sp);
@@ -93,7 +93,7 @@ class SkillDialog final : public Window,
const std::string &name,
const int level,
const int range,
- const bool modifiable,
+ const Modifiable modifiable,
const SkillType::SkillType type,
const int sp);
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index aa62aae4c..198df1508 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -401,11 +401,11 @@ void StatusWindow::setPointsNeeded(const int id, const int needed)
void StatusWindow::addAttribute(const int id, const std::string &restrict name,
const std::string &restrict shortName,
- const bool modifiable)
+ const Modifiable modifiable)
{
AttrDisplay *disp;
- if (modifiable)
+ if (modifiable == Modifiable_true)
{
disp = new ChangeDisplay(this, id, name, shortName);
disp->update();
diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h
index bde444fe5..eea7f936e 100644
--- a/src/gui/windows/statuswindow.h
+++ b/src/gui/windows/statuswindow.h
@@ -58,7 +58,7 @@ class StatusWindow final : public Window,
void addAttribute(const int id, const std::string &restrict name,
const std::string &restrict shortName = "",
- const bool modifiable = false);
+ const Modifiable modifiable = Modifiable_false);
static void updateHPBar(ProgressBar *const bar,
const bool showMax = false);
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index 3b15062ff..1b8302ace 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -343,7 +343,7 @@ void GuildHandler::processGuildSkillInfo(Net::MessageIn &msg)
const int sp = msg.readInt16("sp");
const int range = msg.readInt16("range");
const std::string name = msg.readString(24, "skill name");
- const int up = msg.readUInt8("up flag");
+ const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
PlayerInfo::setSkillLevel(skillId, level);
if (skillDialog)
{
diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp
index 2aeb41357..f05d1f18a 100644
--- a/src/net/ea/skillhandler.cpp
+++ b/src/net/ea/skillhandler.cpp
@@ -43,7 +43,7 @@ void SkillHandler::processPlayerSkillUp(Net::MessageIn &msg)
const int level = msg.readInt16("skill level");
const int sp = msg.readInt16("sp");
const int range = msg.readInt16("range");
- const int up = msg.readUInt8("up flag");
+ const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
if (skillDialog && PlayerInfo::getSkillLevel(skillId) != level)
skillDialog->playUpdateEffect(skillId);
diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp
index b527aae70..3c442af82 100644
--- a/src/net/eathena/generalhandler.cpp
+++ b/src/net/eathena/generalhandler.cpp
@@ -390,13 +390,18 @@ void GeneralHandler::gameStarted() const
// protection against double addition attributes.
statusWindow->clearAttributes();
- statusWindow->addAttribute(Attributes::STR, _("Strength"), "str", true);
- statusWindow->addAttribute(Attributes::AGI, _("Agility"), "agi", true);
- statusWindow->addAttribute(Attributes::VIT, _("Vitality"), "vit", true);
+ statusWindow->addAttribute(Attributes::STR,
+ _("Strength"), "str", Modifiable_true);
+ statusWindow->addAttribute(Attributes::AGI,
+ _("Agility"), "agi", Modifiable_true);
+ statusWindow->addAttribute(Attributes::VIT,
+ _("Vitality"), "vit", Modifiable_true);
statusWindow->addAttribute(Attributes::INT,
- _("Intelligence"), "int", true);
- statusWindow->addAttribute(Attributes::DEX, _("Dexterity"), "dex", true);
- statusWindow->addAttribute(Attributes::LUK, _("Luck"), "luk", true);
+ _("Intelligence"), "int", Modifiable_true);
+ statusWindow->addAttribute(Attributes::DEX,
+ _("Dexterity"), "dex", Modifiable_true);
+ statusWindow->addAttribute(Attributes::LUK,
+ _("Luck"), "luk", Modifiable_true);
statusWindow->addAttribute(Attributes::ATK, _("Attack"));
statusWindow->addAttribute(Attributes::DEF, _("Defense"));
diff --git a/src/net/eathena/homunculushandler.cpp b/src/net/eathena/homunculushandler.cpp
index e3f83cd39..2bfe358c2 100644
--- a/src/net/eathena/homunculushandler.cpp
+++ b/src/net/eathena/homunculushandler.cpp
@@ -108,7 +108,7 @@ void HomunculusHandler::processHomunculusSkills(Net::MessageIn &msg)
const int sp = msg.readInt16("sp");
const int range = msg.readInt16("range");
const std::string name = msg.readString(24, "skill name");
- const int up = msg.readUInt8("up flag");
+ const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
PlayerInfo::setSkillLevel(skillId, level);
if (skillDialog)
{
@@ -202,7 +202,7 @@ void HomunculusHandler::processHomunculusSkillUp(Net::MessageIn &msg)
const int level = msg.readInt16("level");
const int sp = msg.readInt16("sp");
const int range = msg.readInt16("range");
- const int up = msg.readUInt8("up flag");
+ const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
if (skillDialog && PlayerInfo::getSkillLevel(skillId) != level)
skillDialog->playUpdateEffect(skillId);
diff --git a/src/net/eathena/mercenaryhandler.cpp b/src/net/eathena/mercenaryhandler.cpp
index 1bc35a72f..ebdba730e 100644
--- a/src/net/eathena/mercenaryhandler.cpp
+++ b/src/net/eathena/mercenaryhandler.cpp
@@ -136,7 +136,7 @@ void MercenaryHandler::processMercenarySkills(Net::MessageIn &msg)
const int sp = msg.readInt16("sp");
const int range = msg.readInt16("range");
const std::string name = msg.readString(24, "skill name");
- const int up = msg.readUInt8("up flag");
+ const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
PlayerInfo::setSkillLevel(skillId, level);
if (skillDialog)
{
diff --git a/src/net/eathena/skillhandler.cpp b/src/net/eathena/skillhandler.cpp
index 413ff103f..445a0b78b 100644
--- a/src/net/eathena/skillhandler.cpp
+++ b/src/net/eathena/skillhandler.cpp
@@ -213,7 +213,7 @@ void SkillHandler::processPlayerSkills(Net::MessageIn &msg)
const int sp = msg.readInt16("sp");
const int range = msg.readInt16("range");
const std::string name = msg.readString(24, "skill name");
- const int up = msg.readUInt8("up flag");
+ const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
const int oldLevel = PlayerInfo::getSkillLevel(skillId);
if (oldLevel && oldLevel != level)
updateSkill = skillId;
@@ -245,7 +245,7 @@ void SkillHandler::processSkillAdd(Net::MessageIn &msg)
const int sp = msg.readInt16("sp");
const int range = msg.readInt16("range");
const std::string name = msg.readString(24, "skill name");
- const int up = msg.readUInt8("up flag");
+ const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
const int oldLevel = PlayerInfo::getSkillLevel(skillId);
if (oldLevel && oldLevel != level)
updateSkill = skillId;
@@ -272,7 +272,7 @@ void SkillHandler::processSkillUpdate(Net::MessageIn &msg)
const int level = msg.readInt16("skill level");
const int sp = msg.readInt16("sp");
const int range = msg.readInt16("range");
- const int up = msg.readUInt8("up flag");
+ const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
const int oldLevel = PlayerInfo::getSkillLevel(skillId);
if (oldLevel && oldLevel != level)
updateSkill = skillId;
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index bf7ff4148..548ee7b8f 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -342,18 +342,23 @@ void GeneralHandler::gameStarted() const
statusWindow->clearAttributes();
// TRANSLATORS: player stat
- statusWindow->addAttribute(Attributes::STR, _("Strength"), "str", true);
+ statusWindow->addAttribute(Attributes::STR,
+ _("Strength"), "str", Modifiable_true);
// TRANSLATORS: player stat
- statusWindow->addAttribute(Attributes::AGI, _("Agility"), "agi", true);
+ statusWindow->addAttribute(Attributes::AGI,
+ _("Agility"), "agi", Modifiable_true);
// TRANSLATORS: player stat
- statusWindow->addAttribute(Attributes::VIT, _("Vitality"), "vit", true);
+ statusWindow->addAttribute(Attributes::VIT,
+ _("Vitality"), "vit", Modifiable_true);
// TRANSLATORS: player stat
statusWindow->addAttribute(Attributes::INT,
- _("Intelligence"), "int", true);
+ _("Intelligence"), "int", Modifiable_true);
// TRANSLATORS: player stat
- statusWindow->addAttribute(Attributes::DEX, _("Dexterity"), "dex", true);
+ statusWindow->addAttribute(Attributes::DEX,
+ _("Dexterity"), "dex", Modifiable_true);
// TRANSLATORS: player stat
- statusWindow->addAttribute(Attributes::LUK, _("Luck"), "luk", true);
+ statusWindow->addAttribute(Attributes::LUK,
+ _("Luck"), "luk", Modifiable_true);
// TRANSLATORS: player stat
statusWindow->addAttribute(Attributes::ATK, _("Attack"));
// TRANSLATORS: player stat
diff --git a/src/net/tmwa/skillhandler.cpp b/src/net/tmwa/skillhandler.cpp
index b88e9e509..1b8678682 100644
--- a/src/net/tmwa/skillhandler.cpp
+++ b/src/net/tmwa/skillhandler.cpp
@@ -135,7 +135,7 @@ void SkillHandler::processPlayerSkills(Net::MessageIn &msg)
const int sp = msg.readInt16("sp");
const int range = msg.readInt16("range");
msg.skip(24, "unused");
- const int up = msg.readUInt8("up flag");
+ const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
const int oldLevel = PlayerInfo::getSkillLevel(skillId);
if (oldLevel && oldLevel != level)
updateSkill = skillId;