From 1612a96285d4da48208fad2f704a6335925deac5 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 30 Oct 2010 17:25:29 +0000 Subject: GOB: Unify Map_v1::/Map_v2::getPass()/setPass() svn-id: r53947 --- engines/gob/map.cpp | 24 ++++++++++++++++++++++ engines/gob/map.h | 56 ++++++-------------------------------------------- engines/gob/map_v1.cpp | 3 ++- 3 files changed, 32 insertions(+), 51 deletions(-) (limited to 'engines/gob') diff --git a/engines/gob/map.cpp b/engines/gob/map.cpp index 03708298d7..ba02c1727e 100644 --- a/engines/gob/map.cpp +++ b/engines/gob/map.cpp @@ -76,6 +76,30 @@ Map::~Map() { delete[] _wayPoints; } +int8 Map::getPass(int x, int y, int width) const { + if (!_passMap) + return 0; + + if ((x < 0) || (y < 0) || (x >= _mapWidth) || (y >= _mapHeight)) + return 0; + + if (width == -1) + width = _passWidth; + return _passMap[y * width + x]; +} + +void Map::setPass(int x, int y, int8 pass, int width) { + if (!_passMap) + return; + + if ((x < 0) || (y < 0) || (x >= _mapWidth) || (y >= _mapHeight)) + return; + + if (width == -1) + width = _passWidth; + _passMap[y * width + x] = pass; +} + void Map::placeItem(int16 x, int16 y, int16 id) { if ((getItem(x, y) & 0xFF00) != 0) setItem(x, y, (getItem(x, y) & 0xFF00) | id); diff --git a/engines/gob/map.h b/engines/gob/map.h index a38826d1d0..a3919cdeb7 100644 --- a/engines/gob/map.h +++ b/engines/gob/map.h @@ -103,6 +103,12 @@ public: ItemPos _itemPoses[40]; char _sourceFile[15]; + Map(GobEngine *vm); + virtual ~Map(); + + int8 getPass(int x, int y, int width = -1) const; + void setPass(int x, int y, int8 pass, int width = -1); + void findNearestWalkable(int16 &gobDestX, int16 &gobDestY, int16 mouseX, int16 mouseY); @@ -120,17 +126,11 @@ public: virtual int16 getItem(int x, int y) = 0; virtual void setItem(int x, int y, int16 item) = 0; - virtual int8 getPass(int x, int y, int heightOff = -1) = 0; - virtual void setPass(int x, int y, int8 pass, int heightOff = -1) = 0; - virtual void loadMapObjects(const char *avjFile) = 0; virtual void findNearestToGob(Mult::Mult_Object *obj) = 0; virtual void findNearestToDest(Mult::Mult_Object *obj) = 0; virtual void optimizePoints(Mult::Mult_Object *obj, int16 x, int16 y) = 0; - Map(GobEngine *vm); - virtual ~Map(); - protected: bool _loadFromAvo; @@ -167,26 +167,6 @@ public: _itemsMap[y][x] = item; } - virtual int8 getPass(int x, int y, int heightOff = -1) { - if (!_passMap) - return 0; - - if ((x < 0) || (y < 0) || (x >= _mapWidth) || (y >= _mapHeight)) - return 0; - - return _passMap[y * _mapWidth + x]; - } - - virtual void setPass(int x, int y, int8 pass, int heightOff = -1) { - if (!_passMap) - return; - - if ((x < 0) || (y < 0) || (x >= _mapWidth) || (y >= _mapHeight)) - return; - - _passMap[y * _mapWidth + x] = pass; - } - Map_v1(GobEngine *vm); virtual ~Map_v1(); @@ -205,30 +185,6 @@ public: virtual void findNearestToDest(Mult::Mult_Object *obj); virtual void optimizePoints(Mult::Mult_Object *obj, int16 x, int16 y); - virtual int8 getPass(int x, int y, int heightOff = -1) { - if (!_passMap) - return 0; - - if ((x < 0) || (y < 0) || (x >= _mapWidth) || (y >= _mapHeight)) - return 0; - - if (heightOff == -1) - heightOff = _passWidth; - return _passMap[y * heightOff + x]; - } - - virtual void setPass(int x, int y, int8 pass, int heightOff = -1) { - if (!_passMap) - return; - - if ((x < 0) || (y < 0) || (x >= _mapWidth) || (y >= _mapHeight)) - return; - - if (heightOff == -1) - heightOff = _passWidth; - _passMap[y * heightOff + x] = pass; - } - Map_v2(GobEngine *vm); virtual ~Map_v2(); diff --git a/engines/gob/map_v1.cpp b/engines/gob/map_v1.cpp index d8898c83d3..9503c97260 100644 --- a/engines/gob/map_v1.cpp +++ b/engines/gob/map_v1.cpp @@ -44,7 +44,8 @@ void Map_v1::init() { if (_passMap || _itemsMap) return; - _mapWidth = 26; + _passWidth = 26; + _mapWidth = 26; _mapHeight = 28; _passMap = new int8[_mapHeight * _mapWidth]; -- cgit v1.2.3