Skip to content

Commit

Permalink
SHERLOCK: Fix icon disappearing when moving to Covent Gradens on map
Browse files Browse the repository at this point in the history
Co-ordinates in Sherlock are frequently multiplied by 100.
Thus, on the overland map, the values can go up to 64000, which overflows
the signed 16-bit values allowed by the standard Common::Point class
  • Loading branch information
dreammaster committed Apr 29, 2015
1 parent 7be4106 commit 34a7ec7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
6 changes: 3 additions & 3 deletions engines/sherlock/map.h
Expand Up @@ -68,7 +68,7 @@ class Map {
ImageFile *_shapes;
ImageFile *_iconShapes;
byte _sequences[MAX_HOLMES_SEQUENCE][MAX_FRAME];
Common::Point _lDrawnPos;
Point32 _lDrawnPos;
int _point;
bool _placesShown;
int _cursorIndex;
Expand Down Expand Up @@ -96,8 +96,8 @@ class Map {
void highlightIcon(const Common::Point &pt);
public:
bool _active;
Common::Point _overPos;
Common::Point _bigPos;
Point32 _overPos;
Point32 _bigPos;
int _charPoint, _oldCharPoint;
public:
Map(SherlockEngine *vm);
Expand Down
2 changes: 1 addition & 1 deletion engines/sherlock/objects.cpp
Expand Up @@ -184,7 +184,7 @@ void Sprite::checkSprite() {
Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk;
Common::Point pt;
Point32 pt;
Common::Rect objBounds;
Common::Point spritePt(_position.x / 100, _position.y / 100);

Expand Down
23 changes: 21 additions & 2 deletions engines/sherlock/objects.h
Expand Up @@ -79,6 +79,25 @@ enum {
#define FLIP_CODE (64 + 128)
#define SOUND_CODE (34 + 128)

class Point32 {
public:
int x;
int y;

Point32() : x(0), y(0) {}
Point32(int x1, int y1) : x(x1), y(y1) {}
Point32(const Common::Point &pt) : x(pt.x), y(pt.y) {}

bool operator==(const Point32 &p) const { return x == p.x && y == p.y; }
bool operator!=(const Point32 &p) const { return x != p.x || y != p.y; }
Point32 operator+(const Point32 &delta) const { return Point32(x + delta.x, y + delta.y); }
Point32 operator-(const Point32 &delta) const { return Point32(x - delta.x, y - delta.y); }
operator Common::Point() { return Common::Point(x, y); }

void operator+=(const Point32 &delta) { x += delta.x; y += delta.y; }
void operator-=(const Point32 &delta) { x -= delta.x; y -= delta.y; }
};

class Sprite {
private:
static SherlockEngine *_vm;
Expand All @@ -95,8 +114,8 @@ class Sprite {
int _allow; // Allowed menu commands - ObjectAllow
int _frameNumber; // Frame number in rame sequence to draw
int _sequenceNumber; // Sequence being used
Common::Point _position; // Current position
Common::Point _delta; // Momvement delta
Point32 _position; // Current position
Point32 _delta; // Momvement delta
Common::Point _oldPosition; // Old position
Common::Point _oldSize; // Image's old size
Common::Point _goto; // Walk destination
Expand Down

0 comments on commit 34a7ec7

Please sign in to comment.