2005-04-05 18:08:02 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2004 Ivan Dubrov
|
|
|
|
* Copyright (C) 2004-2005 The ScummVM project
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef GOB_MAP_H
|
|
|
|
#define GOB_MAP_H
|
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.
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kDirNW = 0x4700,
|
|
|
|
kDirN = 0x4800,
|
|
|
|
kDirNE = 0x4900,
|
|
|
|
kDirW = 0x4b00,
|
|
|
|
kDirE = 0x4d00,
|
|
|
|
kDirSW = 0x4f00,
|
|
|
|
kDirS = 0x5000,
|
|
|
|
kDirSE = 0x5100
|
|
|
|
};
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
#pragma START_PACK_STRUCTS
|
|
|
|
#define szMap_Point 4
|
|
|
|
typedef struct Map_Point {
|
|
|
|
int16 x;
|
|
|
|
int16 y;
|
|
|
|
} GCC_PACK Map_Point;
|
|
|
|
|
|
|
|
#define szMap_ItemPos 3
|
|
|
|
typedef struct Map_ItemPos {
|
2005-06-22 19:32:10 +00:00
|
|
|
int8 x;
|
|
|
|
int8 y;
|
|
|
|
int8 orient; // ??
|
2005-04-05 15:07:40 +00:00
|
|
|
} GCC_PACK Map_ItemPos;
|
|
|
|
#pragma END_PACK_STRUCTS
|
|
|
|
|
2005-06-22 19:32:10 +00:00
|
|
|
extern int8 map_passMap[28][26]; // [y][x]
|
2005-04-05 15:07:40 +00:00
|
|
|
extern int16 map_itemsMap[28][26]; // [y][x]
|
|
|
|
extern Map_Point map_wayPoints[40];
|
|
|
|
extern int16 map_nearestWayPoint;
|
|
|
|
extern int16 map_nearestDest;
|
|
|
|
|
|
|
|
extern int16 map_curGoblinX;
|
|
|
|
extern int16 map_curGoblinY;
|
|
|
|
extern int16 map_destX;
|
|
|
|
extern int16 map_destY;
|
2005-06-22 19:32:10 +00:00
|
|
|
extern int8 map_loadFromAvo;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
extern Map_ItemPos map_itemPoses[40];
|
|
|
|
extern char map_sourceFile[15];
|
|
|
|
|
This should fix a crash which could happen when placing several objects too
close to each other on the ground. (Happened to me on the first level after
destroying the voodoo doll, where I'd drop the banana, the soap and the
false nose close to each other on the ground after using them.)
Reasoning behind the change:
From what I understand, map_itemsMap[] contains information for each "cell"
of the map about which objects are there. Each cell can contain two objects
which are stored in the upper and lower byte of a 16-bit word.
When dropping an object, it is written into map_itemsMap[], but not just to
the indicated cell but also to a few of the surrounding ones. Presumably to
make it easier to pick it up afterwards.
When writing an object to a cell, we check if one of the bytes is already
occupied. If it is, write to the other byte. Otherwise, write to that byte.
(If both bytes are occupied, one will be overwritten.)
The old code assumed that if one byte was free at position (x,y) the same
byte would automatically be the free one in the surrounding cells. This
could cause bad values in the array, since the item was added to an
existing value, rather than replacing it.
This new code makes the check for each cell that is modified. (It also gets
rid of some code duplication.)
svn-id: r17851
2005-04-28 10:34:48 +00:00
|
|
|
void map_placeItem(int16 x, int16 y, int16 id);
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 map_getDirection(int16 x0, int16 y0, int16 x1, int16 y1);
|
|
|
|
void map_findNearestToGob(void);
|
|
|
|
void map_findNearestToDest(void);
|
|
|
|
int16 map_checkDirectPath(int16 x0, int16 y0, int16 x1, int16 y1);
|
|
|
|
int16 map_checkLongPath(int16 x0, int16 y0, int16 x1, int16 y1, int16 i0, int16 i1);
|
|
|
|
int16 map_optimizePoints(int16 xPos, int16 yPos);
|
|
|
|
void map_loadItemToObject(void);
|
|
|
|
void map_loadMapObjects(char *avjFile);
|
2005-06-22 19:32:10 +00:00
|
|
|
void map_loadDataFromAvo(int8 *dest, int16 size);
|
2005-04-05 15:07:40 +00:00
|
|
|
void map_loadMapsInitGobs(void);
|
|
|
|
|
|
|
|
} // End of namespace Gob
|
|
|
|
|
|
|
|
#endif /* __MAP_H */
|