[Scummvm-git-logs] scummvm master -> 5645d63acdac555d987cb106bf1e84182c7ae52e

dreammaster dreammaster at scummvm.org
Mon Mar 19 23:40:17 CET 2018


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

Summary:
5645d63acd XEEN: Standardize on a single SPELLS_PER_CLASS define


Commit: 5645d63acdac555d987cb106bf1e84182c7ae52e
    https://github.com/scummvm/scummvm/commit/5645d63acdac555d987cb106bf1e84182c7ae52e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-03-19T18:33:47-04:00

Commit Message:
XEEN: Standardize on a single SPELLS_PER_CLASS define

There was previous confusion because characters can have a maximum of
39 spells for their class. But the spell list for each class has
40 entries, of which the last one, #39, is always the 'No Spell' value

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


diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index 3776e51..ba81852 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -134,7 +134,7 @@ void Character::synchronize(Common::Serializer &s) {
 	}
 
 	// Synchronize spell list
-	for (int i = 0; i < CHAR_MAX_SPELLS; ++i)
+	for (int i = 0; i < SPELLS_PER_CLASS; ++i)
 		s.syncAsByte(_spells[i]);
 	s.syncAsByte(_lloydMap);
 	s.syncAsByte(_lloydPosition.x);
diff --git a/engines/xeen/character.h b/engines/xeen/character.h
index b37431a..9a757b5 100644
--- a/engines/xeen/character.h
+++ b/engines/xeen/character.h
@@ -34,8 +34,7 @@
 namespace Xeen {
 
 #define INV_ITEMS_TOTAL 9
-#define CHAR_MAX_SPELLS 39
-#define SPELLS_PER_CLASS 40
+#define SPELLS_PER_CLASS 39
 #define AWARDS_TOTAL 88
 #define WARZONE_AWARD 9
 
@@ -125,7 +124,7 @@ public:
 	int _tempAge;
 	int _skills[18];
 	int _awards[128];
-	bool _spells[CHAR_MAX_SPELLS];
+	bool _spells[SPELLS_PER_CLASS];
 	int _lloydMap;
 	Common::Point _lloydPosition;
 	bool _hasSpells;
diff --git a/engines/xeen/debugger.cpp b/engines/xeen/debugger.cpp
index 21e5819..d5f1b40 100644
--- a/engines/xeen/debugger.cpp
+++ b/engines/xeen/debugger.cpp
@@ -95,7 +95,7 @@ bool Debugger::cmdSpells(int argc, const char **argv) {
 
 	for (uint charIdx = 0; charIdx < party._activeParty.size(); ++charIdx) {
 		Character &c = party._activeParty[charIdx];
-		Common::fill(c._spells, c._spells + CHAR_MAX_SPELLS, true);
+		Common::fill(c._spells, c._spells + SPELLS_PER_CLASS, true);
 		c._currentSp = 9999;
 	}
 
diff --git a/engines/xeen/dialogs/dialogs_spells.cpp b/engines/xeen/dialogs/dialogs_spells.cpp
index 60c30e6..b189059 100644
--- a/engines/xeen/dialogs/dialogs_spells.cpp
+++ b/engines/xeen/dialogs/dialogs_spells.cpp
@@ -142,7 +142,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int
 							XeenEngine::printMil(party._gold).c_str(), Res.GUILD_TEXT, c->_name.c_str()));
 					} else {
 						SpellsCategory category = c->getSpellsCategory();
-						int spellIndex = (c->_currentSpell == -1) ? SPELLS_PER_CLASS - 1 : c->_currentSpell;
+						int spellIndex = (c->_currentSpell == -1) ? SPELLS_PER_CLASS : c->_currentSpell;
 						int spellId = (category == SPELLCAT_INVALID) ? NO_SPELL : Res.SPELLS_ALLOWED[category][spellIndex];
 
 						windows[10].writeString(Common::String::format(Res.CAST_SPELL_DETAILS,
@@ -286,11 +286,11 @@ const char *SpellsDialog::setSpellText(Character *c, int mode) {
 			if (party._mazeId == 49 || party._mazeId == 37) {
 				for (uint spellId = 0; spellId < TOTAL_SPELLS; ++spellId) {
 					int idx = 0;
-					while (idx < CHAR_MAX_SPELLS && Res.SPELLS_ALLOWED[category][idx] != (int)spellId)
+					while (idx < SPELLS_PER_CLASS && Res.SPELLS_ALLOWED[category][idx] != (int)spellId)
 						++idx;
 
 					// Handling if the spell is appropriate for the character's class
-					if (idx < CHAR_MAX_SPELLS) {
+					if (idx < SPELLS_PER_CLASS) {
 						if (!c->_spells[idx] || (mode & 0x80)) {
 							int cost = spells.calcSpellCost(Res.SPELLS_ALLOWED[category][idx], expenseFactor);
 							_spells.push_back(SpellEntry(Common::String::format("\x3l%s\x3r\x9""000%u",
@@ -304,10 +304,10 @@ const char *SpellsDialog::setSpellText(Character *c, int mode) {
 				for (int spellId = Res.DARK_SPELL_RANGES[groupIndex][0];
 						spellId < Res.DARK_SPELL_RANGES[groupIndex][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]);
 
-					if (idx < SPELLS_PER_CLASS) {
+					if (idx <= SPELLS_PER_CLASS) {
 						if (!c->_spells[idx] || (mode & 0x80)) {
 							int cost = spells.calcSpellCost(Res.SPELLS_ALLOWED[category][idx], expenseFactor);
 							_spells.push_back(SpellEntry(Common::String::format("\x3l%s\x3r\x9""000%u",
@@ -320,10 +320,10 @@ const char *SpellsDialog::setSpellText(Character *c, int mode) {
 				for (int spellId = 0; spellId < 20; ++spellId) {
 					int idx = 0;
 					while (Res.CLOUDS_GUILD_SPELLS[party._mazeId - 28][spellId] !=
-						(int)Res.SPELLS_ALLOWED[category][idx] && idx < SPELLS_PER_CLASS)
+						(int)Res.SPELLS_ALLOWED[category][idx] && idx <= SPELLS_PER_CLASS)
 						++idx;
 
-					if (idx < SPELLS_PER_CLASS) {
+					if (idx <= SPELLS_PER_CLASS) {
 						if (!c->_spells[idx] || (mode & 0x80)) {
 							int cost = spells.calcSpellCost(Res.SPELLS_ALLOWED[category][idx], expenseFactor);
 							_spells.push_back(SpellEntry(Common::String::format("\x3l%s\x3r\x9""000%u",
@@ -342,7 +342,7 @@ const char *SpellsDialog::setSpellText(Character *c, int mode) {
 		if (c->getMaxSP() == 0) {
 			return Res.NOT_A_SPELL_CASTER;
 		} else {
-			for (int spellIndex = 0; spellIndex < CHAR_MAX_SPELLS; ++spellIndex) {
+			for (int spellIndex = 0; spellIndex < SPELLS_PER_CLASS; ++spellIndex) {
 				if (c->_spells[spellIndex]) {
 					int spellId = Res.SPELLS_ALLOWED[category][spellIndex];
 					int gemCost = Res.SPELL_GEM_COST[spellId];





More information about the Scummvm-git-logs mailing list