[Scummvm-git-logs] scummvm master -> 60bb10e92bf90c75f6966c4793c4e123b29ab51d

dreammaster dreammaster at scummvm.org
Sat Mar 31 02:30:44 CEST 2018


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
eca76ea91e XEEN: Fix highlighting of character when Cast Spell dialog is opened
60bb10e92b XEEN: Fix to correct remember last caster when reopening Cast Spell dialog


Commit: eca76ea91ec0b932d90d20608db2f4c1b9aae1cf
    https://github.com/scummvm/scummvm/commit/eca76ea91ec0b932d90d20608db2f4c1b9aae1cf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-03-30T20:08:31-04:00

Commit Message:
XEEN: Fix highlighting of character when Cast Spell dialog is opened

Changed paths:
    engines/xeen/character.cpp
    engines/xeen/character.h
    engines/xeen/dialogs/dialogs_spells.cpp
    engines/xeen/interface.cpp
    engines/xeen/interface.h
    engines/xeen/party.h


diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index 333bad8..72d8ed6 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -37,6 +37,17 @@ void AttributePair::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+int CharacterArray::indexOf(const Character &c) {
+	for (uint idx = 0; idx < size(); ++idx) {
+		if ((*this)[idx] == c)
+			return idx;
+	}
+
+	return -1;
+}
+
+/*------------------------------------------------------------------------*/
+
 Character::Character(): _weapons(this), _armor(this), _accessories(this), _misc(this), _items(this) {
 	clear();
 	_faceSprites = nullptr;
diff --git a/engines/xeen/character.h b/engines/xeen/character.h
index b45cfaf..43531c7 100644
--- a/engines/xeen/character.h
+++ b/engines/xeen/character.h
@@ -166,6 +166,16 @@ public:
 	Character(const Character &src);
 
 	/**
+	 * Equality operator
+	 */
+	bool operator==(const Character &src) const { return src._rosterId == _rosterId; }
+
+	/**
+	 * Inequality operator
+	 */
+	bool operator!=(const Character &src) const { return src._rosterId != _rosterId; }
+
+	/**
 	 * Clears the data for a character
 	 */
 	void clear();
@@ -346,6 +356,14 @@ public:
 	void clearConditions();
 };
 
+class CharacterArray : public Common::Array<Character> {
+public:
+	/**
+	 * Returns the index of a given character in the array
+	 */
+	int indexOf(const Character &c);
+};
+
 } // End of namespace Xeen
 
 #endif /* XEEN_CHARACTER_H */
