summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-26 15:54:29 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-26 15:54:29 +0300
commitb462762ae88e52ba18a0610c62a9dda6ac89d32d (patch)
treedc5d865703fd06b7c9bdc218f74301eec4cf77e0
parent5190fe2cdac7c259d96619e4686f8543bdc96af4 (diff)
downloadplus-b462762ae88e52ba18a0610c62a9dda6ac89d32d.tar.gz
plus-b462762ae88e52ba18a0610c62a9dda6ac89d32d.tar.bz2
plus-b462762ae88e52ba18a0610c62a9dda6ac89d32d.tar.xz
plus-b462762ae88e52ba18a0610c62a9dda6ac89d32d.zip
Split skills and stats.
-rw-r--r--src/game.cpp1
-rw-r--r--src/gui/skilldialog.cpp22
-rw-r--r--src/net/ea/skillhandler.cpp8
-rw-r--r--src/playerinfo.cpp19
-rw-r--r--src/playerinfo.h7
5 files changed, 38 insertions, 19 deletions
diff --git a/src/game.cpp b/src/game.cpp
index eb1d573e6..7645a669b 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -388,6 +388,7 @@ Game::Game():
// Create the viewport
viewport = new Viewport;
viewport->setSize(mainGraphics->mWidth, mainGraphics->mHeight);
+ PlayerInfo::clear();
gcn::Container *const top = static_cast<gcn::Container*>(gui->getTop());
if (top)
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index b0e3d8e91..39be5eea7 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -662,7 +662,7 @@ void SkillDialog::updateQuest(const int var, const int val)
SkillInfo *const info = it->second;
if (info)
{
- PlayerInfo::setStatBase(id, val);
+ PlayerInfo::setSkillLevel(id, val);
info->level = val;
info->update();
}
@@ -699,11 +699,10 @@ SkillInfo::~SkillInfo()
void SkillInfo::update()
{
- const int baseLevel = PlayerInfo::getStatBase(id);
- const int effLevel = PlayerInfo::getStatEffective(id);
+ const int baseLevel = PlayerInfo::getSkillLevel(id);
const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
- if (!modifiable && baseLevel == 0 && effLevel == 0 && exp.second == 0)
+ if (!modifiable && baseLevel == 0 && exp.second == 0)
{
if (visible)
{
@@ -717,18 +716,11 @@ void SkillInfo::update()
const bool updateVisibility = !visible;
visible = true;
- if (effLevel != baseLevel)
- {
- skillLevel = strprintf(_("Lvl: %d (%+d)"), baseLevel,
- effLevel - baseLevel);
- }
+ if (baseLevel == 0)
+ skillLevel.clear();
else
- {
- if (baseLevel == 0)
- skillLevel.clear();
- else
- skillLevel = strprintf(_("Lvl: %d"), baseLevel);
- }
+ skillLevel = strprintf(_("Lvl: %d"), baseLevel);
+
level = baseLevel;
skillLevelWidth = -1;
diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp
index 35a809ac9..51dc85461 100644
--- a/src/net/ea/skillhandler.cpp
+++ b/src/net/ea/skillhandler.cpp
@@ -93,10 +93,10 @@ void SkillHandler::processPlayerSkills(Net::MessageIn &msg)
const int range = msg.readInt16();
msg.skip(24); // 0 unused
const int up = msg.readInt8();
- const int oldLevel = PlayerInfo::getStatBase(skillId);
+ const int oldLevel = PlayerInfo::getSkillLevel(skillId);
if (oldLevel && oldLevel != level)
updateSkill = skillId;
- PlayerInfo::setStatBase(skillId, level);
+ PlayerInfo::setSkillLevel(skillId, level);
if (skillDialog)
{
if (!skillDialog->updateSkill(skillId, range, up))
@@ -115,9 +115,9 @@ void SkillHandler::processPlayerSkillUp(Net::MessageIn &msg)
const int range = msg.readInt16();
const int up = msg.readInt8();
- if (skillDialog && PlayerInfo::getStatBase(skillId) != level)
+ if (skillDialog && PlayerInfo::getSkillLevel(skillId) != level)
skillDialog->playUpdateEffect(skillId);
- PlayerInfo::setStatBase(skillId, level);
+ PlayerInfo::setSkillLevel(skillId, level);
if (skillDialog)
{
if (!skillDialog->updateSkill(skillId, range, up))
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index b54f6c671..af4ed6837 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -106,6 +106,20 @@ void setAttribute(const int id, const int value, const bool notify)
triggerAttr(id, old);
}
+int getSkillLevel(const int id)
+{
+ const IntMap::const_iterator it = mData.mSkills.find(id);
+ if (it != mData.mSkills.end())
+ return it->second;
+ else
+ return 0;
+}
+
+void setSkillLevel(const int id, const int value)
+{
+ mData.mSkills[id] = value;
+}
+
// --- Stats ------------------------------------------------------------------
int getStatBase(const int id)
@@ -367,6 +381,11 @@ void deinit()
mListener = nullptr;
}
+void clear()
+{
+ mData.mSkills.clear();
+}
+
bool isTalking()
{
return NpcDialog::isActive() || NpcPostDialog::isActive()
diff --git a/src/playerinfo.h b/src/playerinfo.h
index 8bb3a6f1d..d96e3e126 100644
--- a/src/playerinfo.h
+++ b/src/playerinfo.h
@@ -49,6 +49,7 @@ struct PlayerInfoBackend final
{
IntMap mAttributes;
StatMap mStats;
+ IntMap mSkills;
};
class Equipment;
@@ -111,6 +112,10 @@ namespace PlayerInfo
void setAttribute(const int id, const int value,
const bool notify = true);
+ int getSkillLevel(const int id) A_WARN_UNUSED;
+
+ void setSkillLevel(const int id, const int value);
+
// --- Stats ------------------------------------------------------------------
/**
@@ -169,6 +174,8 @@ namespace PlayerInfo
*/
void clearInventory();
+ void clear();
+
/**
* Changes the inventory item at the given slot.
*/