summaryrefslogtreecommitdiff
path: root/src/ai/trolly
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-24 21:45:54 +0000
committerrubidium <rubidium@openttd.org>2007-05-24 21:45:54 +0000
commitef48d1012b7a3774ee9cea9eb6ac8e7779adadce (patch)
treea60c49017c933cc546dc7f046008c43285a8bfad /src/ai/trolly
parentdf3a9b40522890c13fdf9fd2318e48ce40d26e97 (diff)
downloadopenttd-ef48d1012b7a3774ee9cea9eb6ac8e7779adadce.tar.xz
(svn r9912) -Fix: the AIs could build any road(station)s.
Diffstat (limited to 'src/ai/trolly')
-rw-r--r--src/ai/trolly/build.cpp8
-rw-r--r--src/ai/trolly/pathfinder.cpp13
2 files changed, 7 insertions, 14 deletions
diff --git a/src/ai/trolly/build.cpp b/src/ai/trolly/build.cpp
index 218a4c0e8..ac66bfaa6 100644
--- a/src/ai/trolly/build.cpp
+++ b/src/ai/trolly/build.cpp
@@ -42,9 +42,9 @@ int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte
return AI_DoCommand(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
if (type == AI_BUS)
- return AI_DoCommand(tile, direction, RoadStop::BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
+ return AI_DoCommand(tile, direction, ROADTYPES_ROAD << 2 | RoadStop::BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
- return AI_DoCommand(tile, direction, RoadStop::TRUCK, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
+ return AI_DoCommand(tile, direction, ROADTYPES_ROAD << 2 | RoadStop::TRUCK, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
}
@@ -75,7 +75,7 @@ int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag)
if (p->ainew.tbt == AI_TRAIN) {
return AI_DoCommand(tile_a, tile_b, (0x00 << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
} else {
- return AI_DoCommand(tile_a, tile_b, (0x80 << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
+ return AI_DoCommand(tile_a, tile_b, ((0x80 | ROADTYPES_ROAD) << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
}
}
@@ -162,7 +162,7 @@ int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte fla
} else {
// Tunnel code
if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) {
- cost += AI_DoCommand(route[part], 0x200, 0, flag, CMD_BUILD_TUNNEL);
+ cost += AI_DoCommand(route[part], 0x200 | ROADTYPES_ROAD, 0, flag, CMD_BUILD_TUNNEL);
PathFinderInfo->position++;
// TODO: problems!
if (CmdFailed(cost)) {
diff --git a/src/ai/trolly/pathfinder.cpp b/src/ai/trolly/pathfinder.cpp
index 0091939b1..e7102d642 100644
--- a/src/ai/trolly/pathfinder.cpp
+++ b/src/ai/trolly/pathfinder.cpp
@@ -237,17 +237,10 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
if (IsTunnel(atile)) {
if (GetTunnelDirection(atile) != i) continue;
} else {
- if ((_m[atile].m5 & 1) != DiagDirToAxis(i)) continue;
+ if (GetBridgeRampDirection(atile) != i) continue;
}
}
}
- // But also if we are on a bridge, we can only move a certain direction
- if (!PathFinderInfo->rail_or_road && IsRoad(ctile)) {
- if (IsTileType(ctile, MP_TUNNELBRIDGE)) {
- // An existing bridge/tunnel... let's test the direction ;)
- if ((_m[ctile].m5 & 1) != (i & 1)) continue;
- }
- }
if ((AI_PATHFINDER_FLAG_BRIDGE & current->path.node.user_data[0]) != 0 ||
(AI_PATHFINDER_FLAG_TUNNEL & current->path.node.user_data[0]) != 0) {
@@ -291,9 +284,9 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
dir = 0;
} else {
// It already has road.. check if we miss any bits!
- if ((_m[ctile].m5 & dir) != dir) {
+ if ((GetRoadBits(ctile, ROADTYPE_ROAD) & dir) != dir) {
// We do miss some pieces :(
- dir &= ~_m[ctile].m5;
+ dir &= ~GetRoadBits(ctile, ROADTYPE_ROAD);
} else {
dir = 0;
}