(svn r9331) [NoAI] -Fix: AIRoad() had most directions wrong, should be okay now noai
authortruelight
Mon, 19 Mar 2007 14:01:29 +0000
branchnoai
changeset 9482 5e0418292ecc
parent 9481 39ba1c349d3d
child 9483 0c6d80b1a87e
(svn r9331) [NoAI] -Fix: AIRoad() had most directions wrong, should be okay now
src/ai/api/ai_road.cpp
--- a/src/ai/api/ai_road.cpp	Mon Mar 19 13:29:28 2007 +0000
+++ b/src/ai/api/ai_road.cpp	Mon Mar 19 14:01:29 2007 +0000
@@ -23,7 +23,7 @@
 	if (TileX(start) != TileX(end) &&
 			TileY(start) != TileY(end)) return false;
 
-	return this->DoCommand(end, start, (TileX(start) != TileX(end) ? 4 : 0) | 3, DC_EXEC, CMD_BUILD_LONG_ROAD);
+	return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | 3, DC_EXEC, CMD_BUILD_LONG_ROAD);
 }
 
 bool AIRoad::BuildRoadDepot(TileIndex tile, TileIndex front)
@@ -31,7 +31,7 @@
 	/* Outside of the map */
 	if (tile >= _map_size || tile == front) return false;
 
-	uint entrance_dir = (TileX(tile) > TileX(front)) << 1 || (TileY(tile) > TileY(front));
+	uint entrance_dir = (TileX(tile) == TileX(front)) ? (TileY(tile) < TileY(front) ? 3 : 1) : (TileX(tile) < TileX(front) ? 2: 0);
 
 	return this->DoCommand(tile, entrance_dir, 0, DC_EXEC, CMD_BUILD_ROAD_DEPOT);
 }
@@ -43,9 +43,9 @@
 
 	uint entrance_dir;
 	if (drive_through) {
-		entrance_dir = TileX(tile) != TileX(front);
+		entrance_dir = TileY(tile) != TileY(front);
 	} else {
-		entrance_dir = (TileX(tile) > TileX(front)) << 1 || (TileY(tile) > TileY(front));
+		entrance_dir = (TileX(tile) == TileX(front)) ? (TileY(tile) < TileY(front) ? 3 : 1) : (TileX(tile) < TileX(front) ? 2: 0);
 	}
 
 	return this->DoCommand(tile, entrance_dir, drive_through << 1 | bus, DC_EXEC, CMD_BUILD_ROAD_STOP);
@@ -59,7 +59,7 @@
 	if (TileX(start) != TileX(end) &&
 			TileY(start) != TileY(end)) return false;
 
-	return this->DoCommand(end, start, (TileX(start) != TileX(end) ? 4 : 0) | 3, DC_EXEC, CMD_REMOVE_LONG_ROAD);
+	return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | 3, DC_EXEC, CMD_REMOVE_LONG_ROAD);
 }
 
 bool AIRoad::RemoveRoadDepot(TileIndex tile)