diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -67,7 +67,7 @@ enum { static TrackBits GetRailTrackStatus(TileIndex tile) { - uint32 r = GetTileTrackStatus(tile, TRANSPORT_RAIL); + uint32 r = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0); return (TrackBits)(byte) (r | r >> 8); } @@ -1862,7 +1862,7 @@ static bool AiDoFollowTrack(const Player arpfd.tile2 = p->ai.cur_tile_a; arpfd.flag = false; arpfd.count = 0; - FollowTrack(p->ai.cur_tile_a + TileOffsByDiagDir(p->ai.cur_dir_a), 0x2000 | TRANSPORT_RAIL, (DiagDirection)(p->ai.cur_dir_a ^ 2), + FollowTrack(p->ai.cur_tile_a + TileOffsByDiagDir(p->ai.cur_dir_a), 0x2000 | TRANSPORT_RAIL, 0, (DiagDirection)(p->ai.cur_dir_a ^ 2), (TPFEnumProc*)AiEnumFollowTrack, NULL, &arpfd); return arpfd.count > 8; } @@ -2824,13 +2824,13 @@ static bool AiCheckRoadFinished(Player * tile = TILE_MASK(p->ai.cur_tile_a + TileOffsByDiagDir(dir)); if (IsRoadStopTile(tile) || IsTileDepotType(tile, TRANSPORT_ROAD)) return false; - bits = GetTileTrackStatus(tile, TRANSPORT_ROAD) & _ai_road_table_and[dir]; + bits = GetTileTrackStatus(tile, TRANSPORT_ROAD, ROADTYPES_ROAD) & _ai_road_table_and[dir]; if (bits == 0) return false; are.best_dist = (uint)-1; for_each_bit(i, bits) { - FollowTrack(tile, 0x3000 | TRANSPORT_ROAD, (DiagDirection)_dir_by_track[i], (TPFEnumProc*)AiEnumFollowRoad, NULL, &are); + FollowTrack(tile, 0x3000 | TRANSPORT_ROAD, ROADTYPES_ROAD, (DiagDirection)_dir_by_track[i], (TPFEnumProc*)AiEnumFollowRoad, NULL, &are); } if (DistanceManhattan(tile, are.dest) <= are.best_dist) return false; diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -764,7 +764,7 @@ static void ClickTile_Clear(TileIndex ti /* not used */ } -static uint32 GetTileTrackStatus_Clear(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode) { return 0; } diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -713,7 +713,7 @@ static void DisasterTick_Submarine(Vehic tile = v->tile + TileOffsByDiagDir(DirToDiagDir(v->direction)); if (IsValidTile(tile)) { - TrackdirBits r = (TrackdirBits)GetTileTrackStatus(tile, TRANSPORT_WATER); + TrackdirBits r = (TrackdirBits)GetTileTrackStatus(tile, TRANSPORT_WATER, 0); if (TrackdirBitsToTrackBits(r) == TRACK_BIT_ALL && !CHANCE16(1, 90)) { GetNewVehiclePosResult gp = GetNewVehiclePos(v); diff --git a/src/dummy_land.cpp b/src/dummy_land.cpp --- a/src/dummy_land.cpp +++ b/src/dummy_land.cpp @@ -63,7 +63,7 @@ static void ChangeTileOwner_Dummy(TileIn /* not used */ } -static uint32 GetTileTrackStatus_Dummy(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_Dummy(TileIndex tile, TransportType mode, uint sub_mode) { return 0; } diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -735,7 +735,7 @@ static void ClickTile_Industry(TileIndex ShowIndustryViewWindow(GetIndustryIndex(tile)); } -static uint32 GetTileTrackStatus_Industry(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_Industry(TileIndex tile, TransportType mode, uint sub_mode) { return 0; } diff --git a/src/landscape.cpp b/src/landscape.cpp --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -274,9 +274,9 @@ void DoClearSquare(TileIndex tile) MarkTileDirtyByTile(tile); } -uint32 GetTileTrackStatus(TileIndex tile, TransportType mode) +uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode) { - return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode); + return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode, sub_mode); } void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player) diff --git a/src/landscape.h b/src/landscape.h --- a/src/landscape.h +++ b/src/landscape.h @@ -44,7 +44,7 @@ void DrawFoundation(TileInfo *ti, uint f void DoClearSquare(TileIndex tile); void RunTileLoop(); -uint32 GetTileTrackStatus(TileIndex tile, TransportType mode); +uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode); void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac); void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player); void AnimateTile(TileIndex tile); diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -307,7 +307,7 @@ static uint32 GetRailContinuationInfo(Ti uint i; for (i = 0; i < lengthof(x_dir); i++, dir++, diagdir++) { - uint32 ts = GetTileTrackStatus(tile + TileOffsByDir(*dir), TRANSPORT_RAIL); + uint32 ts = GetTileTrackStatus(tile + TileOffsByDir(*dir), TRANSPORT_RAIL, 0); if (ts != 0) { /* If there is any track on the tile, set the bit in the second byte */ SETBIT(res, i + 8); diff --git a/src/npf.cpp b/src/npf.cpp --- a/src/npf.cpp +++ b/src/npf.cpp @@ -523,6 +523,7 @@ static void NPFFollowTrack(AyStar* aysta uint32 ts; TrackdirBits trackdirbits; TransportType type = (TransportType)aystar->user_data[NPF_TYPE]; + uint subtype = aystar->user_data[NPF_SUB_TYPE]; bool override_dst_check = false; /* Initialize to 0, so we can jump out (return) somewhere an have no neighbours */ aystar->num_neighbours = 0; @@ -622,7 +623,7 @@ static void NPFFollowTrack(AyStar* aysta * the back */ ts = TrackdirToTrackdirBits(DiagdirToDiagTrackdir(ReverseDiagDir(exitdir))); } else { - ts = GetTileTrackStatus(dst_tile, type); + ts = GetTileTrackStatus(dst_tile, type, subtype); } trackdirbits = (TrackdirBits)(ts & TRACKDIR_BIT_MASK); /* Filter out signal status and the unused bits */ @@ -670,7 +671,7 @@ static void NPFFollowTrack(AyStar* aysta * multiple targets that are spread around, we should perform a breadth first * search by specifiying CalcZero as our heuristic. */ -static NPFFoundTargetData NPFRouteInternal(AyStarNode* start1, AyStarNode* start2, NPFFindStationOrTileData* target, AyStar_EndNodeCheck target_proc, AyStar_CalculateH heuristic_proc, TransportType type, Owner owner, RailTypeMask railtypes, uint reverse_penalty) +static NPFFoundTargetData NPFRouteInternal(AyStarNode* start1, AyStarNode* start2, NPFFindStationOrTileData* target, AyStar_EndNodeCheck target_proc, AyStar_CalculateH heuristic_proc, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes, uint reverse_penalty) { int r; NPFFoundTargetData result; @@ -709,6 +710,7 @@ static NPFFoundTargetData NPFRouteIntern /* Initialize user_data */ _npf_aystar.user_data[NPF_TYPE] = type; + _npf_aystar.user_data[NPF_SUB_TYPE] = sub_type; _npf_aystar.user_data[NPF_OWNER] = owner; _npf_aystar.user_data[NPF_RAILTYPES] = railtypes; @@ -728,7 +730,7 @@ static NPFFoundTargetData NPFRouteIntern return result; } -NPFFoundTargetData NPFRouteToStationOrTileTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypeMask railtypes) +NPFFoundTargetData NPFRouteToStationOrTileTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes) { AyStarNode start1; AyStarNode start2; @@ -742,15 +744,15 @@ NPFFoundTargetData NPFRouteToStationOrTi start2.direction = trackdir2; start2.user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR; - return NPFRouteInternal(&start1, (IsValidTile(tile2) ? &start2 : NULL), target, NPFFindStationOrTile, NPFCalcStationOrTileHeuristic, type, owner, railtypes, 0); + return NPFRouteInternal(&start1, (IsValidTile(tile2) ? &start2 : NULL), target, NPFFindStationOrTile, NPFCalcStationOrTileHeuristic, type, sub_type, owner, railtypes, 0); } -NPFFoundTargetData NPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypeMask railtypes) +NPFFoundTargetData NPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes) { - return NPFRouteToStationOrTileTwoWay(tile, trackdir, INVALID_TILE, INVALID_TRACKDIR, target, type, owner, railtypes); + return NPFRouteToStationOrTileTwoWay(tile, trackdir, INVALID_TILE, INVALID_TRACKDIR, target, type, sub_type, owner, railtypes); } -NPFFoundTargetData NPFRouteToDepotBreadthFirstTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, TransportType type, Owner owner, RailTypeMask railtypes, uint reverse_penalty) +NPFFoundTargetData NPFRouteToDepotBreadthFirstTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes, uint reverse_penalty) { AyStarNode start1; AyStarNode start2; @@ -766,15 +768,15 @@ NPFFoundTargetData NPFRouteToDepotBreadt /* perform a breadth first search. Target is NULL, * since we are just looking for any depot...*/ - return NPFRouteInternal(&start1, (IsValidTile(tile2) ? &start2 : NULL), NULL, NPFFindDepot, NPFCalcZero, type, owner, railtypes, reverse_penalty); + return NPFRouteInternal(&start1, (IsValidTile(tile2) ? &start2 : NULL), NULL, NPFFindDepot, NPFCalcZero, type, sub_type, owner, railtypes, reverse_penalty); } -NPFFoundTargetData NPFRouteToDepotBreadthFirst(TileIndex tile, Trackdir trackdir, TransportType type, Owner owner, RailTypeMask railtypes) +NPFFoundTargetData NPFRouteToDepotBreadthFirst(TileIndex tile, Trackdir trackdir, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes) { - return NPFRouteToDepotBreadthFirstTwoWay(tile, trackdir, INVALID_TILE, INVALID_TRACKDIR, type, owner, railtypes, 0); + return NPFRouteToDepotBreadthFirstTwoWay(tile, trackdir, INVALID_TILE, INVALID_TRACKDIR, type, sub_type, owner, railtypes, 0); } -NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, TransportType type, Owner owner, RailTypeMask railtypes) +NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes) { /* Okay, what we're gonna do. First, we look at all depots, calculate * the manhatten distance to get to each depot. We then sort them by @@ -823,6 +825,7 @@ NPFFoundTargetData NPFRouteToDepotTrialE /* Initialize user_data */ _npf_aystar.user_data[NPF_TYPE] = type; + _npf_aystar.user_data[NPF_SUB_TYPE] = sub_type; _npf_aystar.user_data[NPF_OWNER] = owner; /* Initialize Start Node */ diff --git a/src/npf.h b/src/npf.h --- a/src/npf.h +++ b/src/npf.h @@ -46,6 +46,7 @@ struct NPFFindStationOrTileData { /* Indices into AyStar.userdata[] */ enum { NPF_TYPE = 0, ///< Contains a TransportTypes value + NPF_SUB_TYPE, ///< Contains the sub transport type NPF_OWNER, ///< Contains an Owner value NPF_RAILTYPES, ///< Contains a bitmask the compatible RailTypes of the engine when NPF_TYPE == TRANSPORT_RAIL. Unused otherwise. }; @@ -76,28 +77,28 @@ struct NPFFoundTargetData { /* Will search from the given tile and direction, for a route to the given * station for the given transport type. See the declaration of * NPFFoundTargetData above for the meaning of the result. */ -NPFFoundTargetData NPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypeMask railtypes); +NPFFoundTargetData NPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes); /* Will search as above, but with two start nodes, the second being the * reverse. Look at the NPF_FLAG_REVERSE flag in the result node to see which * direction was taken (NPFGetBit(result.node, NPF_FLAG_REVERSE)) */ -NPFFoundTargetData NPFRouteToStationOrTileTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypeMask railtypes); +NPFFoundTargetData NPFRouteToStationOrTileTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes); /* Will search a route to the closest depot. */ /* Search using breadth first. Good for little track choice and inaccurate * heuristic, such as railway/road.*/ -NPFFoundTargetData NPFRouteToDepotBreadthFirst(TileIndex tile, Trackdir trackdir, TransportType type, Owner owner, RailTypeMask railtypes); +NPFFoundTargetData NPFRouteToDepotBreadthFirst(TileIndex tile, Trackdir trackdir, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes); /* Same as above but with two start nodes, the second being the reverse. Call * NPFGetBit(result.node, NPF_FLAG_REVERSE) to see from which node the path * orginated. All pathfs from the second node will have the given * reverse_penalty applied (NPF_TILE_LENGTH is the equivalent of one full * tile). */ -NPFFoundTargetData NPFRouteToDepotBreadthFirstTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, TransportType type, Owner owner, RailTypeMask railtypes, uint reverse_penalty); +NPFFoundTargetData NPFRouteToDepotBreadthFirstTwoWay(TileIndex tile1, Trackdir trackdir1, TileIndex tile2, Trackdir trackdir2, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes, uint reverse_penalty); /* Search by trying each depot in order of Manhattan Distance. Good for lots * of choices and accurate heuristics, such as water. */ -NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, TransportType type, Owner owner, RailTypeMask railtypes); +NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes); void NPFFillWithOrderData(NPFFindStationOrTileData* fstd, Vehicle* v); diff --git a/src/openttd.h b/src/openttd.h --- a/src/openttd.h +++ b/src/openttd.h @@ -364,7 +364,8 @@ typedef uint GetSlopeZProc(TileIndex til typedef int32 ClearTileProc(TileIndex tile, byte flags); typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res); typedef void GetTileDescProc(TileIndex tile, TileDesc *td); -/* GetTileTrackStatusProcs return a value that contains the possible tracks +/** + * GetTileTrackStatusProcs return a value that contains the possible tracks * that can be taken on a given tile by a given transport. The return value is * composed as follows: 0xaabbccdd. ccdd and aabb are bitmasks of trackdirs, * where bit n corresponds to trackdir n. ccdd are the trackdirs that are @@ -382,8 +383,12 @@ typedef void GetTileDescProc(TileIndex t * are a track, the fourth bit is the direction. these give 12 (or 14) * possible options: 0-5 and 8-13, so we need 14 bits for a trackdir bitmask * above. + * @param tile the tile to get the track status from + * @param mode the mode of transportation + * @param sub_mode used to differentiate between different kinds within the mode + * @return the above mentions track status information */ -typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode); +typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode); typedef void GetProducedCargoProc(TileIndex tile, CargoID *b); typedef void ClickTileProc(TileIndex tile); typedef void AnimateTileProc(TileIndex tile); diff --git a/src/pathfind.cpp b/src/pathfind.cpp --- a/src/pathfind.cpp +++ b/src/pathfind.cpp @@ -153,7 +153,7 @@ static void TPFMode2(TrackPathFinder* tp if (++tpf->rd.cur_length > 50) return; - bits = GetTileTrackStatus(tile, tpf->tracktype); + bits = GetTileTrackStatus(tile, tpf->tracktype, tpf->sub_type); bits = (byte)((bits | (bits >> 8)) & _bits_mask[direction]); if (bits == 0) return; @@ -322,7 +322,7 @@ static void TPFMode1(TrackPathFinder* tp tpf->rd.cur_length++; - bits = GetTileTrackStatus(tile, tpf->tracktype); + bits = GetTileTrackStatus(tile, tpf->tracktype, tpf->sub_type); if ((byte)bits != tpf->var2) { bits &= _tpfmode1_and[direction]; @@ -363,7 +363,7 @@ static void TPFMode1(TrackPathFinder* tp direction = ReverseDiagDir(direction); tile += TileOffsByDiagDir(direction); - bits = GetTileTrackStatus(tile, tpf->tracktype); + bits = GetTileTrackStatus(tile, tpf->tracktype, tpf->sub_type); bits |= (bits >> 8); if ( (byte)bits != tpf->var2) { @@ -388,7 +388,7 @@ static void TPFMode1(TrackPathFinder* tp } while (bits != 0); } -void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data) +void FollowTrack(TileIndex tile, uint16 flags, uint sub_type, DiagDirection direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data) { TrackPathFinder tpf; @@ -411,6 +411,7 @@ void FollowTrack(TileIndex tile, uint16 tpf.tracktype = (TransportType)(flags & 0xFF); + tpf.sub_type = sub_type; if (HASBIT(flags, 11)) { tpf.rd.pft_var6 = 0xFF; @@ -783,7 +784,7 @@ start_at: if (!IsTileType(tile, MP_RAILWAY) || !IsPlainRailTile(tile)) { /* We found a tile which is not a normal railway tile. * Determine which tracks that exist on this tile. */ - uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _tpfmode1_and[direction]; + uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _tpfmode1_and[direction]; bits = TrackdirBitsToTrackBits((TrackdirBits)(ts & TRACKDIR_BIT_MASK)); /* Check that the tile contains exactly one track */ diff --git a/src/pathfind.h b/src/pathfind.h --- a/src/pathfind.h +++ b/src/pathfind.h @@ -57,6 +57,8 @@ struct TrackPathFinder { TrackdirByte the_dir; TransportTypeByte tracktype; + uint sub_type; + byte var2; bool disable_tile_hash; bool hasbit_13; @@ -67,7 +69,7 @@ struct TrackPathFinder { TrackPathFinderLink links[0x400]; ///< hopefully, this is enough. }; -void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumProc* enum_proc, TPFAfterProc* after_proc, void* data); +void FollowTrack(TileIndex tile, uint16 flags, uint sub_type, DiagDirection direction, TPFEnumProc* enum_proc, TPFAfterProc* after_proc, void* data); struct FindLengthOfTunnelResult { TileIndex tile; diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1716,7 +1716,7 @@ bool UpdateSignalsOnSegment(TileIndex ti ssd.cur = ssd.presignal_exits = ssd.presignal_exits_free = 0; ssd.has_presignal = false; - FollowTrack(tile, 0xC000 | TRANSPORT_RAIL, direction, SetSignalsEnumProc, SetSignalsAfterProc, &ssd); + FollowTrack(tile, 0xC000 | TRANSPORT_RAIL, 0, direction, SetSignalsEnumProc, SetSignalsAfterProc, &ssd); ChangeSignalStates(&ssd); /* remember the result only for the first iteration. */ @@ -1908,7 +1908,7 @@ set_ground: } -static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint sub_mode) { if (mode != TRANSPORT_RAIL) return 0; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -168,7 +168,7 @@ static void GenericPlaceSignals(TileInde byte trackstat; uint i; - trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL); + trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL, 0); if (trackstat & TRACK_BIT_VERT) // N-S direction trackstat = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT; diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1111,9 +1111,8 @@ static const byte _road_trackbits[16] = 0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F, }; -static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode, uint sub_mode) { - RoadType rt = ROADTYPE_ROAD; switch (mode) { case TRANSPORT_RAIL: @@ -1121,10 +1120,12 @@ static uint32 GetTileTrackStatus_Road(Ti return GetCrossingRailBits(tile) * 0x101; case TRANSPORT_ROAD: - if (!HASBIT(GetRoadTypes(tile), rt)) return 0; + if ((GetRoadTypes(tile) & sub_mode) == 0) return 0; switch (GetRoadTileType(tile)) { - case ROAD_TILE_NORMAL: + case ROAD_TILE_NORMAL: { + RoadType rt = (RoadType)FindFirstBit(sub_mode); return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile, rt)] * 0x101; + } case ROAD_TILE_CROSSING: { uint32 r = AxisToTrackBits(GetCrossingRoadAxis(tile)) * 0x101; diff --git a/src/road_map.cpp b/src/road_map.cpp --- a/src/road_map.cpp +++ b/src/road_map.cpp @@ -55,7 +55,7 @@ TrackBits GetAnyRoadTrackBits(TileIndex return TRACK_BIT_NONE; } - r = GetTileTrackStatus(tile, TRANSPORT_ROAD); + r = GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt)); return (TrackBits)(byte)(r | (r >> 8)); } diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -173,6 +173,9 @@ int32 CmdBuildRoadVeh(TileIndex tile, ui v->u.road.state = RVSB_IN_DEPOT; v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL; + v->u.road.roadtype = ROADTYPE_ROAD; + v->u.road.compatible_roadtypes = RoadTypeToRoadTypes(v->u.road.roadtype); + v->spritenum = rvi->image_index; v->cargo_type = rvi->cargo_type; v->cargo_subtype = 0; @@ -353,7 +356,7 @@ static const Depot* FindClosestRoadDepot /* See where we are now */ Trackdir trackdir = GetVehicleTrackdir(v); - ftd = NPFRouteToDepotBreadthFirst(v->tile, trackdir, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE); + ftd = NPFRouteToDepotBreadthFirst(v->tile, trackdir, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPE); if (ftd.best_bird_dist == 0) { return GetDepotByTile(ftd.node.tile); /* Target found */ } else { @@ -368,7 +371,7 @@ static const Depot* FindClosestRoadDepot /* search in all directions */ for (DiagDirection i = DIAGDIR_BEGIN; i != DIAGDIR_END; i++) { - FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, i, EnumRoadSignalFindDepot, NULL, &rfdd); + FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, v->u.road.compatible_roadtypes, i, EnumRoadSignalFindDepot, NULL, &rfdd); } if (rfdd.best_length == (uint)-1) return NULL; @@ -933,7 +936,7 @@ static bool FindRoadVehToOvertake(Overta { uint32 bits; - bits = GetTileTrackStatus(od->tile, TRANSPORT_ROAD) & 0x3F; + bits = GetTileTrackStatus(od->tile, TRANSPORT_ROAD, od->v->u.road.compatible_roadtypes) & 0x3F; if (!(od->tilebits & bits) || (bits & 0x3C) || (bits & 0x3F3F0000)) return true; @@ -959,7 +962,7 @@ static void RoadVehCheckOvertake(Vehicle /* Check if vehicle is in a road stop, depot, tunnel or bridge or not on a straight road */ if (v->u.road.state >= RVSB_IN_ROAD_STOP || !IsStraightRoadTrackdir((Trackdir)(v->u.road.state & RVSB_TRACKDIR_MASK))) return; - tt = GetTileTrackStatus(v->tile, TRANSPORT_ROAD) & 0x3F; + tt = GetTileTrackStatus(v->tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes) & 0x3F; if ((tt & 3) == 0) return; if ((tt & 0x3C) != 0) return; @@ -1030,11 +1033,11 @@ static bool EnumRoadTrackFindDist(TileIn return false; } -static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypeMask railtypes) +static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes) { void* perf = NpfBeginInterval(); - NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, owner, railtypes); + NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, sub_type, owner, railtypes); int t = NpfEndInterval(perf); DEBUG(yapf, 4, "[NPFR] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size); return ret; @@ -1056,7 +1059,7 @@ static Trackdir RoadFindPathToDest(Vehic FindRoadToChooseData frd; Trackdir best_track; - uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD); + uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes); TrackdirBits signal = (TrackdirBits)GB(r, 16, 16); TrackdirBits trackdirs = (TrackdirBits)GB(r, 0, 16); @@ -1131,7 +1134,7 @@ static Trackdir RoadFindPathToDest(Vehic trackdir = DiagdirToDiagTrackdir(enterdir); //debug("Finding path. Enterdir: %d, Trackdir: %d", enterdir, trackdir); - ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE); + ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPE); if (ftd.best_trackdir == INVALID_TRACKDIR) { /* We are already at our target. Just do something * @todo: maybe display error? @@ -1181,7 +1184,7 @@ do_it:; if (best_track == INVALID_TRACKDIR) best_track = (Trackdir)i; // in case we don't find the path, just pick a track frd.maxtracklen = (uint)-1; frd.mindist = (uint)-1; - FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, _road_pf_directions[i], EnumRoadTrackFindDist, NULL, &frd); + FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, v->u.road.compatible_roadtypes, _road_pf_directions[i], EnumRoadTrackFindDist, NULL, &frd); if (frd.mindist < best_dist || (frd.mindist == best_dist && frd.maxtracklen < best_maxlen)) { best_dist = frd.mindist; @@ -1214,7 +1217,7 @@ static uint RoadFindPathToStop(const Veh fstd.dest_coords = tile; fstd.station_index = INVALID_STATION; // indicates that the destination is a tile, not a station - dist = NPFRouteToStationOrTile(v->tile, trackdir, &fstd, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE).best_path_dist; + dist = NPFRouteToStationOrTile(v->tile, trackdir, &fstd, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPE).best_path_dist; /* change units from NPF_TILE_LENGTH to # of tiles */ if (dist != UINT_MAX) dist = (dist + NPF_TILE_LENGTH - 1) / NPF_TILE_LENGTH; diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -43,7 +43,7 @@ static const TrackBits _ship_sometracks[ static TrackBits GetTileShipTrackStatus(TileIndex tile) { - uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER); + uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER, 0); return TrackdirBitsToTrackBits((TrackdirBits)(TRACKDIR_BIT_MASK & (r | r >> 8))); } @@ -114,7 +114,7 @@ static const Depot* FindClosestShipDepot if (_patches.new_pathfinding_all) { NPFFoundTargetData ftd; Trackdir trackdir = GetVehicleTrackdir(v); - ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER, v->owner, INVALID_RAILTYPE); + ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPE); if (ftd.best_bird_dist == 0) { best_depot = GetDepotByTile(ftd.node.tile); /* Found target */ } else { @@ -479,7 +479,7 @@ static uint FindShipTrack(Vehicle *v, Ti pfs.best_bird_dist = (uint)-1; pfs.best_length = (uint)-1; - FollowTrack(tile, 0x3800 | TRANSPORT_WATER, (DiagDirection)_ship_search_directions[i][dir], (TPFEnumProc*)ShipTrackFollower, NULL, &pfs); + FollowTrack(tile, 0x3800 | TRANSPORT_WATER, 0, (DiagDirection)_ship_search_directions[i][dir], (TPFEnumProc*)ShipTrackFollower, NULL, &pfs); if (best_track != INVALID_TRACK) { if (pfs.best_bird_dist != 0) { @@ -514,7 +514,7 @@ static inline NPFFoundTargetData PerfNPF { void* perf = NpfBeginInterval(); - NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, owner, railtypes); + NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, 0, owner, railtypes); int t = NpfEndInterval(perf); DEBUG(yapf, 4, "[NPFW] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size); return ret; @@ -597,7 +597,7 @@ static Direction ShipGetNewDirection(Veh static TrackBits GetAvailShipTracks(TileIndex tile, int dir) { - uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER); + uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER, 0); return (TrackBits)((r | r >> 8) & _ship_sometracks[dir]); } diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2132,7 +2132,7 @@ static void GetTileDesc_Station(TileInde } -static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode, uint sub_mode) { switch (mode) { case TRANSPORT_RAIL: @@ -2154,7 +2154,7 @@ static uint32 GetTileTrackStatus_Station break; case TRANSPORT_ROAD: - if (IsRoadStopTile(tile)) { + if ((GetRoadTypes(tile) & sub_mode) != 0 && IsRoadStopTile(tile)) { return AxisToTrackBits(DiagDirToAxis(GetRoadStopDir(tile))) * 0x101; } break; diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -563,7 +563,7 @@ static void GetTileDesc_Town(TileIndex t td->owner = OWNER_TOWN; } -static uint32 GetTileTrackStatus_Town(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_Town(TileIndex tile, TransportType mode, uint sub_mode) { /* not used */ return 0; diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1937,7 +1937,7 @@ static TrainFindDepotData FindClosestTra Trackdir trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last)); assert(trackdir != INVALID_TRACKDIR); - NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, last->tile, trackdir_rev, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY); + NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, last->tile, trackdir_rev, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY); if (ftd.best_bird_dist == 0) { /* Found target */ tfdd.tile = ftd.node.tile; @@ -2302,7 +2302,7 @@ static Track ChooseTrainTrack(Vehicle* v Trackdir trackdir = GetVehicleTrackdir(v); assert(trackdir != 0xff); - NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes); + NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes); if (ftd.best_trackdir == 0xff) { /* We are already at our target. Just do something @@ -2412,7 +2412,7 @@ static bool CheckReverseTrain(Vehicle *v assert(trackdir != 0xff); assert(trackdir_rev != 0xff); - ftd = NPFRouteToStationOrTileTwoWay(v->tile, trackdir, last->tile, trackdir_rev, &fstd, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes); + ftd = NPFRouteToStationOrTileTwoWay(v->tile, trackdir, last->tile, trackdir_rev, &fstd, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes); if (ftd.best_bird_dist != 0) { /* We didn't find anything, just keep on going straight ahead */ reverse_best = false; @@ -2920,7 +2920,7 @@ static void TrainController(Vehicle *v, /* Get the status of the tracks in the new tile and mask * away the bits that aren't reachable. */ - uint32 ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL) & _reachable_tracks[enterdir]; + uint32 ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL, 0) & _reachable_tracks[enterdir]; /* Combine the from & to directions. * Now, the lower byte contains the track status, and the byte at bit 16 contains @@ -3265,7 +3265,7 @@ static bool TrainCheckIfLineEnds(Vehicle /* Calculate next tile */ tile += TileOffsByDiagDir(dir); // determine the track status on the next tile. - uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _reachable_tracks[dir]; + uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _reachable_tracks[dir]; /* Calc position within the current tile ?? */ uint x = v->x_pos & 0xF; diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -648,7 +648,7 @@ static void ClickTile_Trees(TileIndex ti /* not used */ } -static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode) { return 0; } diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -1236,13 +1236,15 @@ static void ClickTile_TunnelBridge(TileI } -static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode) { if (IsTunnel(tile)) { if (GetTunnelTransportType(tile) != mode) return 0; + if (GetTunnelTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0; return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(tile))) * 0x101; } else { if (GetBridgeTransportType(tile) != mode) return 0; + if (GetBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0; return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(tile))) * 0x101; } } diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp --- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -319,7 +319,7 @@ static void TileLoop_Unmovable(TileIndex } -static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode, uint sub_mode) { return 0; } diff --git a/src/vehicle.cpp b/src/vehicle.cpp --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -239,8 +239,13 @@ void AfterLoadVehicles() FOR_ALL_VEHICLES(v) { switch (v->type) { + case VEH_ROAD: + v->cur_image = GetRoadVehImage(v, v->direction); + v->u.road.roadtype = ROADTYPE_ROAD; + v->u.road.compatible_roadtypes = RoadTypeToRoadTypes(v->u.road.roadtype); + break; + case VEH_TRAIN: v->cur_image = GetTrainImage(v, v->direction); break; - case VEH_ROAD: v->cur_image = GetRoadVehImage(v, v->direction); break; case VEH_SHIP: v->cur_image = GetShipImage(v, v->direction); break; case VEH_AIRCRAFT: if (IsNormalAircraft(v)) { diff --git a/src/vehicle.h b/src/vehicle.h --- a/src/vehicle.h +++ b/src/vehicle.h @@ -8,6 +8,7 @@ #include "oldpool.h" #include "order.h" #include "rail.h" +#include "road.h" /** The returned bits of VehicleEnterTile. */ enum VehicleEnterTileStatus { @@ -188,6 +189,9 @@ struct VehicleRoad { byte reverse_ctr; struct RoadStop *slot; byte slot_age; + + RoadType roadtype; + RoadTypes compatible_roadtypes; }; struct VehicleSpecial { diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -725,7 +725,7 @@ void TileLoop_Water(TileIndex tile) } } -static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode, uint sub_mode) { static const byte coast_tracks[] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0}; diff --git a/src/yapf/follow_track.hpp b/src/yapf/follow_track.hpp --- a/src/yapf/follow_track.hpp +++ b/src/yapf/follow_track.hpp @@ -45,7 +45,7 @@ struct CFollowTrackT : public FollowTrac { m_old_tile = old_tile; m_old_td = old_td; - assert((GetTileTrackStatus(m_old_tile, TT()) & TrackdirToTrackdirBits(m_old_td)) != 0); + assert((GetTileTrackStatus(m_old_tile, TT(), m_veh->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(m_old_td)) != 0); m_exitdir = TrackdirToExitdir(m_old_td); if (EnteredDepot()) return true; if (!CanExitOldTile()) return false; @@ -114,7 +114,7 @@ protected: if (IsRailTT() && GetTileType(m_new_tile) == MP_RAILWAY && IsPlainRailTile(m_new_tile)) { m_new_td_bits = (TrackdirBits)(GetTrackBits(m_new_tile) * 0x101); } else { - uint32 ts = GetTileTrackStatus(m_new_tile, TT()); + uint32 ts = GetTileTrackStatus(m_new_tile, TT(), m_veh->u.road.compatible_roadtypes); m_new_td_bits = (TrackdirBits)(ts & TRACKDIR_BIT_MASK); } return (m_new_td_bits != TRACKDIR_BIT_NONE); diff --git a/src/yapf/yapf_destrail.hpp b/src/yapf/yapf_destrail.hpp --- a/src/yapf/yapf_destrail.hpp +++ b/src/yapf/yapf_destrail.hpp @@ -113,7 +113,7 @@ public: default: m_destTile = v->dest_tile; m_dest_station_id = INVALID_STATION; - m_destTrackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_RAIL) & TRACKDIR_BIT_MASK); + m_destTrackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_RAIL, 0) & TRACKDIR_BIT_MASK); break; } CYapfDestinationRailBase::SetDestination(v); diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp --- a/src/yapf/yapf_road.cpp +++ b/src/yapf/yapf_road.cpp @@ -268,14 +268,14 @@ public: // our source tile will be the next vehicle tile (should be the given one) TileIndex src_tile = tile; // get available trackdirs on the start tile - uint ts = GetTileTrackStatus(tile, TRANSPORT_ROAD); + uint ts = GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes); TrackdirBits src_trackdirs = (TrackdirBits)(ts & TRACKDIR_BIT_MASK); // select reachable trackdirs only src_trackdirs &= DiagdirReachesTrackdirs(enterdir); // get available trackdirs on the destination tile TileIndex dest_tile = v->dest_tile; - uint dest_ts = GetTileTrackStatus(dest_tile, TRANSPORT_ROAD); + uint dest_ts = GetTileTrackStatus(dest_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes); TrackdirBits dest_trackdirs = (TrackdirBits)(dest_ts & TRACKDIR_BIT_MASK); // set origin and destination nodes @@ -320,7 +320,7 @@ public: // set destination tile, trackdir // get available trackdirs on the destination tile - uint dest_ts = GetTileTrackStatus(dst_tile, TRANSPORT_ROAD); + uint dest_ts = GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes); TrackdirBits dst_td_bits = (TrackdirBits)(dest_ts & TRACKDIR_BIT_MASK); Yapf().SetDestination(dst_tile, dst_td_bits); @@ -345,7 +345,7 @@ public: // set origin (tile, trackdir) TileIndex src_tile = v->tile; Trackdir src_td = GetVehicleTrackdir(v); - if ((GetTileTrackStatus(src_tile, TRANSPORT_ROAD) & TrackdirToTrackdirBits(src_td)) == 0) { + if ((GetTileTrackStatus(src_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(src_td)) == 0) { // sometimes the roadveh is not on the road (it resides on non-existing track) // how should we handle that situation? return false; @@ -438,7 +438,7 @@ Depot* YapfFindNearestRoadDepot(const Ve { TileIndex tile = v->tile; Trackdir trackdir = GetVehicleTrackdir(v); - if ((GetTileTrackStatus(tile, TRANSPORT_ROAD) & TrackdirToTrackdirBits(trackdir)) == 0) + if ((GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(trackdir)) == 0) return NULL; // handle the case when our vehicle is already in the depot tile diff --git a/src/yapf/yapf_ship.cpp b/src/yapf/yapf_ship.cpp --- a/src/yapf/yapf_ship.cpp +++ b/src/yapf/yapf_ship.cpp @@ -53,7 +53,7 @@ public: // convert origin trackdir to TrackdirBits TrackdirBits trackdirs = TrackdirToTrackdirBits(trackdir); // get available trackdirs on the destination tile - TrackdirBits dest_trackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_WATER) & TRACKDIR_BIT_MASK); + TrackdirBits dest_trackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_WATER, 0) & TRACKDIR_BIT_MASK); // create pathfinder instance Tpf pf;