diff options
author | Ira Rice <irarice@gmail.com> | 2008-11-02 01:23:14 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-11-02 01:23:14 +0000 |
commit | d41605e5aff79d26075a7ddbc9e6c021b9a5c35b (patch) | |
tree | 0b1f2c3a2127fd505090c25aaf51e00831ddd9eb /src/gui/skill.cpp | |
parent | 4ce57a9faccce077c21596f441a6683a832c0f04 (diff) | |
download | mana-client-d41605e5aff79d26075a7ddbc9e6c021b9a5c35b.tar.gz mana-client-d41605e5aff79d26075a7ddbc9e6c021b9a5c35b.tar.bz2 mana-client-d41605e5aff79d26075a7ddbc9e6c021b9a5c35b.tar.xz mana-client-d41605e5aff79d26075a7ddbc9e6c021b9a5c35b.zip |
Merged another fix from TMW for the new skill dialogue, which makes it so that if a skill is unknown, it doesn't
crash the client (it doesn't print garbage, like fate claims).
Diffstat (limited to 'src/gui/skill.cpp')
-rw-r--r-- | src/gui/skill.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 32c961bd..4296c506 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -80,14 +80,21 @@ public: virtual void update(void) { + static const SkillInfo fakeSkillInfo = { "???", false }; + mEntriesNr = mDialog->getSkills().size(); resize(); for (int i = 0; i < mEntriesNr; i++) { SKILL *skill = mDialog->getSkills()[i]; - SkillInfo *info = &skill_db[skill->id]; + SkillInfo const *info; char tmp[128]; + if (skill->id >= 0 && (unsigned int) skill->id < skill_db.size()) + info = &skill_db[skill->id]; + else + info = &fakeSkillInfo; + sprintf(tmp, "%c%s", info->modifiable? ' ' : '*', info->name.c_str()); gcn::Label *name_label = new gcn::Label(std::string(tmp)); @@ -188,9 +195,18 @@ void SkillDialog::update() int selectedSkill = mTable.getSelectedRow(); - mIncButton->setEnabled(selectedSkill > -1 - && skill_db[mSkillList[selectedSkill]->id].modifiable - && player_node->mSkillPoint > 0); + if (selectedSkill >= 0) { + int skillId = mSkillList[selectedSkill]->id; + bool modifiable; + + if (skillId >= 0 && (unsigned int) skillId < skill_db.size()) + modifiable = skill_db[skillId].modifiable; + else + modifiable = false; + + mIncButton->setEnabled(modifiable && player_node->mSkillPoint > 0); + } else + mIncButton->setEnabled(false); mTableModel->update(); } |