Skip to content

Commit

Permalink
XEEN: Fixes for map loading cells and indoor sprite list references
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 17, 2015
1 parent 484901e commit 6bfd599
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 54 deletions.
44 changes: 22 additions & 22 deletions engines/xeen/interface.cpp
Expand Up @@ -662,7 +662,7 @@ void Interface::draw3d(bool updateFlag) {
}

setIndoorsAttackingMonsters();
setIndoorObjects();
setIndoorsObjects();
setIndoorsWallPics();

_indoorList[161]._sprites = nullptr;
Expand Down Expand Up @@ -757,7 +757,7 @@ void Interface::startup() {
animate3d();
if (_vm->_map->_isOutdoors) {
setIndoorsAttackingMonsters();
setIndoorObjects();
setIndoorsObjects();
} else {
setOutdoorsMonsters();
setOutdoorsObjects();
Expand Down Expand Up @@ -816,7 +816,7 @@ void Interface::setMainButtons() {
void Interface::setMazeBits() {
Common::fill(&_wo[0], &_wo[308], 0);

switch (_vm->_map->getCell(0)) {
switch (_vm->_map->getCell(0) - 1) {
case 0:
++_wo[125];
break;
Expand Down Expand Up @@ -886,7 +886,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(2)) {
switch (_vm->_map->getCell(2) - 1) {
case 0:
++_wo[127];
break;
Expand Down Expand Up @@ -956,7 +956,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(4)) {
switch (_vm->_map->getCell(4) - 1) {
case 0:
++_wo[126];
break;
Expand Down Expand Up @@ -1002,7 +1002,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(5)) {
switch (_vm->_map->getCell(5) - 1) {
case 0:
++_wo[122];
break;
Expand Down Expand Up @@ -1068,7 +1068,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(7)) {
switch (_vm->_map->getCell(7) - 1) {
case 0:
++_wo[124];
break;
Expand Down Expand Up @@ -1140,7 +1140,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(9)) {
switch (_vm->_map->getCell(9) - 1) {
case 0:
++_wo[123];
break;
Expand Down Expand Up @@ -1186,7 +1186,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(10)) {
switch (_vm->_map->getCell(10) - 1) {
case 0:
++_wo[117];
break;
Expand Down Expand Up @@ -1255,7 +1255,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(12)) {
switch (_vm->_map->getCell(12) - 1) {
case 0:
++_wo[118];
break;
Expand Down Expand Up @@ -1325,7 +1325,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(14)) {
switch (_vm->_map->getCell(14) - 1) {
case 0:
++_wo[121];
break;
Expand Down Expand Up @@ -1395,7 +1395,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(16)) {
switch (_vm->_map->getCell(16) - 1) {
case 0:
++_wo[120];
break;
Expand Down Expand Up @@ -1465,7 +1465,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(18)) {
switch (_vm->_map->getCell(18) - 1) {
case 0:
++_wo[119];
break;
Expand Down Expand Up @@ -1511,7 +1511,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(19)) {
switch (_vm->_map->getCell(19) - 1) {
case 0:
++_wo[108];
break;
Expand Down Expand Up @@ -1580,7 +1580,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(21)) {
switch (_vm->_map->getCell(21) - 1) {
case 0:
++_wo[109];
break;
Expand Down Expand Up @@ -1650,7 +1650,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(23)) {
switch (_vm->_map->getCell(23) - 1) {
case 0:
++_wo[110];
break;
Expand Down Expand Up @@ -1720,7 +1720,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(25)) {
switch (_vm->_map->getCell(25) - 1) {
case 0:
++_wo[111];
break;
Expand Down Expand Up @@ -1790,7 +1790,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(27)) {
switch (_vm->_map->getCell(27) - 1) {
case 0:
++_wo[116];
break;
Expand Down Expand Up @@ -1860,7 +1860,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(29)) {
switch (_vm->_map->getCell(29) - 1) {
case 0:
++_wo[115];
break;
Expand Down Expand Up @@ -1930,7 +1930,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(31)) {
switch (_vm->_map->getCell(31) - 1) {
case 0:
++_wo[114];
break;
Expand Down Expand Up @@ -1999,7 +1999,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(33)) {
switch (_vm->_map->getCell(33) - 1) {
case 0:
++_wo[112];
break;
Expand Down Expand Up @@ -2069,7 +2069,7 @@ void Interface::setMazeBits() {
break;
}

switch (_vm->_map->getCell(35)) {
switch (_vm->_map->getCell(35) - 1) {
case 0:
++_wo[113];
break;
Expand Down
53 changes: 27 additions & 26 deletions engines/xeen/interface_map.cpp
Expand Up @@ -166,7 +166,7 @@ OutdoorDrawList::OutdoorDrawList() : _skySprite(_data[1]), _groundSprite(_data[2

IndoorDrawList::IndoorDrawList() :
_sky(_data[1]), _ground(_data[2]), _horizon(_data[28]),
_swl_0F1R(_data[ 46]), _swl_0F1L(_data[44]), _swl_1F1R(_data[134]),
_swl_0F1R(_data[146]), _swl_0F1L(_data[144]), _swl_1F1R(_data[134]),
_swl_1F1L(_data[133]), _swl_2F2R(_data[110]), _swl_2F1R(_data[109]),
_swl_2F1L(_data[108]), _swl_2F2L(_data[107]), _swl_3F1R(_data[ 78]),
_swl_3F2R(_data[ 77]), _swl_3F3R(_data[ 76]), _swl_3F4R(_data[ 75]),
Expand Down Expand Up @@ -377,6 +377,7 @@ InterfaceMap::InterfaceMap(XeenEngine *vm): _vm(vm) {
void InterfaceMap::setIndoorsAttackingMonsters() {
Combat &combat = *_vm->_combat;
Map &map = *_vm->_map;
Common::Point mazePos = _vm->_party._mazePosition;
Direction dir = _vm->_party._mazeDirection;
const int INDOOR_MONSTERS_Y[4] = { 2, 34, 53, 59 };

Expand All @@ -392,8 +393,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}

// The following long sequence sets up monsters in the various positions
if (monster._position.x == SCREEN_POSITIONING_X[dir][2] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][2]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][2]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][2])) {
monster._isAttacking = true;
if (combat._attackMonsters[0] == -1) {
combat._attackMonsters[0] = monsterIdx;
Expand All @@ -407,8 +408,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}
}

if (monster._position.x == SCREEN_POSITIONING_X[dir][7] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][7]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][7]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][7])) {
monster._isAttacking = true;
if (!_wo[27]) {
if (combat._attackMonsters[3] == -1) {
Expand All @@ -424,8 +425,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}
}

if (monster._position.x == SCREEN_POSITIONING_X[dir][5] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][5]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][5]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][5])) {
if (_wo[27] && _wo[25]) {
} else if (_wo[27] && _wo[28]) {
} else if (_wo[23] & _wo[25]) {
Expand All @@ -440,8 +441,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}
}

if (monster._position.x == SCREEN_POSITIONING_X[dir][9] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][9]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][9]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][9])) {
if (_wo[27] && _wo[26]) {
} else if (_wo[27] && _wo[29]) {
} else if (_wo[24] & _wo[26]) {
Expand All @@ -456,8 +457,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}
}

if (monster._position.x == SCREEN_POSITIONING_X[dir][14] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][14]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][14]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][14])) {
monster._isAttacking = true;

if (!_wo[22] && !_wo[27]) {
Expand All @@ -474,8 +475,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}
}

if (monster._position.x == SCREEN_POSITIONING_X[dir][12] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][12]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][12]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][12])) {
if (_wo[27]) {
} else if (_wo[22] && _wo[23]) {
} else if (_wo[22] & _wo[20]) {
Expand All @@ -493,8 +494,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}
}

if (monster._position.x == SCREEN_POSITIONING_X[dir][16] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][16]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][16]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][16])) {
if (_wo[27]) {
} else if (_wo[22] && _wo[24]) {
} else if (_wo[22] & _wo[21]) {
Expand All @@ -513,8 +514,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}
}

if (monster._position.x == SCREEN_POSITIONING_X[dir][27] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][27]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][27]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][27])) {
if (!_wo[27] && !_wo[22] && _wo[15]) {
monster._isAttacking = true;

Expand All @@ -531,8 +532,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}
}

