diff options
author | Paul Gilbert | 2018-03-18 20:02:45 -0400 |
---|---|---|
committer | Paul Gilbert | 2018-03-18 20:02:45 -0400 |
commit | 500ed10658001ccb55578a59d245ee2bfda63385 (patch) | |
tree | 143646496271cf417c069fdc68010225172aba1c /engines/xeen/party.cpp | |
parent | 23fd97c99a650cf2e99df72a74326520b9347fc7 (diff) | |
download | scummvm-rg350-500ed10658001ccb55578a59d245ee2bfda63385.tar.gz scummvm-rg350-500ed10658001ccb55578a59d245ee2bfda63385.tar.bz2 scummvm-rg350-500ed10658001ccb55578a59d245ee2bfda63385.zip |
XEEN: Add an enum SpellsCategory enum, code simplification using it
Diffstat (limited to 'engines/xeen/party.cpp')
-rw-r--r-- | engines/xeen/party.cpp | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index 8e94c939c3..839dc41b10 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -906,26 +906,11 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int ps._conditions[takeVal] = 0; break; case 19: { - int idx2 = 0; - switch (ps._class) { - case CLASS_PALADIN: - case CLASS_CLERIC: - idx2 = 0; - break; - case CLASS_ARCHER: - case CLASS_SORCERER: - idx2 = 1; - break; - case CLASS_DRUID: - case CLASS_RANGER: - idx2 = 2; - break; - default: - break; - } + SpellsCategory category = ps.getSpellsCategory(); + assert(category != SPELLCAT_INVALID); - for (int idx = 0; idx < 39; ++idx) { - if (Res.SPELLS_ALLOWED[idx2][idx] == (int)takeVal) { + for (int idx = 0; idx < SPELLS_PER_CLASS; ++idx) { + if (Res.SPELLS_ALLOWED[category][idx] == (int)takeVal) { ps._spells[idx] = false; break; } @@ -1175,26 +1160,11 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int ps._currentHp = 0; break; case 19: { - int idx2 = 0; - switch (ps._class) { - case CLASS_PALADIN: - case CLASS_CLERIC: - idx2 = 0; - break; - case CLASS_ARCHER: - case CLASS_SORCERER: - idx2 = 1; - break; - case CLASS_DRUID: - case CLASS_RANGER: - idx2 = 2; - break; - default: - break; - } + SpellsCategory category = ps.getSpellsCategory(); + assert(category != SPELLCAT_INVALID); - for (int idx = 0; idx < 39; ++idx) { - if (Res.SPELLS_ALLOWED[idx2][idx] == (int)giveVal) { + for (int idx = 0; idx < SPELLS_PER_CLASS; ++idx) { + if (Res.SPELLS_ALLOWED[category][idx] == (int)giveVal) { ps._spells[idx] = true; intf.spellFX(&ps); break; |