aboutsummaryrefslogtreecommitdiff
path: root/gob
diff options
context:
space:
mode:
authorMax Horn2005-12-30 18:39:01 +0000
committerMax Horn2005-12-30 18:39:01 +0000
commit3b0d3defa73512c4bcef4d59a4b667829cdb7dc7 (patch)
tree62de776adfac9c71147459620057ae6a66573cd6 /gob
parent1bfae752517cce99ad9cfbd7da7e6b14742700ab (diff)
downloadscummvm-rg350-3b0d3defa73512c4bcef4d59a4b667829cdb7dc7.tar.gz
scummvm-rg350-3b0d3defa73512c4bcef4d59a4b667829cdb7dc7.tar.bz2
scummvm-rg350-3b0d3defa73512c4bcef4d59a4b667829cdb7dc7.zip
Added kMapHeight and kMapWidth constants
svn-id: r19863
Diffstat (limited to 'gob')
-rw-r--r--gob/goblin.cpp36
-rw-r--r--gob/map.cpp40
-rw-r--r--gob/map.h5
3 files changed, 43 insertions, 38 deletions
diff --git a/gob/goblin.cpp b/gob/goblin.cpp
index 5313bb5a23..f88514ab83 100644
--- a/gob/goblin.cpp
+++ b/gob/goblin.cpp
@@ -720,11 +720,11 @@ void gob_adjustDest(int16 posX, int16 posY) {
}
for (i = 1;
- (i + gob_pressedMapX) < 26
+ (i + gob_pressedMapX) < kMapWidth
&& map_passMap[gob_pressedMapY][gob_pressedMapX + i] == 0;
i++);
- if (gob_pressedMapX + i < 26) {
+ if (gob_pressedMapX + i < kMapWidth) {
deltaPix = (i * 12) - (posX % 12);
if (resDelta == -1 || deltaPix < resDeltaPix) {
resDeltaPix = deltaPix;
@@ -734,11 +734,11 @@ void gob_adjustDest(int16 posX, int16 posY) {
}
for (i = 1;
- (i + gob_pressedMapY) < 28
+ (i + gob_pressedMapY) < kMapHeight
&& map_passMap[gob_pressedMapY + i][gob_pressedMapX] == 0;
i++);
- if (gob_pressedMapY + i < 28) {
+ if (gob_pressedMapY + i < kMapHeight) {
deltaPix = (i * 6) - (posY % 6);
if (resDelta == -1 || deltaPix < resDeltaPix) {
resDeltaPix = deltaPix;
@@ -790,11 +790,11 @@ void gob_adjustTarget(void) {
&& map_itemsMap[gob_pressedMapY - 1][gob_pressedMapX] !=
0) {
gob_pressedMapY--;
- } else if (gob_pressedMapX < 25
+ } else if (gob_pressedMapX < kMapWidth - 1
&& map_itemsMap[gob_pressedMapY][gob_pressedMapX + 1] !=
0) {
gob_pressedMapX++;
- } else if (gob_pressedMapX < 25 && gob_pressedMapY > 0
+ } else if (gob_pressedMapX < kMapWidth - 1 && gob_pressedMapY > 0
&& map_itemsMap[gob_pressedMapY - 1][gob_pressedMapX +
1] != 0) {
gob_pressedMapY--;
@@ -2089,8 +2089,8 @@ void gob_pickItem(int16 indexToPocket, int16 idToPocket) {
gob_itemIndInPocket = indexToPocket;
gob_itemIdInPocket = idToPocket;
- for (y = 0; y < 28; y++) {
- for (x = 0; x < 26; x++) {
+ for (y = 0; y < kMapHeight; y++) {
+ for (x = 0; x < kMapWidth; x++) {
if (gob_itemByteFlag == 1) {
if (((map_itemsMap[y][x] & 0xff00) >> 8) ==
idToPocket)
@@ -2156,7 +2156,7 @@ void gob_placeItem(int16 indexInPocket, int16 idInPocket) {
}
if (lookDir == 4) {
- if (xPos < 25) {
+ if (xPos < kMapWidth - 1) {
map_placeItem(xPos + 1, yPos, idInPocket);
if (yPos > 0) {
@@ -2205,8 +2205,8 @@ void gob_swapItems(int16 indexToPick, int16 idToPick) {
gob_itemIdInPocket = idToPick;
if (gob_itemByteFlag == 0) {
- for (y = 0; y < 28; y++) {
- for (x = 0; x < 26; x++) {
+ for (y = 0; y < kMapHeight; y++) {
+ for (x = 0; x < kMapWidth; x++) {
if ((map_itemsMap[y][x] & 0xff) == idToPick)
map_itemsMap[y][x] =
(map_itemsMap[y][x] & 0xff00) +
@@ -2215,8 +2215,8 @@ void gob_swapItems(int16 indexToPick, int16 idToPick) {
}
} else {
- for (y = 0; y < 28; y++) {
- for (x = 0; x < 26; x++) {
+ for (y = 0; y < kMapHeight; y++) {
+ for (x = 0; x < kMapWidth; x++) {
if (((map_itemsMap[y][x] & 0xff00) >> 8) ==
idToPick)
map_itemsMap[y][x] =
@@ -2594,8 +2594,8 @@ void gob_interFunc(void) {
item = VAR(item);
}
- for (y = 0; y < 28; y++) {
- for (x = 0; x < 26; x++) {
+ for (y = 0; y < kMapHeight; y++) {
+ for (x = 0; x < kMapWidth; x++) {
if ((map_itemsMap[y][x] & 0xff) == item) {
map_itemsMap[y][x] &= 0xff00;
} else if (((map_itemsMap[y][x] & 0xff00) >> 8)
@@ -2605,7 +2605,7 @@ void gob_interFunc(void) {
}
}
- if (xPos < 25) {
+ if (xPos < kMapWidth - 1) {
if (yPos > 0) {
if ((map_itemsMap[yPos][xPos] & 0xff00) != 0 ||
(map_itemsMap[yPos - 1][xPos] & 0xff00) !=
@@ -2712,14 +2712,14 @@ void gob_interFunc(void) {
break;
}
- if (xPos < 24 && map_passMap[yPos][xPos + 2] == 1) {
+ if (xPos < kMapWidth - 2 && map_passMap[yPos][xPos + 2] == 1) {
map_itemPoses[item].x = xPos + 2;
map_itemPoses[item].y = yPos;
map_itemPoses[item].orient = 0;
break;
}
- if (xPos < 25 && map_passMap[yPos][xPos + 1] == 1) {
+ if (xPos < kMapWidth - 1 && map_passMap[yPos][xPos + 1] == 1) {
map_itemPoses[item].x = xPos + 1;
map_itemPoses[item].y = yPos;
map_itemPoses[item].orient = 0;
diff --git a/gob/map.cpp b/gob/map.cpp
index afd51b6f01..955742503a 100644
--- a/gob/map.cpp
+++ b/gob/map.cpp
@@ -31,8 +31,8 @@
namespace Gob {
-int8 map_passMap[28][26]; // [y][x]
-int16 map_itemsMap[28][26]; // [y][x]
+int8 map_passMap[kMapHeight][kMapWidth]; // [y][x]
+int16 map_itemsMap[kMapHeight][kMapWidth]; // [y][x]
Map_Point map_wayPoints[40];
int16 map_nearestWayPoint = 0;
@@ -68,7 +68,7 @@ int16 map_getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
if (x0 == x1 && y0 == y1)
return 0;
- if (x1 < 0 || x1 > 25 || y1 < 0 || y1 > 27)
+ if (!(x1 >= 0 && x1 < kMapWidth && y1 >= 0 && y1 < kMapHeight))
return 0;
if (y1 > y0)
@@ -108,7 +108,7 @@ int16 map_getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
}
if (dir == kRight) {
- if (x0 + 1 < 26 && map_passMap[y0][x0 + 1] != 0)
+ if (x0 + 1 < kMapWidth && map_passMap[y0][x0 + 1] != 0)
return kDirE;
return 0;
}
@@ -121,7 +121,7 @@ int16 map_getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
&& map_passMap[y0 - 1][x0 - 1] != 0)
return kDirNW;
- if (y0 - 1 >= 0 && x0 + 1 < 26
+ if (y0 - 1 >= 0 && x0 + 1 < kMapWidth
&& map_passMap[y0 - 1][x0 + 1] != 0)
return kDirNE;
@@ -129,14 +129,14 @@ int16 map_getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
}
if (dir == kDown) {
- if (y0 + 1 < 28 && map_passMap[y0 + 1][x0] != 0)
+ if (y0 + 1 < kMapHeight && map_passMap[y0 + 1][x0] != 0)
return kDirS;
- if (y0 + 1 < 28 && x0 - 1 >= 0
+ if (y0 + 1 < kMapHeight && x0 - 1 >= 0
&& map_passMap[y0 + 1][x0 - 1] != 0)
return kDirSW;
- if (y0 + 1 < 28 && x0 + 1 < 26
+ if (y0 + 1 < kMapHeight && x0 + 1 < kMapWidth
&& map_passMap[y0 + 1][x0 + 1] != 0)
return kDirSE;
@@ -144,28 +144,28 @@ int16 map_getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
}
if (dir == (kRight | kUp)) {
- if (y0 - 1 >= 0 && x0 + 1 < 26
+ if (y0 - 1 >= 0 && x0 + 1 < kMapWidth
&& map_passMap[y0 - 1][x0 + 1] != 0)
return kDirNE;
if (y0 - 1 >= 0 && map_passMap[y0 - 1][x0] != 0)
return kDirN;
- if (x0 + 1 < 26 && map_passMap[y0][x0 + 1] != 0)
+ if (x0 + 1 < kMapWidth && map_passMap[y0][x0 + 1] != 0)
return kDirE;
return 0;
}
if (dir == (kRight | kDown)) {
- if (x0 + 1 < 26 && y0 + 1 < 28
+ if (x0 + 1 < kMapWidth && y0 + 1 < kMapHeight
&& map_passMap[y0 + 1][x0 + 1] != 0)
return kDirSE;
- if (y0 + 1 < 28 && map_passMap[y0 + 1][x0] != 0)
+ if (y0 + 1 < kMapHeight && map_passMap[y0 + 1][x0] != 0)
return kDirS;
- if (x0 + 1 < 26 && map_passMap[y0][x0 + 1] != 0)
+ if (x0 + 1 < kMapWidth && map_passMap[y0][x0 + 1] != 0)
return kDirE;
return 0;
@@ -186,11 +186,11 @@ int16 map_getDirection(int16 x0, int16 y0, int16 x1, int16 y1) {
}
if (dir == (kLeft | kDown)) {
- if (x0 - 1 >= 0 && y0 + 1 < 28
+ if (x0 - 1 >= 0 && y0 + 1 < kMapHeight
&& map_passMap[y0 + 1][x0 - 1] != 0)
return kDirSW;
- if (y0 + 1 < 28 && map_passMap[y0 + 1][x0] != 0)
+ if (y0 + 1 < kMapHeight && map_passMap[y0 + 1][x0] != 0)
return kDirS;
if (x0 - 1 >= 0 && map_passMap[y0][x0 - 1] != 0)
@@ -211,8 +211,8 @@ int16 map_findNearestWayPoint(int16 x, int16 y) {
for (i = 0; i < 40; i++) {
if (map_wayPoints[i].x < 0 ||
- map_wayPoints[i].x > 25 ||
- map_wayPoints[i].y < 0 || map_wayPoints[i].y > 27)
+ map_wayPoints[i].x >= kMapWidth ||
+ map_wayPoints[i].y < 0 || map_wayPoints[i].y >= kMapHeight)
return -1;
tmp = ABS(x - map_wayPoints[i].x) + ABS(y - map_wayPoints[i].y);
@@ -454,10 +454,10 @@ void map_loadMapObjects(char *avjFile) {
data_closeData(handle);
map_avoDataPtr = data_getData(avoName);
dataBuf = map_avoDataPtr;
- map_loadDataFromAvo((char *)map_passMap, 28 * 26);
+ map_loadDataFromAvo((char *)map_passMap, kMapHeight * kMapWidth);
- for (y = 0; y < 28; y++) {
- for (x = 0; x < 26; x++) {
+ for (y = 0; y < kMapHeight; y++) {
+ for (x = 0; x < kMapWidth; x++) {
map_loadDataFromAvo(&item, 1);
map_itemsMap[y][x] = item;
}
diff --git a/gob/map.h b/gob/map.h
index 5e4ac8f86a..c9372d5790 100644
--- a/gob/map.h
+++ b/gob/map.h
@@ -54,6 +54,11 @@ typedef struct Map_Point {
#pragma END_PACK_STRUCTS
+enum {
+ kMapWidth = 26,
+ kMapHeight = 28
+};
+
extern int8 map_passMap[28][26]; // [y][x]
extern int16 map_itemsMap[28][26]; // [y][x]
extern Map_Point map_wayPoints[40];