Skip to content

Commit

Permalink
XEEN: Fix mode change across display of CastSpell dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Feb 27, 2015
1 parent 19007ba commit c069a7f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
17 changes: 9 additions & 8 deletions engines/xeen/dialogs_spells.cpp
Expand Up @@ -435,15 +435,15 @@ const char *SpellsDialog::setSpellText(Character *c, int isCasting) {

/*------------------------------------------------------------------------*/

int CastSpell::show(XeenEngine *vm, int mode) {
int CastSpell::show(XeenEngine *vm) {
Combat &combat = *vm->_combat;
Interface &intf = *vm->_interface;
Party &party = *vm->_party;
Spells &spells = *vm->_spells;
int charNum;

// Get which character is doing the casting
if (mode == MODE_COMBAT) {
if (vm->_mode == MODE_COMBAT) {
charNum = combat._whosTurn;
} else if (spells._lastCaster >= 0 && spells._lastCaster < (int)party._activeParty.size()) {
charNum = spells._lastCaster;
Expand All @@ -460,29 +460,30 @@ int CastSpell::show(XeenEngine *vm, int mode) {
intf.highlightChar(charNum);

CastSpell *dlg = new CastSpell(vm);
int spellId = dlg->execute(c, mode);
int spellId = dlg->execute(c);
delete dlg;

return spellId;
}

int CastSpell::show(XeenEngine *vm, Character *&c, int mode) {
int CastSpell::show(XeenEngine *vm, Character *&c) {
CastSpell *dlg = new CastSpell(vm);
int spellId = dlg->execute(c, mode);
int spellId = dlg->execute(c);
delete dlg;

return spellId;
}

int CastSpell::execute(Character *&c, int mode) {
int CastSpell::execute(Character *&c) {
EventsManager &events = *_vm->_events;
Interface &intf = *_vm->_interface;
Party &party = *_vm->_party;
Screen &screen = *_vm->_screen;
Spells &spells = *_vm->_spells;
Window &w = screen._windows[10];

Mode oldMode = (Mode)mode;
Mode oldMode = _vm->_mode;
_vm->_mode = MODE_3;

w.open();
loadButtons();
Expand All @@ -503,7 +504,6 @@ int CastSpell::execute(Character *&c, int mode) {
drawButtons(&screen);
w.update();

_vm->_mode = MODE_3;
redrawFlag = false;
}

Expand Down Expand Up @@ -565,6 +565,7 @@ int CastSpell::execute(Character *&c, int mode) {
if (_vm->shouldQuit())
spellId = -1;

_vm->_mode = oldMode;
return spellId;
}

Expand Down
6 changes: 3 additions & 3 deletions engines/xeen/dialogs_spells.h
Expand Up @@ -65,12 +65,12 @@ class CastSpell : public ButtonContainer {

CastSpell(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}

int execute(Character *&c, int mode);
int execute(Character *&c);

void loadButtons();
public:
static int show(XeenEngine *vm, int mode);
static int show(XeenEngine *vm, Character *&c, int mode);
static int show(XeenEngine *vm);
static int show(XeenEngine *vm, Character *&c);
};

} // End of namespace Xeen
Expand Down
7 changes: 5 additions & 2 deletions engines/xeen/interface.cpp
Expand Up @@ -531,7 +531,7 @@ void Interface::perform() {
spells._lastCaster >= (int)party._activeParty.size()) ?
(int)party._activeParty.size() - 1 : spells._lastCaster];
do {
int spellId = CastSpell::show(_vm, c, _vm->_mode);
int spellId = CastSpell::show(_vm, c);
if (spellId == -1 || c == nullptr)
break;

Expand Down Expand Up @@ -1975,10 +1975,13 @@ void Interface::doCombat() {

case Common::KEYCODE_c: {
// Cast spell
int spellId = CastSpell::show(_vm, _vm->_mode);
int spellId = CastSpell::show(_vm);
if (spellId != -1) {
Character *c = combat._combatParty[combat._whosTurn];
spells.castSpell(c, spellId);
nextChar();
} else {
highlightChar(combat._combatParty[combat._whosTurn]->_rosterId);
}
break;
}
Expand Down

0 comments on commit c069a7f

Please sign in to comment.