summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-24 01:30:46 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-24 01:32:02 +0300
commit3da7fa61442364be6713359690a35f89aa8e613a (patch)
tree48a941dbbb0234b897478aa50518112407d08e5b /src
parent470aaad15a0f9a08dd12ab34c8602cd93fc57b76 (diff)
downloadmanaplus-3da7fa61442364be6713359690a35f89aa8e613a.tar.gz
manaplus-3da7fa61442364be6713359690a35f89aa8e613a.tar.bz2
manaplus-3da7fa61442364be6713359690a35f89aa8e613a.tar.xz
manaplus-3da7fa61442364be6713359690a35f89aa8e613a.zip
Add support for show quest variables in skills window (evol only)
This allow use pseudo skills controlled by quest variables.
Diffstat (limited to 'src')
-rw-r--r--src/actorspritemanager.cpp6
-rw-r--r--src/gui/chatwindow.cpp3
-rw-r--r--src/gui/skilldialog.cpp63
-rw-r--r--src/gui/skilldialog.h5
-rw-r--r--src/gui/statuswindow.cpp38
-rw-r--r--src/localplayer.cpp10
-rw-r--r--src/net/ea/playerhandler.cpp120
-rw-r--r--src/net/ea/playerhandler.h4
-rw-r--r--src/net/ea/specialhandler.cpp6
-rw-r--r--src/net/playerhandler.h5
-rw-r--r--src/net/tmwa/questhandler.cpp5
-rw-r--r--src/playerinfo.cpp36
-rw-r--r--src/playerinfo.h20
-rw-r--r--src/spellmanager.cpp7
14 files changed, 155 insertions, 173 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 4a36d6e1d..899f51088 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -1144,10 +1144,8 @@ void ActorSpriteManager::heal(const Being *const target) const
}
}
// magic levels < 2
- else if (PlayerInfo::getStatEffective(
- static_cast<PlayerInfo::Attribute>(340)) < 2
- || PlayerInfo::getStatEffective(
- static_cast<PlayerInfo::Attribute>(341)) < 2)
+ else if (PlayerInfo::getStatEffective(340) < 2
+ || PlayerInfo::getStatEffective(341) < 2)
{
if (PlayerInfo::getAttribute(PlayerInfo::MP) >= 6)
{
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 705ef6e61..78ffde880 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -998,8 +998,7 @@ void ChatWindow::processEvent(Channels channel, const DepricatedEvent &event)
if (id == Net::getPlayerHandler()->getJobLocation())
{
const std::pair<int, int> exp
- = PlayerInfo::getStatExperience(
- static_cast<PlayerInfo::Attribute>(id));
+ = PlayerInfo::getStatExperience(id);
if (event.getInt("oldValue1") > exp.first
|| !event.getInt("oldValue2"))
{
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 053bcbd1b..ee248562a 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -277,6 +277,7 @@ SkillDialog::SkillDialog() :
setupWindow->registerWindowForReset(this);
mUseButton->setEnabled(false);
+ mIncreaseButton->setEnabled(false);
place(0, 0, mTabs, 5, 5);
place(0, 5, mPointsLabel, 4);
@@ -316,7 +317,7 @@ void SkillDialog::action(const gcn::ActionEvent &event)
if (const SkillInfo *const info = tab->getSelectedInfo())
{
mUseButton->setEnabled(info->range > 0);
-
+ mIncreaseButton->setEnabled(info->id < SKILL_VAR_MIN_ID);
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS)
&& itemShortcut[num])
@@ -328,6 +329,7 @@ void SkillDialog::action(const gcn::ActionEvent &event)
else
{
mUseButton->setEnabled(false);
+ mIncreaseButton->setEnabled(false);
}
}
}
@@ -471,14 +473,20 @@ void SkillDialog::loadSkills()
{
if (xmlNameEqual(node, "skill"))
{
- const int id = atoi(XML::getProperty(
- node, "id", "-1").c_str());
+ int id = XML::getIntProperty(node, "id", -1, -1, 1000000);
+ if (id == -1)
+ {
+ id = XML::getIntProperty(node, "var", -1, -1, 100000);
+ if (id == -1)
+ continue;
+ id += SKILL_VAR_MIN_ID;
+ }
SkillInfo *skill = getSkill(id);
if (!skill)
{
skill = new SkillInfo;
- skill->id = static_cast<short unsigned>(id);
+ skill->id = static_cast<unsigned int>(id);
skill->modifiable = false;
skill->visible = false;
skill->model = model;
@@ -497,8 +505,16 @@ void SkillDialog::loadSkills()
data->name = name;
data->setIcon(icon);
- data->dispName = strprintf("%s, %d",
- name.c_str(), skill->id);
+ if (skill->id < SKILL_VAR_MIN_ID)
+ {
+ data->dispName = strprintf("%s, %d",
+ name.c_str(), skill->id);
+ }
+ else
+ {
+ data->dispName = strprintf("%s, (%d)",
+ name.c_str(), skill->id - SKILL_VAR_MIN_ID);
+ }
data->shortName = XML::langProperty(node,
"shortName", name.substr(0, 3));
data->description = XML::langProperty(
@@ -558,7 +574,7 @@ void SkillDialog::addSkill(const int id, const int level, const int range,
if (mDefaultModel)
{
SkillInfo *const skill = new SkillInfo;
- skill->id = static_cast<short unsigned>(id);
+ skill->id = static_cast<unsigned int>(id);
skill->data->name = "Unknown skill Id: " + toString(id);
skill->data->dispName = "Unknown skill Id: " + toString(id);
skill->data->description.clear();
@@ -624,9 +640,31 @@ void SkillDialog::updateTabSelection()
if (tab)
{
if (const SkillInfo *const info = tab->getSelectedInfo())
+ {
mUseButton->setEnabled(info->range > 0);
+ mIncreaseButton->setEnabled(info->id < SKILL_VAR_MIN_ID);
+ }
else
+ {
mUseButton->setEnabled(false);
+ }
+ }
+}
+
+void SkillDialog::updateQuest(const int var, const int val)
+{
+ const int id = var + SKILL_VAR_MIN_ID;
+ const SkillMap::const_iterator it = mSkills.find(id);
+
+ if (it != mSkills.end())
+ {
+ SkillInfo *const info = it->second;
+ if (info)
+ {
+ PlayerInfo::setStatBase(id, val);
+ info->level = val;
+ info->update();
+ }
}
}
@@ -647,13 +685,9 @@ SkillInfo::~SkillInfo()
void SkillInfo::update()
{
- const int baseLevel = PlayerInfo::getStatBase(
- static_cast<PlayerInfo::Attribute>(id));
- const int effLevel = PlayerInfo::getStatEffective(
- static_cast<PlayerInfo::Attribute>(id));
-
- const std::pair<int, int> exp = PlayerInfo::getStatExperience(
- static_cast<PlayerInfo::Attribute>(id));
+ const int baseLevel = PlayerInfo::getStatBase(id);
+ const int effLevel = PlayerInfo::getStatEffective(id);
+ const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
if (!modifiable && baseLevel == 0 && effLevel == 0 && exp.second == 0)
{
@@ -663,7 +697,6 @@ void SkillInfo::update()
if (model)
model->updateVisibilities();
}
-
return;
}
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index 396718310..cf2b518e2 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -32,6 +32,7 @@
#include <vector>
const int SKILL_MIN_ID = 200000;
+const int SKILL_VAR_MIN_ID = 1000000;
class Button;
class Label;
@@ -68,7 +69,7 @@ struct SkillInfo final
int level;
std::string skillLevel;
int skillLevelWidth;
- unsigned short id;
+ unsigned int id;
bool modifiable;
bool visible;
SkillModel *model;
@@ -145,6 +146,8 @@ class SkillDialog final : public Window, public gcn::ActionListener
void updateTabSelection();
+ void updateQuest(const int var, const int val);
+
private:
typedef std::map<int, SkillInfo*> SkillMap;
SkillMap mSkills;
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 019d136d4..3e34b088d 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -373,12 +373,10 @@ void StatusWindow::processEvent(Channels channel A_UNUSED,
{
if (mJobLvlLabel)
{
- int lvl = PlayerInfo::getStatBase(
- static_cast<PlayerInfo::Attribute>(id));
-
+ int lvl = PlayerInfo::getStatBase(id);
const int oldExp = event.getInt("oldValue1");
- const std::pair<int, int> exp = PlayerInfo::getStatExperience(
- static_cast<PlayerInfo::Attribute>(id));
+ const std::pair<int, int> exp
+ = PlayerInfo::getStatExperience(id);
if (!lvl)
{
@@ -392,8 +390,7 @@ void StatusWindow::processEvent(Channels channel A_UNUSED,
{
lvl = (exp.second - 20000) / 150;
blocked = true;
- PlayerInfo::setStatBase(
- static_cast<PlayerInfo::Attribute>(id), lvl);
+ PlayerInfo::setStatBase(id, lvl);
blocked = false;
}
}
@@ -404,10 +401,8 @@ void StatusWindow::processEvent(Channels channel A_UNUSED,
lvl ++;
blocked = true;
PlayerInfo::setStatExperience(
- static_cast<PlayerInfo::Attribute>(id),
- exp.first, 20000 + lvl * 150);
- PlayerInfo::setStatBase(
- static_cast<PlayerInfo::Attribute>(id), lvl);
+ id, exp.first, 20000 + lvl * 150);
+ PlayerInfo::setStatBase(id, lvl);
blocked = false;
}
@@ -589,8 +584,7 @@ void StatusWindow::updateJobBar(ProgressBar *const bar, const bool percent)
void StatusWindow::updateProgressBar(ProgressBar *const bar, const int id,
const bool percent) const
{
- const std::pair<int, int> exp = PlayerInfo::getStatExperience(
- static_cast<PlayerInfo::Attribute>(id));
+ const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
updateProgressBar(bar, exp.first, exp.second, percent);
}
@@ -783,10 +777,8 @@ AttrDisplay::~AttrDisplay()
std::string AttrDisplay::update()
{
- const int base = PlayerInfo::getStatBase(
- static_cast<PlayerInfo::Attribute>(mId));
- const int bonus = PlayerInfo::getStatMod(
- static_cast<PlayerInfo::Attribute>(mId));
+ const int base = PlayerInfo::getStatBase(mId);
+ const int bonus = PlayerInfo::getStatMod(mId);
std::string value = toString(base + bonus);
if (bonus)
value += strprintf("=%d%+d", base, bonus);
@@ -872,10 +864,8 @@ void ChangeDisplay::action(const gcn::ActionEvent &event)
PlayerInfo::CHAR_POINTS) + 1;
PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, newpoints);
- const int newbase = PlayerInfo::getStatBase(
- static_cast<PlayerInfo::Attribute>(mId)) - 1;
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- mId), newbase);
+ const int newbase = PlayerInfo::getStatBase(mId) - 1;
+ PlayerInfo::setStatBase(mId, newbase);
Net::getPlayerHandler()->decreaseAttribute(mId);
}
@@ -893,10 +883,8 @@ void ChangeDisplay::action(const gcn::ActionEvent &event)
PlayerInfo::CHAR_POINTS) - cnt;
PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, newpoints);
- const int newbase = PlayerInfo::getStatBase(
- static_cast<PlayerInfo::Attribute>(mId)) + cnt;
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- mId), newbase);
+ const int newbase = PlayerInfo::getStatBase(mId) + cnt;
+ PlayerInfo::setStatBase(mId, newbase);
for (unsigned f = 0; f < mInc->getClickCount(); f ++)
{
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index b4c31b33a..f7a95625f 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -1697,8 +1697,8 @@ void LocalPlayer::processEvent(Channels channel,
const int id = event.getInt("id");
if (id == Net::getPlayerHandler()->getJobLocation())
{
- const std::pair<int, int> exp = PlayerInfo::getStatExperience(
- static_cast<PlayerInfo::Attribute>(id));
+ const std::pair<int, int> exp
+ = PlayerInfo::getStatExperience(id);
if (event.getInt("oldValue1") > exp.first
|| !event.getInt("oldValue2"))
{
@@ -3272,10 +3272,8 @@ void LocalPlayer::tryMagic(const std::string &spell, const int baseMagic,
if (!chatWindow)
return;
- if (PlayerInfo::getStatEffective(static_cast<PlayerInfo::Attribute>(
- 340)) >= baseMagic
- && PlayerInfo::getStatEffective(static_cast<PlayerInfo::Attribute>(
- 342)) >= schoolMagic)
+ if (PlayerInfo::getStatEffective(340) >= baseMagic
+ && PlayerInfo::getStatEffective(342) >= schoolMagic)
{
if (PlayerInfo::getAttribute(PlayerInfo::MP) >= mana)
{
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index f46a2241b..81bc373f3 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -360,60 +360,48 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
break;
case 0x0029:
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- EA_ATK), value);
+ PlayerInfo::setStatBase(EA_ATK, value);
PlayerInfo::updateAttrs();
break;
case 0x002a:
- PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
- EA_ATK), value);
+ PlayerInfo::setStatMod(EA_ATK, value);
PlayerInfo::updateAttrs();
break;
case 0x002b:
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- EA_MATK), value);
+ PlayerInfo::setStatBase(EA_MATK, value);
break;
case 0x002c:
- PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
- EA_MATK), value);
+ PlayerInfo::setStatMod(EA_MATK, value);
break;
case 0x002d:
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- EA_DEF), value);
+ PlayerInfo::setStatBase(EA_DEF, value);
break;
case 0x002e:
- PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
- EA_DEF), value);
+ PlayerInfo::setStatMod(EA_DEF, value);
break;
case 0x002f:
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- EA_MDEF), value);
+ PlayerInfo::setStatBase(EA_MDEF, value);
break;
case 0x0030:
- PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
- EA_MDEF), value);
+ PlayerInfo::setStatMod(EA_MDEF, value);
break;
case 0x0031:
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- EA_HIT), value);
+ PlayerInfo::setStatBase(EA_HIT, value);
break;
case 0x0032:
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- EA_FLEE), value);
+ PlayerInfo::setStatBase(EA_FLEE, value);
break;
case 0x0033:
- PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
- EA_FLEE), value);
+ PlayerInfo::setStatMod(EA_FLEE, value);
break;
case 0x0034:
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- EA_CRIT), value);
+ PlayerInfo::setStatBase(EA_CRIT, value);
break;
case 0x0035:
@@ -424,8 +412,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
break;
case 0x0037:
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- EA_JOB), value);
+ PlayerInfo::setStatBase(EA_JOB, value);
break;
case 500:
@@ -460,10 +447,8 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg)
PlayerInfo::setAttribute(PlayerInfo::EXP, msg.readInt32());
break;
case 0x0002:
- PlayerInfo::setStatExperience(static_cast<PlayerInfo::Attribute>(
- EA_JOB), msg.readInt32(),
- PlayerInfo::getStatExperience(static_cast<PlayerInfo::Attribute>(
- EA_JOB)).second);
+ PlayerInfo::setStatExperience(EA_JOB, msg.readInt32(),
+ PlayerInfo::getStatExperience(EA_JOB).second);
break;
case 0x0014:
{
@@ -487,10 +472,8 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg)
PlayerInfo::setAttribute(PlayerInfo::EXP_NEEDED, msg.readInt32());
break;
case 0x0017:
- PlayerInfo::setStatExperience(static_cast<PlayerInfo::Attribute>(
- EA_JOB), PlayerInfo::getStatExperience(
- static_cast<PlayerInfo::Attribute>(EA_JOB)).first,
- msg.readInt32());
+ PlayerInfo::setStatExperience(EA_JOB, PlayerInfo::getStatExperience(
+ EA_JOB).first, msg.readInt32());
break;
default:
logger->log("QQQQ PLAYER_STAT_UPDATE_2 " + toString(type));
@@ -504,10 +487,8 @@ void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg)
const int base = msg.readInt32();
const int bonus = msg.readInt32();
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- type), base, false);
- PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
- type), bonus);
+ PlayerInfo::setStatBase(type, base, false);
+ PlayerInfo::setStatMod(type, bonus);
if (type == EA_ATK || type == PlayerInfo::ATTACK_DELAY)
PlayerInfo::updateAttrs();
}
@@ -520,15 +501,14 @@ void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg)
if (ok != 1)
{
- const int oldValue = PlayerInfo::getStatBase(
- static_cast<PlayerInfo::Attribute>(type));
+ const int oldValue = PlayerInfo::getStatBase(type);
int points = PlayerInfo::getAttribute(PlayerInfo::CHAR_POINTS);
points += oldValue - value;
PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, points);
SERVER_NOTICE(_("Cannot raise skill!"))
}
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(type), value);
+ PlayerInfo::setStatBase(type, value);
}
void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg)
@@ -536,80 +516,69 @@ void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg)
PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, msg.readInt16());
int val = msg.readInt8();
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_STR), val);
+ PlayerInfo::setStatBase(EA_STR, val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_STR, msg.readInt8());
else
msg.readInt8();
val = msg.readInt8();
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_AGI), val);
+ PlayerInfo::setStatBase(EA_AGI, val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_AGI, msg.readInt8());
else
msg.readInt8();
val = msg.readInt8();
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_VIT), val);
+ PlayerInfo::setStatBase(EA_VIT, val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_VIT, msg.readInt8());
else
msg.readInt8();
val = msg.readInt8();
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_INT), val);
+ PlayerInfo::setStatBase(EA_INT, val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_INT, msg.readInt8());
else
msg.readInt8();
val = msg.readInt8();
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_DEX), val);
+ PlayerInfo::setStatBase(EA_DEX, val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_DEX, msg.readInt8());
else
msg.readInt8();
val = msg.readInt8();
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_LUK), val);
+ PlayerInfo::setStatBase(EA_LUK, val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_LUK, msg.readInt8());
else
msg.readInt8();
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_ATK),
- msg.readInt16(), false);
- PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_ATK),
- msg.readInt16());
+ PlayerInfo::setStatBase(EA_ATK, msg.readInt16(), false);
+ PlayerInfo::setStatMod(EA_ATK, msg.readInt16());
PlayerInfo::updateAttrs();
val = msg.readInt16();
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_MATK),
- val, false);
+ PlayerInfo::setStatBase(EA_MATK, val, false);
val = msg.readInt16();
- PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_MATK), val);
+ PlayerInfo::setStatMod(EA_MATK, val);
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_DEF),
- msg.readInt16(), false);
- PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_DEF),
- msg.readInt16());
+ PlayerInfo::setStatBase(EA_DEF, msg.readInt16(), false);
+ PlayerInfo::setStatMod(EA_DEF, msg.readInt16());
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_MDEF),
- msg.readInt16(), false);
- PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_MDEF),
- msg.readInt16());
+ PlayerInfo::setStatBase(EA_MDEF, msg.readInt16(), false);
+ PlayerInfo::setStatMod(EA_MDEF, msg.readInt16());
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_HIT),
- msg.readInt16());
+ PlayerInfo::setStatBase(EA_HIT, msg.readInt16());
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_FLEE),
- msg.readInt16(), false);
- PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_FLEE),
- msg.readInt16());
+ PlayerInfo::setStatBase(EA_FLEE, msg.readInt16(), false);
+ PlayerInfo::setStatMod(EA_FLEE, msg.readInt16());
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_CRIT),
- msg.readInt16());
+ PlayerInfo::setStatBase(EA_CRIT, msg.readInt16());
msg.readInt16(); // manner
}
@@ -667,18 +636,17 @@ void PlayerHandler::processPlayerArrowMessage(Net::MessageIn &msg)
bool PlayerHandler::canUseMagic() const
{
- return PlayerInfo::getStatEffective(static_cast<PlayerInfo::Attribute>(
- EA_MATK)) > 0;
+ return PlayerInfo::getStatEffective(EA_MATK) > 0;
}
-PlayerInfo::Attribute PlayerHandler::getJobLocation() const
+int PlayerHandler::getJobLocation() const
{
- return static_cast<PlayerInfo::Attribute>(EA_JOB);
+ return EA_JOB;
}
-PlayerInfo::Attribute PlayerHandler::getAttackLocation() const
+int PlayerHandler::getAttackLocation() const
{
- return static_cast<PlayerInfo::Attribute>(EA_ATK);
+ return EA_ATK;
}
} // namespace Ea
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index 6df4cc237..016b29782 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -49,9 +49,9 @@ class PlayerHandler : public Net::PlayerHandler
Vector getDefaultWalkSpeed() const A_WARN_UNUSED;
- PlayerInfo::Attribute getJobLocation() const A_WARN_UNUSED;
+ int getJobLocation() const A_WARN_UNUSED;
- PlayerInfo::Attribute getAttackLocation() const A_WARN_UNUSED;
+ int getAttackLocation() const A_WARN_UNUSED;
void processWalkResponse(Net::MessageIn &msg);
diff --git a/src/net/ea/specialhandler.cpp b/src/net/ea/specialhandler.cpp
index ba805e261..6f9b346a3 100644
--- a/src/net/ea/specialhandler.cpp
+++ b/src/net/ea/specialhandler.cpp
@@ -93,8 +93,7 @@ void SpecialHandler::processPlayerSkills(Net::MessageIn &msg)
msg.skip(24); // 0 unused
const int up = msg.readInt8();
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- skillId), level);
+ PlayerInfo::setStatBase(skillId, level);
if (skillDialog)
{
if (!skillDialog->updateSkill(skillId, range, up))
@@ -111,8 +110,7 @@ void SpecialHandler::processPlayerSkillUp(Net::MessageIn &msg)
const int range = msg.readInt16();
const int up = msg.readInt8();
- PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
- skillId), level);
+ PlayerInfo::setStatBase(skillId, level);
if (skillDialog)
{
if (!skillDialog->updateSkill(skillId, range, up))
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index dab32836f..01ab732e3 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -66,10 +66,9 @@ class PlayerHandler
virtual bool canCorrectAttributes() const = 0;
- virtual PlayerInfo::Attribute getJobLocation() const A_WARN_UNUSED = 0;
+ virtual int getJobLocation() const A_WARN_UNUSED = 0;
- virtual PlayerInfo::Attribute getAttackLocation()
- const A_WARN_UNUSED = 0;
+ virtual int getAttackLocation() const A_WARN_UNUSED = 0;
virtual Vector getDefaultWalkSpeed() const A_WARN_UNUSED = 0;
diff --git a/src/net/tmwa/questhandler.cpp b/src/net/tmwa/questhandler.cpp
index b0910cf7c..f819dfc16 100644
--- a/src/net/tmwa/questhandler.cpp
+++ b/src/net/tmwa/questhandler.cpp
@@ -22,6 +22,7 @@
#include "localplayer.h"
+#include "gui/skilldialog.h"
#include "gui/questswindow.h"
#include "net/tmwa/protocol.h"
@@ -78,6 +79,8 @@ void QuestHandler::processSetQuestVar(Net::MessageIn &msg A_UNUSED)
questsWindow->updateQuest(var, val);
questsWindow->rebuild(true);
}
+ if (skillDialog)
+ skillDialog->updateQuest(var, val);
}
void QuestHandler::processPlayerQuests(Net::MessageIn &msg A_UNUSED)
@@ -89,6 +92,8 @@ void QuestHandler::processPlayerQuests(Net::MessageIn &msg A_UNUSED)
const int val = msg.readInt32(); // value
if (questsWindow)
questsWindow->updateQuest(var, val);
+ if (skillDialog)
+ skillDialog->updateQuest(var, val);
}
if (questsWindow)
questsWindow->rebuild(false);
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index 5721d2d67..b54f6c671 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -89,7 +89,7 @@ void triggerStat(const int id, const std::string &changed,
// --- Attributes -------------------------------------------------------------
-int getAttribute(const Attribute id)
+int getAttribute(const int id)
{
const IntMap::const_iterator it = mData.mAttributes.find(id);
if (it != mData.mAttributes.end())
@@ -98,7 +98,7 @@ int getAttribute(const Attribute id)
return 0;
}
-void setAttribute(const Attribute id, const int value, const bool notify)
+void setAttribute(const int id, const int value, const bool notify)
{
const int old = mData.mAttributes[id];
mData.mAttributes[id] = value;
@@ -108,7 +108,7 @@ void setAttribute(const Attribute id, const int value, const bool notify)
// --- Stats ------------------------------------------------------------------
-int getStatBase(const Attribute id)
+int getStatBase(const int id)
{
const StatMap::const_iterator it = mData.mStats.find(id);
if (it != mData.mStats.end())
@@ -117,7 +117,7 @@ int getStatBase(const Attribute id)
return 0;
}
-void setStatBase(const Attribute id, const int value, const bool notify)
+void setStatBase(const int id, const int value, const bool notify)
{
const int old = mData.mStats[id].base;
mData.mStats[id].base = value;
@@ -125,7 +125,7 @@ void setStatBase(const Attribute id, const int value, const bool notify)
triggerStat(id, "base", old);
}
-int getStatMod(const Attribute id)
+int getStatMod(const int id)
{
const StatMap::const_iterator it = mData.mStats.find(id);
if (it != mData.mStats.end())
@@ -134,7 +134,7 @@ int getStatMod(const Attribute id)
return 0;
}
-void setStatMod(const Attribute id, const int value, const bool notify)
+void setStatMod(const int id, const int value, const bool notify)
{
const int old = mData.mStats[id].mod;
mData.mStats[id].mod = value;
@@ -142,7 +142,7 @@ void setStatMod(const Attribute id, const int value, const bool notify)
triggerStat(id, "mod", old);
}
-int getStatEffective(const Attribute id)
+int getStatEffective(const int id)
{
const StatMap::const_iterator it = mData.mStats.find(id);
if (it != mData.mStats.end())
@@ -151,7 +151,7 @@ int getStatEffective(const Attribute id)
return 0;
}
-std::pair<int, int> getStatExperience(const Attribute id)
+std::pair<int, int> getStatExperience(const int id)
{
const StatMap::const_iterator it = mData.mStats.find(id);
int a, b;
@@ -168,7 +168,7 @@ std::pair<int, int> getStatExperience(const Attribute id)
return std::pair<int, int>(a, b);
}
-void setStatExperience(const Attribute id, const int have,
+void setStatExperience(const int id, const int have,
const int need, const bool notify)
{
Stat &stat = mData.mStats[id];
@@ -299,21 +299,15 @@ void updateAttrs()
const int attr = Net::getPlayerHandler()->getAttackLocation();
if (attr != -1 && getStatBase(ATTACK_DELAY))
{
- setStatBase(static_cast<PlayerInfo::Attribute>(ATTACK_SPEED),
- getStatBase(static_cast<PlayerInfo::Attribute>(attr))
- * 1000 / getStatBase(
- static_cast<PlayerInfo::Attribute>(ATTACK_DELAY)), false);
- setStatMod(static_cast<PlayerInfo::Attribute>(ATTACK_SPEED),
- getStatMod(static_cast<PlayerInfo::Attribute>(attr))
- * 1000 / getStatBase(
- static_cast<PlayerInfo::Attribute>(ATTACK_DELAY)), true);
+ setStatBase(ATTACK_SPEED, getStatBase(attr) * 1000
+ / getStatBase(ATTACK_DELAY), false);
+ setStatMod(ATTACK_SPEED, getStatMod(attr) * 1000
+ / getStatBase(ATTACK_DELAY), true);
}
else
{
- setStatBase(static_cast<PlayerInfo::Attribute>(
- ATTACK_SPEED), 0, false);
- setStatMod(static_cast<PlayerInfo::Attribute>(
- ATTACK_SPEED), 0, true);
+ setStatBase(ATTACK_SPEED, 0, false);
+ setStatMod(ATTACK_SPEED, 0, true);
}
}
diff --git a/src/playerinfo.h b/src/playerinfo.h
index 09699bd6d..8bb3a6f1d 100644
--- a/src/playerinfo.h
+++ b/src/playerinfo.h
@@ -103,12 +103,12 @@ namespace PlayerInfo
/**
* Returns the value of the given attribute.
*/
- int getAttribute(const Attribute id) A_WARN_UNUSED;
+ int getAttribute(const int id) A_WARN_UNUSED;
/**
* Changes the value of the given attribute.
*/
- void setAttribute(const Attribute id, const int value,
+ void setAttribute(const int id, const int value,
const bool notify = true);
// --- Stats ------------------------------------------------------------------
@@ -116,45 +116,45 @@ namespace PlayerInfo
/**
* Returns the base value of the given stat.
*/
- int getStatBase(const Attribute id) A_WARN_UNUSED;
+ int getStatBase(const int id) A_WARN_UNUSED;
/**
* Changes the base value of the given stat.
*/
- void setStatBase(const Attribute id, const int value,
+ void setStatBase(const int id, const int value,
const bool notify = true);
/**
* Returns the modifier for the given stat.
*/
- int getStatMod(const Attribute id) A_WARN_UNUSED;
+ int getStatMod(const int id) A_WARN_UNUSED;
/**
* Changes the modifier for the given stat.
*/
- void setStatMod(const Attribute id, const int value,
+ void setStatMod(const int id, const int value,
const bool notify = true);
/**
* Returns the current effective value of the given stat. Effective is base
* + mod
*/
- int getStatEffective(const Attribute id) A_WARN_UNUSED;
+ int getStatEffective(const int id) A_WARN_UNUSED;
/**
* Changes the level of the given stat.
*/
- void setStatLevel(Attribute id, int value, bool notify = true);
+ void setStatLevel(int id, int value, bool notify = true);
/**
* Returns the experience of the given stat.
*/
- std::pair<int, int> getStatExperience(const Attribute id) A_WARN_UNUSED;
+ std::pair<int, int> getStatExperience(const int id) A_WARN_UNUSED;
/**
* Changes the experience of the given stat.
*/
- void setStatExperience(const Attribute id, const int have,
+ void setStatExperience(const int id, const int have,
const int need, const bool notify = true);
// --- Inventory / Equipment --------------------------------------------------
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index 27b6f45e7..93480fb63 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -135,11 +135,10 @@ void SpellManager::invoke(const int spellId)
if (spell->getCommandType() == TEXT_COMMAND_TEXT
|| (Net::getPlayerHandler()->canUseMagic()
- && PlayerInfo::getStatEffective(static_cast<PlayerInfo::Attribute>(
- SKILL_MAGIC)) >= static_cast<signed>(spell->getBaseLvl())
+ && PlayerInfo::getStatEffective(SKILL_MAGIC)
+ >= static_cast<signed>(spell->getBaseLvl())
&& PlayerInfo::getStatEffective(
- static_cast<PlayerInfo::Attribute>(spell->getSchool()))
- >= static_cast<signed>(spell->getSchoolLvl())
+ spell->getSchool()) >= static_cast<signed>(spell->getSchoolLvl())
&& PlayerInfo::getAttribute(PlayerInfo::MP) >= spell->getMana()))
{
const Being *const target = player_node->getTarget();