diff options
author | Paul Gilbert | 2018-03-19 18:32:07 -0400 |
---|---|---|
committer | Paul Gilbert | 2018-03-19 18:33:47 -0400 |
commit | 5645d63acdac555d987cb106bf1e84182c7ae52e (patch) | |
tree | 8b0758260830dd9fad8ece036742c75a5df4a3a0 | |
parent | ef593ed8e33891200f80410a5aef6bd3e87f0a0a (diff) | |
download | scummvm-rg350-5645d63acdac555d987cb106bf1e84182c7ae52e.tar.gz scummvm-rg350-5645d63acdac555d987cb106bf1e84182c7ae52e.tar.bz2 scummvm-rg350-5645d63acdac555d987cb106bf1e84182c7ae52e.zip |
XEEN: Standardize on a single SPELLS_PER_CLASS define
There was previous confusion because characters can have a maximum of
39 spells for their class. But the spell list for each class has
40 entries, of which the last one, #39, is always the 'No Spell' value
-rw-r--r-- | engines/xeen/character.cpp | 2 | ||||
-rw-r--r-- | engines/xeen/character.h | 5 | ||||
-rw-r--r-- | engines/xeen/debugger.cpp | 2 | ||||
-rw-r--r-- | engines/xeen/dialogs/dialogs_spells.cpp | 16 |
4 files changed, 12 insertions, 13 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp index 3776e51e5d..ba81852c50 100644 --- a/engines/xeen/character.cpp +++ b/engines/xeen/character.cpp @@ -134,7 +134,7 @@ void Character::synchronize(Common::Serializer &s) { } // Synchronize spell list - for (int i = 0; i < CHAR_MAX_SPELLS; ++i) + for (int i = 0; i < SPELLS_PER_CLASS; ++i) s.syncAsByte(_spells[i]); s.syncAsByte(_lloydMap); s.syncAsByte(_lloydPosition.x); diff --git a/engines/xeen/character.h b/engines/xeen/character.h index b37431a40f..9a757b56e2 100644 --- a/engines/xeen/character.h +++ b/engines/xeen/character.h @@ -34,8 +34,7 @@ namespace Xeen { #define INV_ITEMS_TOTAL 9 -#define CHAR_MAX_SPELLS 39 -#define SPELLS_PER_CLASS 40 +#define SPELLS_PER_CLASS 39 #define AWARDS_TOTAL 88 #define WARZONE_AWARD 9 @@ -125,7 +124,7 @@ public: int _tempAge; int _skills[18]; int _awards[128]; - bool _spells[CHAR_MAX_SPELLS]; + bool _spells[SPELLS_PER_CLASS]; int _lloydMap; Common::Point _lloydPosition; bool _hasSpells; diff --git a/engines/xeen/debugger.cpp b/engines/xeen/debugger.cpp index 21e58195d7..d5f1b40d29 100644 --- a/engines/xeen/debugger.cpp +++ b/engines/xeen/debugger.cpp @@ -95,7 +95,7 @@ bool Debugger::cmdSpells(int argc, const char **argv) { for (uint charIdx = 0; charIdx < party._activeParty.size(); ++charIdx) { Character &c = party._activeParty[charIdx]; - Common::fill(c._spells, c._spells + CHAR_MAX_SPELLS, true); + Common::fill(c._spells, c._spells + SPELLS_PER_CLASS, true); c._currentSp = 9999; } diff --git a/engines/xeen/dialogs/dialogs_spells.cpp b/engines/xeen/dialogs/dialogs_spells.cpp index 60c30e6813..b1890590b2 100644 --- a/engines/xeen/dialogs/dialogs_spells.cpp +++ b/engines/xeen/dialogs/dialogs_spells.cpp @@ -142,7 +142,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int XeenEngine::printMil(party._gold).c_str(), Res.GUILD_TEXT, c->_name.c_str())); } else { SpellsCategory category = c->getSpellsCategory(); - int spellIndex = (c->_currentSpell == -1) ? SPELLS_PER_CLASS - 1 : c->_currentSpell; + int spellIndex = (c->_currentSpell == -1) ? SPELLS_PER_CLASS : c->_currentSpell; int spellId = (category == SPELLCAT_INVALID) ? NO_SPELL : Res.SPELLS_ALLOWED[category][spellIndex]; windows[10].writeString(Common::String::format(Res.CAST_SPELL_DETAILS, @@ -286,11 +286,11 @@ const char *SpellsDialog::setSpellText(Character *c, int mode) { if (party._mazeId == 49 || party._mazeId == 37) { for (uint spellId = 0; spellId < TOTAL_SPELLS; ++spellId) { int idx = 0; - while (idx < CHAR_MAX_SPELLS && Res.SPELLS_ALLOWED[category][idx] != (int)spellId) + while (idx < SPELLS_PER_CLASS && Res.SPELLS_ALLOWED[category][idx] != (int)spellId) ++idx; // Handling if the spell is appropriate for the character's class - if (idx < CHAR_MAX_SPELLS) { + if (idx < SPELLS_PER_CLASS) { if (!c->_spells[idx] || (mode & 0x80)) { int cost = spells.calcSpellCost(Res.SPELLS_ALLOWED[category][idx], expenseFactor); _spells.push_back(SpellEntry(Common::String::format("\x3l%s\x3r\x9""000%u", @@ -304,10 +304,10 @@ const char *SpellsDialog::setSpellText(Character *c, int mode) { for (int spellId = Res.DARK_SPELL_RANGES[groupIndex][0]; spellId < Res.DARK_SPELL_RANGES[groupIndex][1]; ++spellId) { int idx = 0; - while (idx < SPELLS_PER_CLASS && Res.SPELLS_ALLOWED[category][idx] == + while (idx <= SPELLS_PER_CLASS && Res.SPELLS_ALLOWED[category][idx] == Res.DARK_SPELL_OFFSETS[category][spellId]); - if (idx < SPELLS_PER_CLASS) { + if (idx <= SPELLS_PER_CLASS) { if (!c->_spells[idx] || (mode & 0x80)) { int cost = spells.calcSpellCost(Res.SPELLS_ALLOWED[category][idx], expenseFactor); _spells.push_back(SpellEntry(Common::String::format("\x3l%s\x3r\x9""000%u", @@ -320,10 +320,10 @@ const char *SpellsDialog::setSpellText(Character *c, int mode) { for (int spellId = 0; spellId < 20; ++spellId) { int idx = 0; while (Res.CLOUDS_GUILD_SPELLS[party._mazeId - 28][spellId] != - (int)Res.SPELLS_ALLOWED[category][idx] && idx < SPELLS_PER_CLASS) + (int)Res.SPELLS_ALLOWED[category][idx] && idx <= SPELLS_PER_CLASS) ++idx; - if (idx < SPELLS_PER_CLASS) { + if (idx <= SPELLS_PER_CLASS) { if (!c->_spells[idx] || (mode & 0x80)) { int cost = spells.calcSpellCost(Res.SPELLS_ALLOWED[category][idx], expenseFactor); _spells.push_back(SpellEntry(Common::String::format("\x3l%s\x3r\x9""000%u", @@ -342,7 +342,7 @@ const char *SpellsDialog::setSpellText(Character *c, int mode) { if (c->getMaxSP() == 0) { return Res.NOT_A_SPELL_CASTER; } else { - for (int spellIndex = 0; spellIndex < CHAR_MAX_SPELLS; ++spellIndex) { + for (int spellIndex = 0; spellIndex < SPELLS_PER_CLASS; ++spellIndex) { if (c->_spells[spellIndex]) { int spellId = Res.SPELLS_ALLOWED[category][spellIndex]; int gemCost = Res.SPELL_GEM_COST[spellId]; |