diff options
author | Fate <fate.tmw@googlemail.com> | 2008-11-01 23:56:14 +0000 |
---|---|---|
committer | Fate <fate.tmw@googlemail.com> | 2008-11-01 23:56:14 +0000 |
commit | 8c54f034a288168cc191410b366889f37255ab21 (patch) | |
tree | 11d82201d0a7697a85a606a5780c29460f3aabf7 /src/gui | |
parent | 8f1bf397990729c3a807bbbe0b643bc97446c923 (diff) | |
download | mana-client-8c54f034a288168cc191410b366889f37255ab21.tar.gz mana-client-8c54f034a288168cc191410b366889f37255ab21.tar.bz2 mana-client-8c54f034a288168cc191410b366889f37255ab21.tar.xz mana-client-8c54f034a288168cc191410b366889f37255ab21.zip |
* Report unmapped skill names as `Mystery Skill' (rather than random characters)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/skill.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index c753ee1a..116e1860 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -81,14 +81,22 @@ public: virtual void update(void) { + static const SkillInfo fakeSkillInfo = { "Mystery Skill", 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)); @@ -189,9 +197,19 @@ 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(); } |