(svn r9331) [NoAI] -Fix: AIRoad() had most directions wrong, should be okay now
--- 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)