aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen/character.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2017-12-16 10:31:15 -0500
committerPaul Gilbert2017-12-16 10:31:15 -0500
commit808dd292a6d47bfa9fcd1d990ae1ca51640df5e2 (patch)
tree9c3a2ee0af9186cfd3dc07adf96aaf1b80ae114d /engines/xeen/character.cpp
parent93b9eb4e374b360e9d874ed1e65234ea2f80a312 (diff)
downloadscummvm-rg350-808dd292a6d47bfa9fcd1d990ae1ca51640df5e2.tar.gz
scummvm-rg350-808dd292a6d47bfa9fcd1d990ae1ca51640df5e2.tar.bz2
scummvm-rg350-808dd292a6d47bfa9fcd1d990ae1ca51640df5e2.zip
XEEN: Convert character _awards array from bool to int
This is needed for the Warzone award (9), which doubles as a counter
Diffstat (limited to 'engines/xeen/character.cpp')
-rw-r--r--engines/xeen/character.cpp15
1 files changed, 9 insertions, 6 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 {