equal
deleted
inserted
replaced
85 const Vehicle* v = Yapf().GetVehicle(); |
85 const Vehicle* v = Yapf().GetVehicle(); |
86 // we have reached the vehicle's destination - segment should end here to avoid target skipping |
86 // we have reached the vehicle's destination - segment should end here to avoid target skipping |
87 if (v->current_order.IsType(OT_GOTO_STATION) && tile == v->dest_tile) break; |
87 if (v->current_order.IsType(OT_GOTO_STATION) && tile == v->dest_tile) break; |
88 |
88 |
89 // stop if we have just entered the depot |
89 // stop if we have just entered the depot |
90 if (IsTileDepotType(tile, TRANSPORT_ROAD) && trackdir == DiagdirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) { |
90 if (IsDepotTypeTile(tile, TRANSPORT_ROAD) && trackdir == DiagdirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) { |
91 // next time we will reverse and leave the depot |
91 // next time we will reverse and leave the depot |
92 break; |
92 break; |
93 } |
93 } |
94 |
94 |
95 // if there are no reachable trackdirs on new tile, we have end of road |
95 // if there are no reachable trackdirs on new tile, we have end of road |
146 Tpf& Yapf() {return *static_cast<Tpf*>(this);} |
146 Tpf& Yapf() {return *static_cast<Tpf*>(this);} |
147 |
147 |
148 /// Called by YAPF to detect if node ends in the desired destination |
148 /// Called by YAPF to detect if node ends in the desired destination |
149 FORCEINLINE bool PfDetectDestination(Node& n) |
149 FORCEINLINE bool PfDetectDestination(Node& n) |
150 { |
150 { |
151 bool bDest = IsTileDepotType(n.m_segment_last_tile, TRANSPORT_ROAD); |
151 bool bDest = IsDepotTypeTile(n.m_segment_last_tile, TRANSPORT_ROAD); |
152 return bDest; |
152 return bDest; |
153 } |
153 } |
154 |
154 |
155 /** Called by YAPF to calculate cost estimate. Calculates distance to the destination |
155 /** Called by YAPF to calculate cost estimate. Calculates distance to the destination |
156 * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */ |
156 * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */ |
368 |
368 |
369 // some path found |
369 // some path found |
370 // get found depot tile |
370 // get found depot tile |
371 Node *n = Yapf().GetBestNode(); |
371 Node *n = Yapf().GetBestNode(); |
372 TileIndex depot_tile = n->m_segment_last_tile; |
372 TileIndex depot_tile = n->m_segment_last_tile; |
373 assert(IsTileDepotType(depot_tile, TRANSPORT_ROAD)); |
373 assert(IsDepotTypeTile(depot_tile, TRANSPORT_ROAD)); |
374 Depot* ret = GetDepotByTile(depot_tile); |
374 Depot* ret = GetDepotByTile(depot_tile); |
375 return ret; |
375 return ret; |
376 } |
376 } |
377 }; |
377 }; |
378 |
378 |
437 Trackdir trackdir = GetVehicleTrackdir(v); |
437 Trackdir trackdir = GetVehicleTrackdir(v); |
438 if ((TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes)) & TrackdirToTrackdirBits(trackdir)) == 0) |
438 if ((TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes)) & TrackdirToTrackdirBits(trackdir)) == 0) |
439 return NULL; |
439 return NULL; |
440 |
440 |
441 // handle the case when our vehicle is already in the depot tile |
441 // handle the case when our vehicle is already in the depot tile |
442 if (IsTileType(tile, MP_ROAD) && IsTileDepotType(tile, TRANSPORT_ROAD)) { |
442 if (IsTileType(tile, MP_ROAD) && IsDepotTypeTile(tile, TRANSPORT_ROAD)) { |
443 // only what we need to return is the Depot* |
443 // only what we need to return is the Depot* |
444 return GetDepotByTile(tile); |
444 return GetDepotByTile(tile); |
445 } |
445 } |
446 |
446 |
447 // default is YAPF type 2 |
447 // default is YAPF type 2 |