diff --git a/engines/xeen/dialogs/dialogs_spells.cpp b/engines/xeen/dialogs/dialogs_spells.cpp
index 21bd7e2..828281e 100644
--- a/engines/xeen/dialogs/dialogs_spells.cpp
+++ b/engines/xeen/dialogs/dialogs_spells.cpp
@@ -383,7 +383,6 @@ CastSpell::~CastSpell() {
 
 int CastSpell::show(XeenEngine *vm) {
 	Combat &combat = *vm->_combat;
-	Interface &intf = *vm->_interface;
 	Party &party = *vm->_party;
 	Spells &spells = *vm->_spells;
 	int charNum;
@@ -403,17 +402,19 @@ int CastSpell::show(XeenEngine *vm) {
 	}
 
 	Character *c = &party._activeParty[charNum];
-	intf.highlightChar(charNum);
-
 	return show(vm, c);
 }
 
 int CastSpell::show(XeenEngine *vm, Character *&c) {
+	Interface &intf = *vm->_interface;
 	Spells &spells = *vm->_spells;
 	CastSpell *dlg = new CastSpell(vm);
 	int spellId;
 	int result = -1;
 
+	// Highlight the character
+	intf.highlightChar(c);
+
 	do {
 		spellId = dlg->execute(c);
 
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index de343fe..648b01f 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -118,6 +118,12 @@ void PartyDrawer::highlightChar(int charId) {
 	}
 }
 
+void PartyDrawer::highlightChar(const Character *c) {
+	int charNum = _vm->_party->_activeParty.indexOf(*c);
+	if (charNum != -1)
+		highlightChar(charNum);
+}
+
 void PartyDrawer::unhighlightChar() {
 	Resources &res = *_vm->_resources;
 	Windows &windows = *_vm->_windows;
diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h
index bbc2a77..6de0449 100644
--- a/engines/xeen/interface.h
+++ b/engines/xeen/interface.h
@@ -71,8 +71,18 @@ public:
 
 	void drawParty(bool updateFlag);
 
+	/**
+	 * Highlights the specified character in the party display at the bottom of the screen
+	 * @param charId		Character number
+	 */
 	void highlightChar(int charId);
 
+	/**
+	 * Highlights the specified character in the party display at the bottom of the screen
+	 * @param c		Character to highlight
+	 */
+	void highlightChar(const Character *c);
+
 	void unhighlightChar();
 
 	void resetHighlight();
diff --git a/engines/xeen/party.h b/engines/xeen/party.h
index 23a9407..322ae2b 100644
--- a/engines/xeen/party.h
+++ b/engines/xeen/party.h
@@ -215,7 +215,7 @@ public:
 public:
 	// Other party related runtime data
 	Roster _roster;
-	Common::Array<Character> _activeParty;
+	CharacterArray _activeParty;
 	bool _newDay;
 	bool _isNight;
 	bool _stepped;


Commit: 60bb10e92bf90c75f6966c4793c4e123b29ab51d
    https://github.com/scummvm/scummvm/commit/60bb10e92bf90c75f6966c4793c4e123b29ab51d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-03-30T20:30:39-04:00

Commit Message:
XEEN: Fix to correct remember last caster when reopening Cast Spell dialog

Changed paths:
    engines/xeen/dialogs/dialogs_spells.cpp
    engines/xeen/dialogs/dialogs_spells.h
    engines/xeen/interface.cpp


diff --git a/engines/xeen/dialogs/dialogs_spells.cpp b/engines/xeen/dialogs/dialogs_spells.cpp
index 828281e..3645b2e 100644
--- a/engines/xeen/dialogs/dialogs_spells.cpp
+++ b/engines/xeen/dialogs/dialogs_spells.cpp
@@ -383,8 +383,10 @@ CastSpell::~CastSpell() {
 
 int CastSpell::show(XeenEngine *vm) {
 	Combat &combat = *vm->_combat;
+	Interface &intf = *vm->_interface;
 	Party &party = *vm->_party;
 	Spells &spells = *vm->_spells;
+	int result = 0, spellId = 0;
 	int charNum;
 
 	// Get which character is doing the casting
@@ -401,20 +403,11 @@ int CastSpell::show(XeenEngine *vm) {
 		}
 	}
 
-	Character *c = &party._activeParty[charNum];
-	return show(vm, c);
-}
-
-int CastSpell::show(XeenEngine *vm, Character *&c) {
-	Interface &intf = *vm->_interface;
-	Spells &spells = *vm->_spells;
-	CastSpell *dlg = new CastSpell(vm);
-	int spellId;
-	int result = -1;
-
 	// Highlight the character
+	Character *c = &party._activeParty[charNum];
 	intf.highlightChar(c);
 
+	CastSpell *dlg = new CastSpell(vm);
 	do {
 		spellId = dlg->execute(c);
 
@@ -481,6 +474,7 @@ int CastSpell::execute(Character *&c) {
 				if (_buttonValue < (int)party._activeParty.size()) {
 					c = &party._activeParty[_buttonValue];
 					intf.highlightChar(_buttonValue);
+					spells._lastCaster = _buttonValue;
 					redrawFlag = true;
 					break;
 				}
diff --git a/engines/xeen/dialogs/dialogs_spells.h b/engines/xeen/dialogs/dialogs_spells.h
index 6a4fe7a..c6e46c4 100644
--- a/engines/xeen/dialogs/dialogs_spells.h
+++ b/engines/xeen/dialogs/dialogs_spells.h
@@ -93,7 +93,6 @@ private:
 	void loadButtons();
 public:
 	static int show(XeenEngine *vm);
-	static int show(XeenEngine *vm, Character *&c);
 };
 
 class SpellOnWho : public ButtonContainer {
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 648b01f..03e6797 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -527,7 +527,7 @@ void Interface::perform() {
 			spells._lastCaster >= (int)party._activeParty.size()) ?
 			(int)party._activeParty.size() - 1 : spells._lastCaster];
 
-		int result = CastSpell::show(_vm, c);
+		int result = CastSpell::show(_vm);
 
 		if (result == 1) {
 			chargeStep();





More information about the Scummvm-git-logs mailing list