Permalink
Browse files

XEEN: Revert "XEEN: Change _gameFlags to it's own class"

This reverts commit a37b0e8.
Turns out the overlapping byte access was for the questItems
array, but using Ids which start at 82 rather than 0
  • Loading branch information...
dreammaster committed Dec 29, 2017
1 parent a37b0e8 commit fb73c1a3ccbf3ce489cd2539a2e4b769a138a055
Showing with 21 additions and 81 deletions.
  1. +3 −3 engines/xeen/combat.cpp
  2. +2 −2 engines/xeen/interface.cpp
  3. +4 −4 engines/xeen/map.cpp
  4. +10 −35 engines/xeen/party.cpp
  5. +1 −36 engines/xeen/party.h
  6. +1 −1 engines/xeen/scripts.cpp
View
@@ -1476,16 +1476,16 @@ void Combat::attack2(int damage, RangeType rangeType) {
if (monsterDied) {
if (!isDarkCc) {
if (_monster2Attack == 20 && party._mazeId == 41)
party._gameFlags.set(11, true);
party._gameFlags[0][11] = true;
if (_monster2Attack == 8 && party._mazeId == 78) {
party._gameFlags.set(60, true);
party._gameFlags[0][60] = true;
party._questFlags[0][23] = false;
for (uint idx = 0; idx < party._activeParty.size(); ++idx)
party._activeParty[idx].setAward(42, true);
if (_monster2Attack == 27 && party._mazeId == 29)
party._gameFlags.set(104, true);
party._gameFlags[0][104] = true;
}
}
@@ -677,7 +677,7 @@ void Interface::doStepCode() {
break;
}
if (_vm->_files->_isDarkCc && party._gameFlags.get(118, 1)) {
if (_vm->_files->_isDarkCc && party._gameFlags[1][118]) {
_falling = false;
} else {
if (_falling)
@@ -711,7 +711,7 @@ void Interface::startFalling(bool flag) {
Scripts &scripts = *_vm->_scripts;
bool isDarkCc = _vm->_files->_isDarkCc;
if (isDarkCc && party._gameFlags.get(118, 1)) {
if (isDarkCc && party._gameFlags[1][118]) {
_falling = 0;
return;
}
View
@@ -1058,7 +1058,7 @@ void Map::load(int mapId) {
if (isDarkCc && mapId == 50)
mazeDataP->setAllTilesStepped();
if (!isDarkCc && party._gameFlags.get(25) &&
if (!isDarkCc && party._gameFlags[0][25] &&
(mapId == 42 || mapId == 43 || mapId == 4)) {
mazeDataP->clearCellSurfaces();
}
@@ -1100,7 +1100,7 @@ void Map::load(int mapId) {
if ((_mobData._monsters[0]._position.x > 31 || _mobData._monsters[0]._position.y > 31) &&
(_mobData._monsters[1]._position.x > 31 || _mobData._monsters[1]._position.y > 31) &&
(_mobData._monsters[2]._position.x > 31 || _mobData._monsters[2]._position.y > 31)) {
party._gameFlags.set(56, true);
party._gameFlags[0][56] = true;
}
}
}
@@ -1135,7 +1135,7 @@ void Map::load(int mapId) {
_mobData._objects[29]._spriteId = 0;
_mobData._objects[29]._id = 8;
_mobData._objectSprites[i]._sprites.clear();
} else if (mapId == 12 && party._gameFlags.get(43) &&
} else if (mapId == 12 && party._gameFlags[0][43] &&
_mobData._objectSprites[i]._spriteId == 118 && !isDarkCc) {
filename = "085.obj";
_mobData._objectSprites[0]._spriteId = 85;
@@ -1445,7 +1445,7 @@ void Map::saveMap() {
for (uint idx = 0; idx < MIN(_mobData._monsters.size(), (uint)3); ++idx) {
MazeMonster &mon = _mobData._monsters[idx];
if (mon._position.x > 31 || mon._position.y > 31) {
party._gameFlags.set(56, true);
party._gameFlags[0][56] = true;
break;
}
}
View
@@ -72,34 +72,6 @@ Treasure::Treasure() {
/*------------------------------------------------------------------------*/
void Party::GameFlags::clear() {
Common::fill(&_flags[0][0], &_flags[0][0] + (FLAGS_COUNT / 8), 0);
Common::fill(&_flags[1][0], &_flags[1][0] + (FLAGS_COUNT / 8), 0);
}
bool Party::GameFlags::get(uint flagNum, uint sideNum) const {
if (flagNum >= FLAGS_COUNT) {
sideNum = flagNum / FLAGS_COUNT;
flagNum %= FLAGS_COUNT;
}
return (_flags[sideNum][flagNum / 8] & (1 << (flagNum % 8))) != 0;
}
void Party::GameFlags::set(uint flagNum, uint sideNum, bool value) {
byte &b = _flags[sideNum][flagNum / 8];
b &= ~(1 << (flagNum % 8));
if (value)
b |= 1 << (flagNum % 8);
}
void Party::GameFlags::synchronize(Common::Serializer &s) {
s.syncBytes(&_flags[0][0], FLAGS_COUNT / 8);
s.syncBytes(&_flags[1][0], FLAGS_COUNT / 8);
}
/*------------------------------------------------------------------------*/
XeenEngine *Party::_vm;
Party::Party(XeenEngine *vm) {
@@ -140,6 +112,8 @@ Party::Party(XeenEngine *vm) {
_totalTime = 0;
_rested = false;
Common::fill(&_gameFlags[0][0], &_gameFlags[0][256], false);
Common::fill(&_gameFlags[1][0], &_gameFlags[1][256], false);
Common::fill(&_worldFlags[0], &_worldFlags[128], false);
Common::fill(&_questFlags[0][0], &_questFlags[0][30], false);
Common::fill(&_questFlags[1][0], &_questFlags[1][30], false);
@@ -232,7 +206,8 @@ void Party::synchronize(Common::Serializer &s) {
s.syncAsUint32LE(_bankGems);
s.syncAsUint32LE(_totalTime);
s.syncAsByte(_rested);
_gameFlags.synchronize(s);
File::syncBitFlags(s, &_gameFlags[0][0], &_gameFlags[0][256]);
File::syncBitFlags(s, &_gameFlags[1][0], &_gameFlags[1][256]);
File::syncBitFlags(s, &_worldFlags[0], &_worldFlags[128]);
File::syncBitFlags(s, &_questFlags[0][0], &_questFlags[0][30]);
File::syncBitFlags(s, &_questFlags[1][0], &_questFlags[1][30]);
@@ -851,7 +826,7 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int
break;
}
case 20:
_gameFlags.set(takeVal, files._isDarkCc, false);
_gameFlags[files._isDarkCc][takeVal] = false;
break;
case 21: {
bool found = false;
@@ -1121,7 +1096,7 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int
break;
}
case 20:
_gameFlags.set(giveVal, files._isDarkCc, true);
_gameFlags[files._isDarkCc][giveVal] = true;
break;
case 21: {
int idx;
@@ -1430,10 +1405,10 @@ void Party::subPartyTime(int time) {
}
void Party::resetYearlyBits() {
_gameFlags.set(55, false);
_gameFlags.set(155, false);
_gameFlags.set(222, false);
_gameFlags.set(231, false);
_gameFlags[0][55] = false;
_gameFlags[0][155] = false;
_gameFlags[0][222] = false;
_gameFlags[0][231] = false;
}
const int BLACKSMITH_DATA1[4][4] = {
View
@@ -47,7 +47,6 @@ enum PartyBank {
WHERE_PARTY = 0, WHERE_BANK = 1
};
#define FLAGS_COUNT 256
#define ITEMS_COUNT 36
#define TOTAL_CHARACTERS 30
#define XEEN_TOTAL_CHARACTERS 24
@@ -83,40 +82,6 @@ class Treasure {
class Party {
friend class Character;
friend class InventoryItems;
class GameFlags {
private:
byte _flags[2][FLAGS_COUNT / 8];
public:
byte &_state;
public:
GameFlags() : _state(_flags[0][6]) { clear(); }
/**
* Clears the flags
*/
void clear();
/**
* Get a flag value
*/
bool get(uint flagNum, uint sideNum = 0) const;
/**
* Sets a flag value
*/
void set(uint flagNum, bool value) { set(flagNum % 256, flagNum / 256, value); }
/**
* Sets a flag value
*/
void set(uint flagNum, uint sideNum, bool value);
/**
* Synchronize flags
*/
void synchronize(Common::Serializer &s);
};
private:
static XeenEngine *_vm;
Character _itemsCharacter;
@@ -185,7 +150,7 @@ class Party {
uint _bankGems;
int _totalTime;
bool _rested;
GameFlags _gameFlags;
bool _gameFlags[2][256];
bool _worldFlags[128];
bool _questFlags[2][30];
int _questItems[TOTAL_QUEST_ITEMS];
View
@@ -1541,7 +1541,7 @@ bool Scripts::ifProc(int action, uint32 val, int mode, int charIndex) {
if (files._isDarkCc)
val += 256;
assert(val < 512);
v = party._gameFlags.get(val) ? val : 0xffffffff;
v = party._gameFlags[val / 256][val % 256] ? val : 0xffffffff;
break;
case 21:
// Scans inventories for given item number

0 comments on commit fb73c1a

Please sign in to comment.