Skip to content

Commit

Permalink
SHERLOCK: Fix display of Holmes' icon on overhead map
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Apr 23, 2015
1 parent 1ae176f commit 02e604c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
25 changes: 15 additions & 10 deletions engines/sherlock/map.cpp
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -238,7 +241,8 @@ int Map::show() {
screen.setFont(oldFont);
events.setCursor(ARROW);

return _charPoint;
_active = false;
return scene._charPoint;
}

/**
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion engines/sherlock/map.h
Expand Up @@ -62,7 +62,6 @@ class Map {
Common::Point _lDrawnPos;
int _point;
bool _placesShown;
int _charPoint, _oldCharPoint;
int _cursorIndex;
bool _drawMap;
Surface _iconSave;
Expand All @@ -86,6 +85,8 @@ class Map {
void restoreIcon();

void highlightIcon(const Common::Point &pt);
public:
bool _active;
public:
Map(SherlockEngine *vm);

Expand Down
7 changes: 4 additions & 3 deletions engines/sherlock/objects.cpp
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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) {
Expand Down
13 changes: 7 additions & 6 deletions engines/sherlock/people.cpp
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion engines/sherlock/sherlock.cpp
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion engines/sherlock/sherlock.h
Expand Up @@ -106,7 +106,6 @@ class SherlockEngine : public Engine {
bool _loadingSavedGame;
int _oldCharPoint; // Old scene
Common::Point _over; // Old map position
bool _onChessboard;
bool _slowChess;
int _keyPadSpeed;
int _loadGameSlot;
Expand Down

0 comments on commit 02e604c

Please sign in to comment.