diff options
| -rw-r--r-- | engines/xeen/character.cpp | 15 | ||||
| -rw-r--r-- | engines/xeen/character.h | 9 | ||||
| -rw-r--r-- | engines/xeen/locations.cpp | 6 | 
3 files changed, 20 insertions, 10 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp index 29b8dcb94a..8a6dd14c42 100644 --- a/engines/xeen/character.cpp +++ b/engines/xeen/character.cpp @@ -682,7 +682,7 @@ void Character::clear() {  	_birthDay = 0;  	_tempAge = 0;  	Common::fill(&_skills[0], &_skills[18], 0); -	Common::fill(&_awards[0], &_awards[128], false); +	Common::fill(&_awards[0], &_awards[128], 0);  	Common::fill(&_spells[0], &_spells[39], 0);  	_lloydMap = 0;  	_hasSpells = false; @@ -748,13 +748,16 @@ void Character::synchronize(Common::Serializer &s) {  	for (int idx = 0; idx < 18; ++idx)  		s.syncAsByte(_skills[idx]); -	// Synchronize character awards +	// Synchronize character awards. The original packed awards 64..127 in the +	// upper nibble of the first 64 bytes. Except for award 9, which was a full +	// byte counter counting the number of times the warzone was awarded  	for (int idx = 0; idx < 64; ++idx) { -		byte b = (_awards[idx] ? 1 : 0) | (_awards[idx + 64] ? 0x10 : 0); +		byte b = (idx == WARZONE_AWARD) ? _awards[idx] :			 +			(_awards[idx] ? 0x1 : 0) | (_awards[idx + 64] ? 0x10 : 0);  		s.syncAsByte(b);  		if (s.isLoading()) { -			_awards[idx] = (b & 0xF) != 0; -			_awards[idx + 64] = (b & 0xF0) != 0; +			_awards[idx] = (idx == WARZONE_AWARD) ? b : b & 0xF; +			_awards[idx + 64] = (idx == WARZONE_AWARD) ? 0 : (b >> 4) & 0xf;  		}  	} @@ -1041,7 +1044,7 @@ void Character::setAward(int awardId, bool value) {  	else if (awardId == 81)  		v = 127; -	_awards[v] = value; +	_awards[v] = value ? 1 : 0;  }  bool Character::hasAward(int awardId) const { diff --git a/engines/xeen/character.h b/engines/xeen/character.h index c16ae6addb..c19cfef4fc 100644 --- a/engines/xeen/character.h +++ b/engines/xeen/character.h @@ -35,6 +35,7 @@ namespace Xeen {  #define INV_ITEMS_TOTAL 9  #define MAX_SPELLS_PER_CLASS 39  #define AWARDS_TOTAL 88 +#define WARZONE_AWARD 9  enum BonusFlags {  	ITEMFLAG_BONUS_MASK = 0xBF, ITEMFLAG_CURSED = 0x40, ITEMFLAG_BROKEN = 0x80 @@ -288,7 +289,7 @@ public:  	uint _birthDay;  	int _tempAge;  	int _skills[18]; -	bool _awards[128]; +	int _awards[128];  	int _spells[MAX_SPELLS_PER_CLASS];  	int _lloydMap;  	Common::Point _lloydPosition; @@ -372,8 +373,14 @@ public:  	bool noActions(); +	/** +	 * Sets an award status +	 */  	void setAward(int awardId, bool value); +	/** +	 * Returns true if a character has a given award +	 */  	bool hasAward(int awardId) const;  	int getArmorClass(bool baseOnly = false) const; diff --git a/engines/xeen/locations.cpp b/engines/xeen/locations.cpp index e11f3daa6d..76c18399e9 100644 --- a/engines/xeen/locations.cpp +++ b/engines/xeen/locations.cpp @@ -1125,11 +1125,11 @@ int ArenaLocation::show() {  		// Give each character the award  		for (uint idx = 0; idx < party._activeParty.size(); ++idx) { -			party._activeParty[idx]._awards[9]++; +			party._activeParty[idx]._awards[WARZONE_AWARD]++;  		}  		Common::String format = map._events._text[3]; -		Common::String count = Common::String::format("%05u", party._activeParty[0]._awards[9]); +		Common::String count = Common::String::format("%05u", party._activeParty[0]._awards[WARZONE_AWARD]);  		int numIdx = count[3] == '1' ? 0 : count[4] - '0';  		Common::String msg = Common::String::format(format.c_str(), count.c_str(), SUFFIXES[numIdx]); @@ -1140,7 +1140,7 @@ int ArenaLocation::show() {  	}  	for (uint idx = 0; idx < party._activeParty.size(); ++idx) { -		if (party._activeParty[idx]._awards[idx] >= 99) { +		if (party._activeParty[idx]._awards[WARZONE_AWARD] >= 99) {  			LocationMessage::show(27, Res.WARZONE_BATTLE_MASTER, Res.WARZONE_MAXED, 1);  			map.load(28);  			goto exit;  | 
