From 49787629ffb86569faebd3155fd65c0cedea0bad Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 Jan 2015 08:54:42 -0500 Subject: XEEN: Various renamings --- engines/xeen/darkside/darkside_game.cpp | 4 +- engines/xeen/dialogs_options.cpp | 2 +- engines/xeen/interface.cpp | 16 ++-- engines/xeen/interface.h | 6 +- engines/xeen/map.cpp | 152 ++++++++++++++++++++++++++++++-- engines/xeen/map.h | 54 +++++++++++- engines/xeen/party.cpp | 4 +- engines/xeen/party.h | 4 +- engines/xeen/sound.h | 2 +- engines/xeen/xeen.cpp | 2 +- engines/xeen/xeen.h | 2 +- 11 files changed, 215 insertions(+), 33 deletions(-) (limited to 'engines') diff --git a/engines/xeen/darkside/darkside_game.cpp b/engines/xeen/darkside/darkside_game.cpp index 30f54580e3..60cb69362a 100644 --- a/engines/xeen/darkside/darkside_game.cpp +++ b/engines/xeen/darkside/darkside_game.cpp @@ -220,8 +220,8 @@ void DarkSideEngine::showStartSequence() { pause(30); // TODO: More - _sound->playMusic(voc[0]); - _sound->playMusic(voc[1]); + _sound->playSong(voc[0]); + _sound->playSong(voc[1]); } } // End of namespace Xeen diff --git a/engines/xeen/dialogs_options.cpp b/engines/xeen/dialogs_options.cpp index fb7366c5c7..8f02559837 100644 --- a/engines/xeen/dialogs_options.cpp +++ b/engines/xeen/dialogs_options.cpp @@ -54,7 +54,7 @@ void OptionsMenu::execute() { EventsManager &events = *_vm->_events; File newBright("newbrigh.m"); - _vm->_sound->playMusic(newBright); + _vm->_sound->playSong(newBright); screen._windows[GAME_WINDOW].setBounds(Common::Rect(72, 25, 248, 175)); diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index e960b3d89a..f952425d05 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -355,7 +355,7 @@ Interface::Interface(XeenEngine *vm) : ButtonContainer(), _vm(vm) { _holyBonusUIFrame = 0; _heroismUIFrame = 0; _flipUIFrame = 0; - _isEarlyGame = false; + _newDay = false; _buttonsLoaded = false; _hiliteChar = -1; Common::fill(&_combatCharIds[0], &_combatCharIds[8], 0); @@ -411,7 +411,7 @@ void Interface::setup() { _vm->_party._activeParty[i] = _vm->_roster[_vm->_party._partyMembers[i]]; } - _isEarlyGame = _vm->_party._minutes >= 300; + _newDay = _vm->_party._minutes >= 300; } void Interface::manageCharacters(bool soundPlayed) { @@ -546,7 +546,7 @@ start: } else { screen.fadeOut(4); w.close(); - addCharacterToRoster(); + moveCharacterToRoster(); _vm->_saves->writeCharFile(); screen.fadeOut(4); flag = true; @@ -636,7 +636,7 @@ void Interface::assembleBorder() { // Draw UI element to indicate whether can spot hidden doors _borderSprites.draw(screen, - (_vm->_spotDoorsAllowed && _vm->_party.checkSkill(SPOT_DOORS)) ? _spotDoorsUIFrame + 28 : 28, + (_vm->_thinWall && _vm->_party.checkSkill(SPOT_DOORS)) ? _spotDoorsUIFrame + 28 : 28, Common::Point(194, 91)); _spotDoorsUIFrame = (_spotDoorsUIFrame + 1) % 12; @@ -788,7 +788,7 @@ void Interface::charIconsPrint(bool updateFlag) { _vm->_party._partyCount); ++idx) { int charIndex = stateFlag ? _combatCharIds[idx] : idx; PlayerStruct &ps = _vm->_party._activeParty[charIndex]; - Condition charCondition = ps.findCondition(); + Condition charCondition = ps.worstCondition(); int charFrame = FACE_CONDITION_FRAMES[charCondition]; SpriteResource *sprites = (charFrame > 4 && !_charFaces[0].empty()) ? @@ -847,7 +847,7 @@ void Interface::drawViewBackground(int bgType) { } } -void Interface::addCharacterToRoster() { +void Interface::moveCharacterToRoster() { error("TODO"); } @@ -975,7 +975,7 @@ void Interface::startup() { for (int i = 1; i < 16; ++i) _mainList[i]._sprites = &_iconSprites; - setIconButtons(); + setMainButtons(); _tillMove = false; } @@ -992,7 +992,7 @@ void Interface::moveMonsters() { } -void Interface::setIconButtons() { +void Interface::setMainButtons() { clearButtons(); addButton(Common::Rect(235, 75, 259, 95), 83, &_iconSprites); diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h index 5dc5e1ffbe..3bb0fa7463 100644 --- a/engines/xeen/interface.h +++ b/engines/xeen/interface.h @@ -89,7 +89,7 @@ private: int _holyBonusUIFrame; int _heroismUIFrame; int _flipUIFrame; - bool _isEarlyGame; + bool _newDay; bool _buttonsLoaded; Common::String _interfaceText; int _hiliteChar; @@ -116,7 +116,7 @@ private: void drawViewBackground(int bgType); - void addCharacterToRoster(); + void moveCharacterToRoster(); void animate3d(); @@ -130,7 +130,7 @@ private: void moveMonsters(); - void setIconButtons(); + void setMainButtons(); public: Interface(XeenEngine *vm); diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index 52dbc839a0..e2050bdefb 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -536,8 +536,8 @@ void MazeDifficulties::synchronize(Common::SeekableReadStream &s) { MazeData::MazeData() { for (int y = 0; y < MAP_HEIGHT; ++y) { - Common::fill(&_wallData[y][0], &_wallData[y][MAP_WIDTH], 0); - Common::fill(&_cellFlag[y][0], &_cellFlag[y][MAP_WIDTH], 0); + for (int x = 0; x < MAP_WIDTH; ++x) + _wallData[y][x]._data = 0; Common::fill(&_seenTiles[y][0], &_seenTiles[y][MAP_WIDTH], 0); Common::fill(&_steppedOnTiles[y][0], &_steppedOnTiles[y][MAP_WIDTH], 0); _wallTypes[y] = 0; @@ -554,11 +554,14 @@ MazeData::MazeData() { void MazeData::synchronize(Common::SeekableReadStream &s) { for (int y = 0; y < MAP_HEIGHT; ++y) { for (int x = 0; x < MAP_WIDTH; ++x) - _wallData[y][x] = s.readUint16LE(); + _wallData[y][x]._data = s.readUint16LE(); } for (int y = 0; y < MAP_HEIGHT; ++y) { - for (int x = 0; x < MAP_WIDTH; ++x) - _cellFlag[y][x] = s.readByte(); + for (int x = 0; x < MAP_WIDTH; ++x) { + byte b = s.readByte(); + _cells[y][x]._surfaceId = b & 7; + _cells[y][x]._flags = b & 0xF8; + } } _mazeNumber = s.readUint16LE(); @@ -594,10 +597,10 @@ void MazeData::setAllTilesStepped() { Common::fill(&_steppedOnTiles[y][0], &_steppedOnTiles[y][MAP_WIDTH], true); } -void MazeData::clearCellBits() { +void MazeData::clearCellSurfaces() { for (int y = 0; y < MAP_HEIGHT; ++y) { for (int x = 0; x < MAP_WIDTH; ++x) - _cellFlag[y][x] &= 0xF8; + _cells[y][x]._surfaceId = 0; } } @@ -763,6 +766,15 @@ Map::Map(XeenEngine *vm) : _vm(vm), _mobData(vm) { _sideMon = 0; _isOutdoors = false; _stepped = false; + _mazeDataIndex = 0; + _currentSteppedOn = false; + _currentSurfaceId = 0; + _currentIsGrate = false; + _currentCantRest = false; + _currentIsDrain = false; + _currentIsEvent = false; + _currentIsObject = false; + _currentMonsterFlags = 0; } void Map::load(int mapId) { @@ -851,7 +863,7 @@ void Map::load(int mapId) { mazeData->setAllTilesStepped(); if (!isDarkCc && _vm->_party._gameFlags[25] && (mapId == 42 || mapId == 43 || mapId == 4)) { - mazeData->clearCellBits(); + mazeData->clearCellSurfaces(); } _isOutdoors = (mazeData->_mazeFlags2 & FLAG_IS_OUTDOORS) != 0; @@ -948,4 +960,128 @@ void Map::load(int mapId) { } } +int Map::mazeLookup(const Common::Point &pt, int directionLayerIndex) { + Common::Point pos = pt; + int mapId = _vm->_party._mazeId; + + if (pt.x < -16 || pt.y < -16 || pt.x >= 32 || pt.y >= 32) + error("Invalid coordinate"); + + // Find the correct maze data out of the set to use + _mazeDataIndex = 0; + while (_mazeData[_mazeDataIndex]._mazeId != _vm->_party._mazeId) + ++_mazeDataIndex; + + // Handle map changing to the north or south as necessary + if (pos.y & 16) { + if (pos.y >= 0) { + pos.y -= 16; + mapId = _mazeData[_mazeDataIndex]._surroundingMazes._north; + } else { + pos.y += 16; + mapId = _mazeData[_mazeDataIndex]._surroundingMazes._south; + } + + if (mapId) { + // Move to the correct map to north/south + _mazeDataIndex = 0; + while (_mazeData[_mazeDataIndex]._mazeId != mapId) + ++_mazeDataIndex; + } else { + // No map, so reached outside indoor area or outer space outdoors + _currentSteppedOn = true; + return _isOutdoors ? SURFTYPE_SPACE : 0x8888; + } + } + + // Handle map changing to the east or west as necessary + if (pos.x & 16) { + if (pos.x >= 0) { + pos.x -= 16; + mapId = _mazeData[_mazeDataIndex]._surroundingMazes._east; + } else { + pos.x += 16; + mapId = _mazeData[_mazeDataIndex]._surroundingMazes._west; + } + + if (mapId) { + _mazeDataIndex = 0; + while (_mazeData[_mazeDataIndex]._mazeId != mapId) + ++_mazeDataIndex; + } + } + + if (mapId) { + if (_isOutdoors) { + _currentSurfaceId = _mazeData[_mazeDataIndex]._wallData[pos.y][pos.x]._outdoors._surfaceId; + } else { + _currentSurfaceId = _mazeData[_mazeDataIndex]._cells[pos.y][pos.x]._surfaceId; + } + + if (_currentSurfaceId == SURFTYPE_SPACE || _currentSurfaceId == SURFTYPE_SKY) { + _currentSteppedOn = true; + } else { + _currentSteppedOn = _mazeData[_mazeDataIndex]._steppedOnTiles[pos.y][pos.x]; + } + + return (_mazeData[_mazeDataIndex]._wallData[pos.y][pos.x]._data >> (directionLayerIndex * 4)) & 0xF; + + } else { + _currentSteppedOn = _isOutdoors; + return _isOutdoors ? SURFTYPE_SPACE : 0x8888; + } +} + +void Map::cellFlagLookup(const Common::Point &pt) { + Common::Point pos = pt; + int mapId = _vm->_party._mazeId; + _mazeDataIndex = 0; + while (_mazeData[_mazeDataIndex]._mazeId != mapId) + ++_mazeDataIndex; + + // Handle map changing to the north or south as necessary + if (pos.y & 16) { + if (pos.y >= 0) { + pos.y -= 16; + mapId = _mazeData[_mazeDataIndex]._surroundingMazes._north; + } else { + pos.y += 16; + mapId = _mazeData[_mazeDataIndex]._surroundingMazes._south; + } + + _mazeDataIndex = 0; + while (_mazeData[_mazeDataIndex]._mazeId != mapId) + ++_mazeDataIndex; + } + + // Handle map changing to the east or west as necessary + if (pos.x & 16) { + if (pos.x >= 0) { + pos.x -= 16; + mapId = _mazeData[_mazeDataIndex]._surroundingMazes._east; + } else { + pos.x += 16; + mapId = _mazeData[_mazeDataIndex]._surroundingMazes._west; + } + + _mazeDataIndex = 0; + while (_mazeData[_mazeDataIndex]._mazeId != mapId) + ++_mazeDataIndex; + } + + // Get the cell flags + const MazeCell &cell = _mazeData[_mazeDataIndex]._cells[pos.y][pos.x]; + _currentIsGrate = cell._flags & OUTFLAG_GRATE; + _currentCantRest = cell._flags & FLAG_WATER; + _currentIsDrain = cell._flags & OUTFLAG_DRAIN; + _currentIsEvent = cell._flags & FLAG_AUTOEXECUTE_EVENT; + _currentIsObject = cell._flags & OUTFLAG_OBJECT_EXISTS; + _currentMonsterFlags = cell._flags & 7; +} + +void Map::setCellSurfaceFlags(const Common::Point &pt, int bits) { + mazeLookup(pt, 0); + _mazeData[0]._cells[pt.y][pt.x]._surfaceId |= bits; +} + } // End of namespace Xeen diff --git a/engines/xeen/map.h b/engines/xeen/map.h index 30c2c643df..3a1073eda2 100644 --- a/engines/xeen/map.h +++ b/engines/xeen/map.h @@ -36,7 +36,7 @@ namespace Xeen { class XeenEngine; -enum DamageType { +enum DamageType { DT_PHYSICAL = 0, DT_1 = 1, DT_FIRE = 2, DT_ELECTRICAL = 3, DT_COLD = 4, DT_POISON = 5, DT_ENERGY = 6, DT_SLEEP = 7, DT_FINGEROFDEATH = 8, DT_HOLYWORD = 9, DT_MASS_DISTORTION = 10, @@ -156,11 +156,42 @@ enum MazeFlags { enum MazeFlags2 { FLAG_IS_OUTDOORS = 0x8000, FLAG_IS_DARK = 0x4000 }; +enum SurfaceType { + SURFTYPE_DEFAULT = 0, SURFTYPE_DIRT = 1, SURFTYPE_GRASS = 2, + SURFTYPE_SNOW = 3, SURFTYPE_SWAMP = 4, SURFTYPE_LAVA = 5, + SURFTYPE_DESERT = 6, SURFTYPE_ROAD = 7, SURFTYPE_WATER = 8, + SURFTYPE_TFLR = 9, SURFTYPE_SKY = 10, SURFTYPE_CROAD = 11, + SURFTYPE_SEWER = 12, SURFTYPE_CLOUD = 13, SURFTYPE_SCORCH = 14, + SURFTYPE_SPACE = 15 +}; + +union MazeWallLayers { + struct MazeWallIndoors { + int _wallNorth : 4; + int _wallEast : 4; + int _wallSouth : 4; + int _wallWest : 4; + } _indoors; + struct MazeWallOutdoors { + SurfaceType _surfaceId : 4; + int _iMiddle : 4; + int _iTop : 4; + int _iOverlay : 4; + } _outdoors; + uint16 _data; +}; + +struct MazeCell { + int _flags; + int _surfaceId; + MazeCell() : _flags(0), _surfaceId(0) {} +}; + class MazeData { public: // Resource fields - int _wallData[MAP_HEIGHT][MAP_WIDTH]; - int _cellFlag[MAP_HEIGHT][MAP_WIDTH]; + MazeWallLayers _wallData[MAP_HEIGHT][MAP_WIDTH]; + MazeCell _cells[MAP_HEIGHT][MAP_WIDTH]; int _mazeNumber; SurroundingMazes _surroundingMazes; int _mazeFlags; @@ -185,7 +216,7 @@ public: void setAllTilesStepped(); - void clearCellBits(); + void clearCellSurfaces(); }; class MobStruct { @@ -293,13 +324,28 @@ private: int _sideObj; int _sideMon; bool _stepped; + int _mazeDataIndex; + bool _currentSteppedOn; + int _currentSurfaceId; + + void cellFlagLookup(const Common::Point &pt); public: bool _isOutdoors; MonsterObjectData _mobData; + bool _currentIsGrate; + bool _currentCantRest; + bool _currentIsDrain; + bool _currentIsEvent; + bool _currentIsObject; + int _currentMonsterFlags; public: Map(XeenEngine *vm); void load(int mapId); + + int mazeLookup(const Common::Point &pt, int directionLayerIndex); + + void setCellSurfaceFlags(const Common::Point &pt, int bits); }; } // End of namespace Xeen diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index ec25f4a71c..ad6d2145de 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -135,7 +135,7 @@ void PlayerStruct::synchronize(Common::Serializer &s) { s.syncAsByte(_currentCombatSpell); } -Condition PlayerStruct::findCondition() const { +Condition PlayerStruct::worstCondition() const { for (int cond = ERADICATED; cond >= CURSED; --cond) { if (_conditions[cond]) return (Condition)cond; @@ -144,7 +144,7 @@ Condition PlayerStruct::findCondition() const { return NO_CONDITION; } -int PlayerStruct::getYear(int partyYear, bool ignoreTemp) { +int PlayerStruct::getAge(int partyYear, bool ignoreTemp) { int year = MIN(partyYear - _ybDay, 254); return ignoreTemp ? year : year + _tempAge; diff --git a/engines/xeen/party.h b/engines/xeen/party.h index b415707344..f1220c82e9 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -126,9 +126,9 @@ public: PlayerStruct(); void synchronize(Common::Serializer &s); - Condition findCondition() const; + Condition worstCondition() const; - int getYear(int partyYear, bool ignoreTemp); + int getAge(int partyYear, bool ignoreTemp); int getMaxHp(); }; diff --git a/engines/xeen/sound.h b/engines/xeen/sound.h index f375b985f8..da6548b07d 100644 --- a/engines/xeen/sound.h +++ b/engines/xeen/sound.h @@ -39,7 +39,7 @@ public: void startMusic(int v1); - void playMusic(const File &f) {} + void playSong(const File &f) {} void playSample(const Common::SeekableReadStream *stream, int v2) {} }; diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index c2abdd9e9f..9cc51e1765 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -46,7 +46,7 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) _sound = nullptr; _eventData = nullptr; _loadDarkSide = 1; - _spotDoorsAllowed = false; + _thinWall = false; _dangerSenseAllowed = false; _face1State = 0; _face2State = 0; diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index 44deaee43c..efeacf0ae1 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -138,7 +138,7 @@ public: Roster _roster; Party _party; int _loadDarkSide; - bool _spotDoorsAllowed; + bool _thinWall; bool _dangerSenseAllowed; int _face1State; int _face2State; -- cgit v1.2.3