diff options
-rw-r--r-- | engines/sherlock/map.cpp | 25 | ||||
-rw-r--r-- | engines/sherlock/map.h | 3 | ||||
-rw-r--r-- | engines/sherlock/objects.cpp | 7 | ||||
-rw-r--r-- | engines/sherlock/people.cpp | 13 | ||||
-rw-r--r-- | engines/sherlock/sherlock.cpp | 1 | ||||
-rw-r--r-- | engines/sherlock/sherlock.h | 1 |
6 files changed, 28 insertions, 22 deletions
diff --git a/engines/sherlock/map.cpp b/engines/sherlock/map.cpp index b89b4b29fa..5173e0296e 100644 --- a/engines/sherlock/map.cpp +++ b/engines/sherlock/map.cpp @@ -26,14 +26,15 @@ namespace Sherlock { Map::Map(SherlockEngine *vm): _vm(vm), _topLine(SHERLOCK_SCREEN_WIDTH, 12) { + _active = false; _mapCursors = nullptr; _shapes = nullptr; _iconShapes = nullptr; _point = 0; _placesShown = false; - _charPoint = _oldCharPoint = -1; _cursorIndex = -1; _drawMap = false; + _overPos = Common::Point(13000, 12600); for (int idx = 0; idx < MAX_HOLMES_SEQUENCE; ++idx) Common::fill(&_sequences[idx][0], &_sequences[idx][MAX_FRAME], 0); @@ -103,9 +104,11 @@ void Map::loadData() { int Map::show() { Events &events = *_vm->_events; People &people = *_vm->_people; + Scene &scene = *_vm->_scene; Screen &screen = *_vm->_screen; Common::Point lDrawn(-1, -1); bool changed = false, exitFlag = false; + _active = true; // Set font and custom cursor for the map int oldFont = screen.fontNumber(); @@ -204,7 +207,7 @@ int Map::show() { if ((events._released || events._rightReleased) && _point != -1) { if (people[AL]._walkCount == 0) { - _charPoint = _point; + scene._charPoint = _point; walkTheStreets(); _cursorIndex = 1; @@ -214,7 +217,7 @@ int Map::show() { // Check if a scene has beeen selected and we've finished "moving" to it if (people[AL]._walkCount == 0) { - if (_charPoint >= 1 && _charPoint < (int)_points.size()) + if (scene._charPoint >= 1 && scene._charPoint < (int)_points.size()) exitFlag = true; } @@ -238,7 +241,8 @@ int Map::show() { screen.setFont(oldFont); events.setCursor(ARROW); - return _charPoint; + _active = false; + return scene._charPoint; } /** @@ -350,7 +354,7 @@ void Map::showPlaceName(int idx, bool highlighted) { screen.gPrint(Common::Point(xp + 1, 1), 0, name.c_str()); screen.gPrint(Common::Point(xp, 0), 12, name.c_str()); - screen.slamArea(xp, 0, screen.stringWidth(name) + 2, 15); + screen.slamArea(xp, 0, width + 2, 15); } } @@ -408,21 +412,22 @@ void Map::updateMap(bool flushScreen) { */ void Map::walkTheStreets() { People &people = *_vm->_people; + Scene &scene = *_vm->_scene; bool reversePath = false; Common::Array<Common::Point> tempPath; // Get indexes into the path lists for the start and destination scenes - int start = _points[_oldCharPoint]._translate; - int dest = _points[_charPoint]._translate; + int start = _points[scene._oldCharPoint]._translate; + int dest = _points[scene._charPoint]._translate; // Get pointer to start of path const int *ptr = &_paths[start][dest]; // Check for any intermediate points between the two locations - if (*ptr || _charPoint > 50 || _oldCharPoint > 50) { + if (*ptr || scene._charPoint > 50 || scene._oldCharPoint > 50) { people[AL]._sequenceNumber = -1; - if (_charPoint == 51 || _oldCharPoint == 51) { + if (scene._charPoint == 51 || scene._oldCharPoint == 51) { people.setWalking(); } else { // Check for moving the path backwards or forwards @@ -514,7 +519,7 @@ void Map::highlightIcon(const Common::Point &pt) { // Iterate through the icon list bool done = false; - for (uint idx = 0; idx < _points.size(); ++idx) { + for (int idx = 0; idx < (int)_points.size(); ++idx) { const MapEntry &entry = _points[idx]; // Check whether the mouse is over a given icon diff --git a/engines/sherlock/map.h b/engines/sherlock/map.h index 752137e0ba..da55a5e383 100644 --- a/engines/sherlock/map.h +++ b/engines/sherlock/map.h @@ -62,7 +62,6 @@ private: Common::Point _lDrawnPos; int _point; bool _placesShown; - int _charPoint, _oldCharPoint; int _cursorIndex; bool _drawMap; Surface _iconSave; @@ -87,6 +86,8 @@ private: void highlightIcon(const Common::Point &pt); public: + bool _active; +public: Map(SherlockEngine *vm); const MapEntry &operator[](int idx) { return _points[idx]; } diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp index a1ead2c437..e5c6f847fb 100644 --- a/engines/sherlock/objects.cpp +++ b/engines/sherlock/objects.cpp @@ -81,6 +81,7 @@ void Sprite::setImageFrame() { * This adjusts the sprites position, as well as it's animation sequence: */ void Sprite::adjustSprite() { + Map &map = *_vm->_map; People &people = *_vm->_people; Scene &scene = *_vm->_scene; Talk &talk = *_vm->_talk; @@ -105,7 +106,7 @@ void Sprite::adjustSprite() { } } - if (_type == CHARACTER && !_vm->_onChessboard) { + if (_type == CHARACTER && !map._active) { if ((_position.y / 100) > LOWER_LIMIT) { _position.y = LOWER_LIMIT * 100; people.gotoStand(*this); @@ -120,12 +121,12 @@ void Sprite::adjustSprite() { _position.x = LEFT_LIMIT * 100; people.gotoStand(*this); } - } else if (!_vm->_onChessboard) { + } else if (!map._active) { _position.y = CLIP((int)_position.y, UPPER_LIMIT, LOWER_LIMIT); _position.x = CLIP((int)_position.x, LEFT_LIMIT, RIGHT_LIMIT); } - if (!_vm->_onChessboard || (_vm->_slowChess = !_vm->_slowChess)) + if (!map._active || (_vm->_slowChess = !_vm->_slowChess)) ++_frameNumber; if ((*_sequences)[_sequenceNumber][_frameNumber] == 0) { diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp index 0212be69b2..d247109a28 100644 --- a/engines/sherlock/people.cpp +++ b/engines/sherlock/people.cpp @@ -270,6 +270,7 @@ bool People::freeWalk() { * check for any obstacles in the path. */ void People::setWalking() { + Map &map = *_vm->_map; Scene &scene = *_vm->_scene; int oldDirection, oldFrame; Common::Point speed, delta; @@ -284,7 +285,7 @@ void People::setWalking() { oldFrame = _player._frameNumber; // Set speed to use horizontal and vertical movement - if (_vm->_onChessboard) { + if (map._active) { speed = Common::Point(MWALK_SPEED, MWALK_SPEED); } else { speed = Common::Point(XWALK_SPEED, YWALK_SPEED); @@ -321,10 +322,10 @@ void People::setWalking() { // Set the initial frame sequence for the left and right, as well // as settting the delta x depending on direction if (_walkDest.x < (_player._position.x / 100)) { - _player._sequenceNumber = _vm->_onChessboard ? MAP_LEFT : WALK_LEFT; + _player._sequenceNumber = map._active ? MAP_LEFT : WALK_LEFT; _player._delta.x = speed.x * -100; } else { - _player._sequenceNumber = _vm->_onChessboard ? MAP_RIGHT : WALK_RIGHT; + _player._sequenceNumber = map._active ? MAP_RIGHT : WALK_RIGHT; _player._delta.x = speed.x * 100; } @@ -348,7 +349,7 @@ void People::setWalking() { // See if the sequence needs to be changed for diagonal walking if (_player._delta.y > 150) { - if (!_vm->_onChessboard) { + if (!map._active) { switch (_player._sequenceNumber) { case WALK_LEFT: _player._sequenceNumber = WALK_DOWNLEFT; @@ -359,7 +360,7 @@ void People::setWalking() { } } } else if (_player._delta.y < -150) { - if (!_vm->_onChessboard) { + if (!map._active) { switch (_player._sequenceNumber) { case WALK_LEFT: _player._sequenceNumber = WALK_UPLEFT; @@ -447,7 +448,7 @@ void People::gotoStand(Sprite &sprite) { if (_oldWalkSequence != -1 || sprite._sequenceNumber == STOP_UP) sprite._frameNumber = 0; - if (_vm->_onChessboard) { + if (map._active) { sprite._sequenceNumber = 0; _data[AL]._position.x = (map[scene._charPoint].x - 6) * 100; _data[AL]._position.y = (map[scene._charPoint].x + 10) * 100; diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index 518a7aa86b..d880257406 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -47,7 +47,6 @@ SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gam _ui = nullptr; _useEpilogue2 = false; _loadingSavedGame = false; - _onChessboard = false; _slowChess = false; _keyPadSpeed = 0; _loadGameSlot = -1; diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h index 916c9cd253..ce126c0dcc 100644 --- a/engines/sherlock/sherlock.h +++ b/engines/sherlock/sherlock.h @@ -106,7 +106,6 @@ public: bool _loadingSavedGame; int _oldCharPoint; // Old scene Common::Point _over; // Old map position - bool _onChessboard; bool _slowChess; int _keyPadSpeed; int _loadGameSlot; |