From f30e96f18eafc9c6cb7f19a3325de3aa3252fea0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 18 Mar 2018 22:30:30 -0400 Subject: XEEN: Fix crash on Cast Spell dialog for non-spell casters --- engines/xeen/dialogs/dialogs_spells.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/xeen/dialogs/dialogs_spells.cpp b/engines/xeen/dialogs/dialogs_spells.cpp index c11a9cfc0a..60c30e6813 100644 --- a/engines/xeen/dialogs/dialogs_spells.cpp +++ b/engines/xeen/dialogs/dialogs_spells.cpp @@ -143,7 +143,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int } else { SpellsCategory category = c->getSpellsCategory(); int spellIndex = (c->_currentSpell == -1) ? SPELLS_PER_CLASS - 1 : c->_currentSpell; - int spellId = Res.SPELLS_ALLOWED[category][spellIndex]; + int spellId = (category == SPELLCAT_INVALID) ? NO_SPELL : Res.SPELLS_ALLOWED[category][spellIndex]; windows[10].writeString(Common::String::format(Res.CAST_SPELL_DETAILS, c->_name.c_str(), spells._spellNames[spellId].c_str(), @@ -441,9 +441,9 @@ int CastSpell::execute(Character *&c) { do { if (redrawFlag) { SpellsCategory category = c->getSpellsCategory(); - assert(category != SPELLCAT_INVALID); + int spellIndex = c->_currentSpell != -1 ? c->_currentSpell : 39; - spellId = Res.SPELLS_ALLOWED[category][spellIndex]; + spellId = (category == SPELLCAT_INVALID) ? NO_SPELL : Res.SPELLS_ALLOWED[category][spellIndex]; int gemCost = Res.SPELL_GEM_COST[spellId]; int spCost = spells.calcSpellPoints(spellId, c->getCurrentLevel()); -- cgit v1.2.3