if (monster._position.x == SCREEN_POSITIONING_X[dir][25] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][25]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][25]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][25])) {
if (_wo[27] || _wo[22]) {
} else if (_wo[15] && _wo[17]) {
} else if (_wo[15] && _wo[12]) {
Expand All @@ -554,8 +555,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}
}

if (monster._position.x == SCREEN_POSITIONING_X[dir][23] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][23]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][23]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][23])) {
if (_wo[27]) {
} else if (_wo[22] && _wo[20]) {
} else if (_wo[22] && _wo[23]) {
Expand All @@ -572,8 +573,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}
}

if (monster._position.x == SCREEN_POSITIONING_X[dir][29] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][29]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][29]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][29])) {
if (_wo[27] || _wo[22]) {
} else if (_wo[15] && _wo[19]) {
} else if (_wo[15] && _wo[14]) {
Expand All @@ -595,8 +596,8 @@ void InterfaceMap::setIndoorsAttackingMonsters() {
}
}

if (monster._position.x == SCREEN_POSITIONING_X[dir][31] &&
monster._position.y == SCREEN_POSITIONING_Y[dir][31]) {
if (monster._position.x == (mazePos.x + SCREEN_POSITIONING_X[dir][31]) &&
monster._position.y == (mazePos.y + SCREEN_POSITIONING_Y[dir][31])) {
if (_wo[27]) {
} else if (_wo[22] && _wo[21]) {
} else if (_wo[22] && _wo[24]) {
Expand Down Expand Up @@ -642,7 +643,7 @@ void InterfaceMap::setMonsterSprite(DrawStruct &drawStruct, MazeMonster &monster
drawStruct._flags = MONSTER_EFFECT_FLAGS[monster._effect2][monster._effect3];
}

void InterfaceMap::setIndoorObjects() {
void InterfaceMap::setIndoorsObjects() {
Common::Point mazePos = _vm->_party._mazePosition;
Direction dir = _vm->_party._mazeDirection;
Common::Point pt;
Expand Down
2 changes: 1 addition & 1 deletion engines/xeen/interface_map.h
Expand Up @@ -107,7 +107,7 @@ class InterfaceMap {

void setIndoorsAttackingMonsters();

void setIndoorObjects();
void setIndoorsObjects();

void setIndoorsWallPics();

Expand Down
10 changes: 5 additions & 5 deletions engines/xeen/map.cpp
Expand Up @@ -950,7 +950,7 @@ void Map::load(int mapId) {
if (mapId != 0) {
// Load in the maze's data file
Common::String datName = Common::String::format("maze%c%03d.dat",
(_vm->_party._mazeId >= 100) ? 'x' : '0', _vm->_party._mazeId);
(mapId >= 100) ? 'x' : '0', mapId);
File datFile(datName);
mazeData->synchronize(datFile);
datFile.close();
Expand Down Expand Up @@ -1435,11 +1435,11 @@ int Map::getCell(int idx) {
_currentWall._data = 0x8888;
return 0x8888;
}

_mazeDataIndex = 0;
while (_mazeData[_mazeDataIndex]._mazeId != mapId)
++_mazeDataIndex;
}

_mazeDataIndex = 0;
while (_mazeData[_mazeDataIndex]._mazeId != mapId)
++_mazeDataIndex;
}

MazeWallLayers &wallLayers = _mazeData[_mazeDataIndex]._wallData[pt.y][pt.x];
Expand Down

0 comments on commit 6bfd599

Please sign in to comment.