From 0100871412ac1b48aa64a87f2d88d8276212963e Mon Sep 17 00:00:00 2001 From: tron Date: Sun, 12 Mar 2006 15:04:03 +0000 Subject: (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does --- ai/default/default.c | 3 ++- ai/trolly/pathfinder.c | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'ai') diff --git a/ai/default/default.c b/ai/default/default.c index f6e6cdbde..41580720c 100644 --- a/ai/default/default.c +++ b/ai/default/default.c @@ -7,6 +7,7 @@ #include "../../road_map.h" #include "../../tile.h" #include "../../player.h" +#include "../../tunnel_map.h" #include "../../vehicle.h" #include "../../engine.h" #include "../../command.h" @@ -2147,7 +2148,7 @@ static bool AiRemoveTileAndGoForward(Player *p) TileIndex tilenew; if (IsTileType(tile, MP_TUNNELBRIDGE)) { - if (!(_m[tile].m5 & 0x80)) { + if (IsTunnel(tile)) { // Clear the tunnel and continue at the other side of it. if (CmdFailed(DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) return false; diff --git a/ai/trolly/pathfinder.c b/ai/trolly/pathfinder.c index 17fc15b66..128351f32 100644 --- a/ai/trolly/pathfinder.c +++ b/ai/trolly/pathfinder.c @@ -43,8 +43,7 @@ static bool IsRoad(TileIndex tile) // MP_STREET, but not a road depot? (IsTileType(tile, MP_STREET) && !IsTileDepotType(tile, TRANSPORT_ROAD)) || (IsTileType(tile, MP_TUNNELBRIDGE) && ( - // road tunnel? - ((_m[tile].m5 & 0x80) == 0 && (_m[tile].m5 & 0x4) == 0x4) || + (IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_ROAD) || // road bridge? ((_m[tile].m5 & 0x80) != 0 && (_m[tile].m5 & 0x2) == 0x2) )); @@ -232,12 +231,10 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr // If the next step is a bridge, we have to enter it the right way if (!PathFinderInfo->rail_or_road && IsRoad(atile)) { if (IsTileType(atile, MP_TUNNELBRIDGE)) { - // An existing bridge... let's test the direction ;) - if ((_m[atile].m5 & 1U) != (i & 1)) continue; - // This problem only is valid for tunnels: - // When the last tile was not yet a tunnel, check if we enter from the right side.. - if ((_m[atile].m5 & 0x80) == 0) { + if (IsTunnel(atile)) { if (GetTunnelDirection(atile) != i) continue; + } else { + if ((_m[atile].m5 & 1U) != DiagDirToAxis(i)) continue; } } } -- cgit v1.2.3-54-g00ecf