Skip to content

Commit

Permalink
XEEN: FIxes for Dark Side & Swords spell listing
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Apr 23, 2018
1 parent dd15251 commit db8f9bc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
39 changes: 34 additions & 5 deletions engines/xeen/dialogs/dialogs_spells.cpp
Expand Up @@ -30,6 +30,14 @@

namespace Xeen {

// FIXME: This new array for Swords isn't worth regenerating the xeen.ccs file over, but it could be
// moved in if there's any cause in future to regenerate the file for other reasons
const int SWORDS_SPELL_RANGES[12][2] = {
{ 0, 20 }, { 16, 35 }, { 27, 39 }, { 29, 39 },
{ 0, 17 }, { 14, 34 }, { 26, 39 }, { 29, 39 },
{ 0, 20 }, { 16, 35 }, { 27, 39 }, {29, 39 }
};

Character *SpellsDialog::show(XeenEngine *vm, ButtonContainer *priorDialog,
Character *c, SpellDialogMode mode) {
SpellsDialog *dlg = new SpellsDialog(vm);
Expand Down Expand Up @@ -283,7 +291,7 @@ const char *SpellsDialog::setSpellText(Character *c, int mode) {

if ((mode & 0x7f) == 0) {
if (category != SPELLCAT_INVALID) {
if (party._mazeId == 49 || party._mazeId == 37) {
if (_vm->getGameID() != GType_Swords && (party._mazeId == 49 || party._mazeId == 37)) {
for (uint spellId = 0; spellId < TOTAL_SPELLS; ++spellId) {
int idx = 0;
while (idx < SPELLS_PER_CLASS && Res.SPELLS_ALLOWED[category][idx] != (int)spellId)
Expand All @@ -300,11 +308,32 @@ const char *SpellsDialog::setSpellText(Character *c, int mode) {
}
}
} else if (ccNum) {
int groupIndex = (party._mazeId - 29) / 2;
for (int spellId = Res.DARK_SPELL_RANGES[groupIndex][0];
spellId < Res.DARK_SPELL_RANGES[groupIndex][1]; ++spellId) {
const int *RANGE;

if (_vm->getGameID() == GType_Swords) {
// Set subset of spells to sell in each Swords of Xeen guild
int groupIndex;
switch (party._mazeId) {
case 92:
groupIndex = 1;
break;
case 63:
groupIndex = 2;
break;
case 53:
default:
groupIndex = 0;
break;
}
RANGE = SWORDS_SPELL_RANGES[category * 4 + groupIndex];
} else {
int groupIndex = (party._mazeId - 29) / 2;
RANGE = Res.DARK_SPELL_RANGES[category * 4 + groupIndex];
}

for (int spellId = RANGE[0]; spellId < RANGE[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])
++idx;

Expand Down
1 change: 0 additions & 1 deletion engines/xeen/resources.h
Expand Up @@ -240,7 +240,6 @@ class Resources {
int CLOUDS_GUILD_SPELLS[5][20];
int DARK_SPELL_OFFSETS[3][39];
int DARK_SPELL_RANGES[12][2];
int SPELL_LEVEL_OFFSETS[3][39];
int SPELL_GEM_COST[77];
const char *NOT_A_SPELL_CASTER;
const char *SPELLS_LEARNED_ALL;
Expand Down

0 comments on commit db8f9bc

Please sign in to comment.