(svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
authorDarkvater
Mon, 18 Jul 2005 00:17:19 +0000
changeset 2118 c73d32cc0b5e
parent 2117 4afebf6c16e2
child 2119 17dd57dacccc
(svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
tree_cmd.c
--- a/tree_cmd.c	Sun Jul 17 22:20:04 2005 +0000
+++ b/tree_cmd.c	Mon Jul 18 00:17:19 2005 +0000
@@ -132,10 +132,7 @@
 int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
 {
 	int32 cost;
-	int sx;
-	int sy;
-	int x;
-	int y;
+	int sx, sy, x, y;
 
 	if (p2 > MapSize()) return CMD_ERROR;
 	/* Check the tree type. It can be random or some valid value within the current climate */
@@ -144,15 +141,16 @@
 	SET_EXPENSES_TYPE(EXPENSES_OTHER);
 
 	// make sure sx,sy are smaller than ex,ey
-	sx = TileX(p2) * 16;
-	sy = TileY(p2) * 16;
+	sx = TileX(p2);
+	sy = TileY(p2);
+	ex /= 16; ey /= 16;
 	if (ex < sx) intswap(ex, sx);
 	if (ey < sy) intswap(ey, sy);
 
 	cost = 0; // total cost
 
-	for (x = sx; x <= ex; x += 16) {
-		for (y = sy; y <= ey; y += 16) {
+	for (x = sx; x <= ex; x++) {
+		for (y = sy; y <= ey; y++) {
 			TileIndex tile = TileXY(x, y);
 
 			if (!EnsureNoVehicle(tile)) continue;