2005-04-05 18:08:02 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2004 Ivan Dubrov
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2004-2006 The ScummVM project
|
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.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* 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
|
|
|
*
|
2006-02-11 10:11:37 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
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-05-29 18:24:52 +00:00
|
|
|
#include "gob/util.h"
|
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 {
|
|
|
|
|
2005-07-10 13:37:03 +00:00
|
|
|
// The same numeric values are also used for the arrow keys.
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
class Map {
|
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
kDirNW = 0x4700,
|
|
|
|
kDirN = 0x4800,
|
|
|
|
kDirNE = 0x4900,
|
|
|
|
kDirW = 0x4b00,
|
|
|
|
kDirE = 0x4d00,
|
|
|
|
kDirSW = 0x4f00,
|
|
|
|
kDirS = 0x5000,
|
|
|
|
kDirSE = 0x5100
|
|
|
|
};
|
2005-07-10 13:37:03 +00:00
|
|
|
|
2006-07-22 17:28:48 +00:00
|
|
|
#include <common/pack-start.h> // START STRUCT PACKING
|
2005-12-18 09:57:44 +00:00
|
|
|
|
2006-01-29 02:27:10 +00:00
|
|
|
struct Point {
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 x;
|
|
|
|
int16 y;
|
2006-05-29 18:24:52 +00:00
|
|
|
int16 field_2; // Gob2
|
2006-07-21 21:25:17 +00:00
|
|
|
};
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
#define szMap_ItemPos 3
|
2005-12-18 09:57:44 +00:00
|
|
|
|
2006-01-29 02:27:10 +00:00
|
|
|
struct ItemPos {
|
2006-01-03 23:14:39 +00:00
|
|
|
int8 x;
|
|
|
|
int8 y;
|
|
|
|
int8 orient; // ??
|
2006-07-21 21:25:17 +00:00
|
|
|
};
|
2005-12-18 09:57:44 +00:00
|
|
|
|
2006-07-22 17:28:48 +00:00
|
|
|
#include <common/pack-end.h> // END STRUCT PACKING
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-05-29 18:24:52 +00:00
|
|
|
int16 _mapWidth;
|
|
|
|
int16 _mapHeight;
|
|
|
|
int16 _screenWidth;
|
|
|
|
int16 _tilesWidth;
|
|
|
|
int16 _tilesHeight;
|
|
|
|
int16 _passWidth;
|
|
|
|
bool _bigTiles;
|
|
|
|
|
|
|
|
int8 *_passMap; // [y * _mapWidth + x], getPass(x, y);
|
|
|
|
int16 **_itemsMap; // [y][x]
|
|
|
|
int16 _wayPointsCount;
|
|
|
|
Point *_wayPoints;
|
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;
|
|
|
|
int8 _loadFromAvo;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-04 01:23:20 +00:00
|
|
|
ItemPos _itemPoses[40];
|
|
|
|
char _sourceFile[15];
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
void placeItem(int16 x, int16 y, int16 id);
|
|
|
|
|
|
|
|
int16 getDirection(int16 x0, int16 y0, int16 x1, int16 y1);
|
2006-06-07 18:49:20 +00:00
|
|
|
int16 checkDirectPath(Mult::Mult_Object *obj, int16 x0, int16 y0, int16 x1, int16 y1);
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 checkLongPath(int16 x0, int16 y0, int16 x1, int16 y1, int16 i0, int16 i1);
|
|
|
|
void loadItemToObject(void);
|
|
|
|
void loadDataFromAvo(char *dest, int16 size);
|
|
|
|
void loadMapsInitGobs(void);
|
|
|
|
|
2006-05-29 18:24:52 +00:00
|
|
|
virtual int8 getPass(int x, int y, int heightOff = -1) = 0;
|
|
|
|
virtual void setPass(int x, int y, int8 pass, int heightOff = -1) = 0;
|
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
virtual void loadMapObjects(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
|
|
|
Map(GobEngine *vm);
|
2006-05-11 19:43:30 +00:00
|
|
|
virtual ~Map() {};
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
protected:
|
2006-01-04 01:23:20 +00:00
|
|
|
char *_avoDataPtr;
|
2006-01-03 23:14:39 +00:00
|
|
|
GobEngine *_vm;
|
|
|
|
|
|
|
|
int16 findNearestWayPoint(int16 x, int16 y);
|
|
|
|
uint16 loadFromAvo_LE_UINT16();
|
2005-12-30 18:39:01 +00:00
|
|
|
};
|
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
class Map_v1 : public Map {
|
|
|
|
public:
|
|
|
|
virtual void loadMapObjects(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
|
|
|
|
|
|
|
virtual inline int8 getPass(int x, int y, int heightOff = -1) {
|
|
|
|
return _passMap[y * _mapWidth + x];
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual inline void setPass(int x, int y, int8 pass, int heightOff = -1) {
|
|
|
|
_passMap[y * _mapWidth + x] = pass;
|
|
|
|
}
|
2006-05-11 19:43:30 +00:00
|
|
|
|
|
|
|
Map_v1(GobEngine *vm);
|
2006-05-29 18:24:52 +00:00
|
|
|
virtual ~Map_v1();
|
2006-05-11 19:43:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Map_v2 : public Map_v1 {
|
|
|
|
public:
|
|
|
|
virtual void loadMapObjects(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
|
|
|
|
|
|
|
virtual inline int8 getPass(int x, int y, int heightOff = -1) {
|
|
|
|
if (heightOff == -1)
|
|
|
|
heightOff = _passWidth;
|
2006-07-08 16:37:23 +00:00
|
|
|
return _passMap[y * heightOff + x];
|
2006-05-29 18:24:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual inline void setPass(int x, int y, int8 pass, int heightOff = -1) {
|
|
|
|
if (heightOff == -1)
|
|
|
|
heightOff = _passWidth;
|
2006-07-08 16:37:23 +00:00
|
|
|
_passMap[y * heightOff + x] = pass;
|
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();
|
2006-05-11 19:43:30 +00:00
|
|
|
};
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
} // End of namespace Gob
|
|
|
|
|
|
|
|
#endif /* __MAP_H */
|