[Scummvm-cvs-logs] CVS: scummvm/gob goblin.cpp,1.23,1.24 map.cpp,1.16,1.17 map.h,1.9,1.10

Max Horn fingolfin at users.sourceforge.net
Fri Dec 30 10:40:01 CET 2005


Update of /cvsroot/scummvm/scummvm/gob
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12849

Modified Files:
	goblin.cpp map.cpp map.h 
Log Message:
Added kMapHeight and kMapWidth constants

Index: goblin.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/goblin.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- goblin.cpp	18 Dec 2005 09:57:44 -0000	1.23
+++ goblin.cpp	30 Dec 2005 18:39:01 -0000	1.24
@@ -720,11 +720,11 @@
 		}
 
 		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 @@
 		}
 
 		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 @@
 		    && 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 @@
 	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 @@
 	}
 
 	if (lookDir == 4) {
-		if (xPos < 25) {
+		if (xPos < kMapWidth - 1) {
 			map_placeItem(xPos + 1, yPos, idInPocket);
 
 			if (yPos > 0) {
@@ -2205,8 +2205,8 @@
 	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 @@
 		}
 	} 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 @@
 			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 @@
 			}
 		}
 
-		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 @@
 			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;

Index: map.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/map.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- map.cpp	18 Dec 2005 09:57:44 -0000	1.16
+++ map.cpp	30 Dec 2005 18:39:01 -0000	1.17
@@ -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 @@
 	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 @@
 	}
 
 	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 @@
 		    && 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 @@
 	}
 
 	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 @@
 	}
 
 	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 @@
 	}
 
 	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 @@
 
 	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 @@
 		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;
 			}

Index: map.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/map.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- map.h	18 Dec 2005 09:57:44 -0000	1.9
+++ map.h	30 Dec 2005 18:39:01 -0000	1.10
@@ -54,6 +54,11 @@
 
 #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];





More information about the Scummvm-git-logs mailing list