2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2005-04-05 18:08:02 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2005-04-05 18:08:02 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2005-04-05 18:08:02 +00:00
|
|
|
* GNU General Public License for more details.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2005-04-05 18:08:02 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2005-04-09 19:19:54 +00:00
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-04-05 18:08:02 +00:00
|
|
|
*
|
|
|
|
*/
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2005-04-05 18:08:02 +00:00
|
|
|
#ifndef GOB_MAP_H
|
|
|
|
#define GOB_MAP_H
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-06-07 18:49:20 +00:00
|
|
|
#include "gob/mult.h"
|
2006-05-29 18:24:52 +00:00
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
namespace Gob {
|
|
|
|
|
2010-10-30 17:24:52 +00:00
|
|
|
enum RelativeDirection {
|
|
|
|
kRelDirNone = 0 ,
|
|
|
|
|
|
|
|
kRelDirLeft = (1 << 0),
|
|
|
|
kRelDirUp = (1 << 1),
|
|
|
|
kRelDirRight = (1 << 2),
|
|
|
|
kRelDirDown = (1 << 3),
|
|
|
|
|
|
|
|
kRelDirLeftUp = kRelDirLeft | kRelDirUp,
|
|
|
|
kRelDirLeftDown = kRelDirLeft | kRelDirDown,
|
|
|
|
kRelDirRightUp = kRelDirRight | kRelDirUp,
|
|
|
|
kRelDirRightDown = kRelDirRight | kRelDirDown
|
|
|
|
};
|
|
|
|
|
2005-07-10 13:37:03 +00:00
|
|
|
// The same numeric values are also used for the arrow keys.
|
2010-10-30 17:24:52 +00:00
|
|
|
enum Direction {
|
|
|
|
kDirNone = 0x0000,
|
|
|
|
kDirNW = 0x4700,
|
|
|
|
kDirN = 0x4800,
|
|
|
|
kDirNE = 0x4900,
|
|
|
|
kDirW = 0x4B00,
|
|
|
|
kDirE = 0x4D00,
|
|
|
|
kDirSW = 0x4F00,
|
|
|
|
kDirS = 0x5000,
|
|
|
|
kDirSE = 0x5100
|
|
|
|
};
|
2005-07-10 13:37:03 +00:00
|
|
|
|
2010-10-30 17:26:49 +00:00
|
|
|
struct WayPoint {
|
|
|
|
int16 x;
|
|
|
|
int16 y;
|
|
|
|
int16 notWalkable;
|
|
|
|
};
|
|
|
|
|
2010-10-30 17:27:53 +00:00
|
|
|
struct ItemPos {
|
|
|
|
int8 x;
|
|
|
|
int8 y;
|
|
|
|
int8 orient;
|
|
|
|
};
|
|
|
|
|
2010-10-30 17:26:49 +00:00
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
class Map {
|
|
|
|
public:
|
2006-01-04 01:23:20 +00:00
|
|
|
int16 _nearestWayPoint;
|
|
|
|
int16 _nearestDest;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-05-29 18:24:52 +00:00
|
|
|
int16 _curGoblinX;
|
2006-01-04 01:23:20 +00:00
|
|
|
int16 _curGoblinY;
|
|
|
|
int16 _destX;
|
|
|
|
int16 _destY;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2011-01-30 13:14:32 +00:00
|
|
|
bool _mapUnknownBool;
|
|
|
|
|
2006-01-04 01:23:20 +00:00
|
|
|
ItemPos _itemPoses[40];
|
|
|
|
char _sourceFile[15];
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2010-10-30 17:25:29 +00:00
|
|
|
Map(GobEngine *vm);
|
|
|
|
virtual ~Map();
|
|
|
|
|
2010-10-30 17:27:23 +00:00
|
|
|
uint8 getVersion() const;
|
|
|
|
|
2010-10-30 17:28:27 +00:00
|
|
|
int16 getMapWidth() const;
|
|
|
|
int16 getMapHeight() const;
|
|
|
|
|
|
|
|
int16 getScreenWidth() const;
|
|
|
|
int16 getScreenHeight() const;
|
|
|
|
|
|
|
|
int16 getTilesWidth() const;
|
|
|
|
int16 getTilesHeight() const;
|
|
|
|
|
|
|
|
bool hasBigTiles() const;
|
|
|
|
|
2010-10-30 17:25:29 +00:00
|
|
|
int8 getPass(int x, int y, int width = -1) const;
|
|
|
|
void setPass(int x, int y, int8 pass, int width = -1);
|
|
|
|
|
2010-10-30 17:26:49 +00:00
|
|
|
const WayPoint &getWayPoint(int n) const;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void findNearestWalkable(int16 &gobDestX, int16 &gobDestY,
|
|
|
|
int16 mouseX, int16 mouseY);
|
|
|
|
|
2010-10-30 17:28:54 +00:00
|
|
|
int16 getItem(int x, int y) const;
|
|
|
|
void setItem(int x, int y, int16 item);
|
2006-01-03 23:14:39 +00:00
|
|
|
void placeItem(int16 x, int16 y, int16 id);
|
|
|
|
|
2010-10-25 03:38:34 +00:00
|
|
|
Direction getDirection(int16 x0, int16 y0, int16 x1, int16 y1);
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 checkDirectPath(Mult::Mult_Object *obj, int16 x0,
|
|
|
|
int16 y0, int16 x1, int16 y1);
|
|
|
|
int16 checkLongPath(int16 x0, int16 y0,
|
|
|
|
int16 x1, int16 y1, int16 i0, int16 i1);
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void loadMapsInitGobs();
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
virtual void loadMapObjects(const char *avjFile) = 0;
|
2006-06-07 18:49:20 +00:00
|
|
|
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;
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
protected:
|
2010-10-30 17:26:06 +00:00
|
|
|
GobEngine *_vm;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
bool _loadFromAvo;
|
|
|
|
|
2010-10-30 17:27:23 +00:00
|
|
|
uint8 _mapVersion;
|
|
|
|
|
2010-10-30 17:28:27 +00:00
|
|
|
int16 _mapWidth;
|
|
|
|
int16 _mapHeight;
|
|
|
|
|
|
|
|
int16 _screenWidth;
|
|
|
|
int16 _screenHeight;
|
|
|
|
|
|
|
|
int16 _tilesWidth;
|
|
|
|
int16 _tilesHeight;
|
|
|
|
|
|
|
|
bool _bigTiles;
|
|
|
|
|
2010-10-30 17:26:06 +00:00
|
|
|
int16 _passWidth;
|
|
|
|
int8 *_passMap; // [y * _mapWidth + x], getPass(x, y);
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2010-10-30 17:26:49 +00:00
|
|
|
int16 _wayPointCount;
|
|
|
|
WayPoint *_wayPoints;
|
|
|
|
|
2010-10-30 17:28:27 +00:00
|
|
|
int16 **_itemsMap; // [y][x]
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 findNearestWayPoint(int16 x, int16 y);
|
2010-10-25 03:38:34 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Move the x and y values according to the direction
|
|
|
|
void moveDirection(Direction dir, int16 &x, int16 &y);
|
2005-12-30 18:39:01 +00:00
|
|
|
};
|
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
class Map_v1 : public Map {
|
|
|
|
public:
|
2007-04-02 11:05:09 +00:00
|
|
|
virtual void loadMapObjects(const char *avjFile);
|
2006-06-07 18:49:20 +00:00
|
|
|
virtual void findNearestToGob(Mult::Mult_Object *obj);
|
|
|
|
virtual void findNearestToDest(Mult::Mult_Object *obj);
|
|
|
|
virtual void optimizePoints(Mult::Mult_Object *obj, int16 x, int16 y);
|
2006-05-29 18:24:52 +00:00
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
Map_v1(GobEngine *vm);
|
2006-05-29 18:24:52 +00:00
|
|
|
virtual ~Map_v1();
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
protected:
|
2009-11-02 21:54:57 +00:00
|
|
|
void init();
|
2007-03-20 14:51:57 +00:00
|
|
|
void loadSounds(Common::SeekableReadStream &data);
|
|
|
|
void loadGoblins(Common::SeekableReadStream &data, uint32 gobsPos);
|
|
|
|
void loadObjects(Common::SeekableReadStream &data, uint32 objsPos);
|
|
|
|
void loadItemToObject(Common::SeekableReadStream &data);
|
2006-05-11 19:43:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Map_v2 : public Map_v1 {
|
|
|
|
public:
|
2007-04-02 11:05:09 +00:00
|
|
|
virtual void loadMapObjects(const char *avjFile);
|
2006-06-07 18:49:20 +00:00
|
|
|
virtual void findNearestToGob(Mult::Mult_Object *obj);
|
|
|
|
virtual void findNearestToDest(Mult::Mult_Object *obj);
|
|
|
|
virtual void optimizePoints(Mult::Mult_Object *obj, int16 x, int16 y);
|
2006-05-29 18:24:52 +00:00
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
Map_v2(GobEngine *vm);
|
2006-06-10 14:37:48 +00:00
|
|
|
virtual ~Map_v2();
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void loadGoblinStates(Common::SeekableReadStream &data, int index);
|
2006-05-11 19:43:30 +00:00
|
|
|
};
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
} // End of namespace Gob
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
#endif // GOB_MAP_H
|