src/ai/trolly/pathfinder.cpp
changeset 8083 ad22eade501f
parent 7928 63e18de69e50
child 8088 92fca5b09665
equal deleted inserted replaced
8082:63240e1bd6cc 8083:ad22eade501f
    10 #include "../../command.h"
    10 #include "../../command.h"
    11 #include "trolly.h"
    11 #include "trolly.h"
    12 #include "../../depot.h"
    12 #include "../../depot.h"
    13 #include "../../tunnel_map.h"
    13 #include "../../tunnel_map.h"
    14 #include "../../bridge.h"
    14 #include "../../bridge.h"
       
    15 #include "../../tunnelbridge_map.h"
    15 #include "../ai.h"
    16 #include "../ai.h"
       
    17 
    16 
    18 
    17 #define TEST_STATION_NO_DIR 0xFF
    19 #define TEST_STATION_NO_DIR 0xFF
    18 
    20 
    19 // Tests if a station can be build on the given spot
    21 // Tests if a station can be build on the given spot
    20 // TODO: make it train compatible
    22 // TODO: make it train compatible
    42 {
    44 {
    43 	return
    45 	return
    44 		// MP_ROAD, but not a road depot?
    46 		// MP_ROAD, but not a road depot?
    45 		(IsTileType(tile, MP_ROAD) && !IsTileDepotType(tile, TRANSPORT_ROAD)) ||
    47 		(IsTileType(tile, MP_ROAD) && !IsTileDepotType(tile, TRANSPORT_ROAD)) ||
    46 		(IsTileType(tile, MP_TUNNELBRIDGE) && (
    48 		(IsTileType(tile, MP_TUNNELBRIDGE) && (
    47 			(IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_ROAD) ||
    49 			(IsTunnel(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) ||
    48 			(IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_ROAD)
    50 			(IsBridge(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD)
    49 		));
    51 		));
    50 }
    52 }
    51 
    53 
    52 
    54 
    53 // Checks if a tile 'a' is between the tiles 'b' and 'c'
    55 // Checks if a tile 'a' is between the tiles 'b' and 'c'
   233 
   235 
   234 			// If the next step is a bridge, we have to enter it the right way
   236 			// If the next step is a bridge, we have to enter it the right way
   235 			if (!PathFinderInfo->rail_or_road && IsRoad(atile)) {
   237 			if (!PathFinderInfo->rail_or_road && IsRoad(atile)) {
   236 				if (IsTileType(atile, MP_TUNNELBRIDGE)) {
   238 				if (IsTileType(atile, MP_TUNNELBRIDGE)) {
   237 					if (IsTunnel(atile)) {
   239 					if (IsTunnel(atile)) {
   238 						if (GetTunnelDirection(atile) != i) continue;
   240 						if (GetTunnelBridgeDirection(atile) != i) continue;
   239 					} else {
   241 					} else {
   240 						if (GetBridgeRampDirection(atile) != i) continue;
   242 						if (GetTunnelBridgeDirection(atile) != i) continue;
   241 					}
   243 					}
   242 				}
   244 				}
   243 			}
   245 			}
   244 
   246 
   245 			if ((AI_PATHFINDER_FLAG_BRIDGE & current->path.node.user_data[0]) != 0 ||
   247 			if ((AI_PATHFINDER_FLAG_BRIDGE & current->path.node.user_data[0]) != 0 ||