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/scripts.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/scripts.cpp')
-rw-r--r-- | engines/xeen/scripts.cpp | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index 91db032d79..cc42081f5c 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -1550,29 +1550,11 @@ bool Scripts::ifProc(int action, uint32 val, int mode, int charIndex) { break; case 19: { // Can player cast a given spell - - // Get the type of character - int category; - switch (ps._class) { - case CLASS_KNIGHT: - case CLASS_ARCHER: - category = 0; - break; - case CLASS_PALADIN: - case CLASS_CLERIC: - category = 1; - break; - case CLASS_BARBARIAN: - case CLASS_DRUID: - category = 2; - break; - default: - category = 0; - break; - } + SpellsCategory category = ps.getSpellsCategory(); + assert(category != SPELLCAT_INVALID); // Check if the character class can cast the particular spell - for (int idx = 0; idx < 39; ++idx) { + for (int idx = 0; idx < SPELLS_PER_CLASS; ++idx) { if (Res.SPELLS_ALLOWED[category][idx] == (int)val) { // Can cast it. Check if the player has it in their spellbook if (ps._spells[idx]) |