equal
deleted
inserted
replaced
343 } |
343 } |
344 Yapf().SetOrigin(src_tile, TrackdirToTrackdirBits(src_td)); |
344 Yapf().SetOrigin(src_tile, TrackdirToTrackdirBits(src_td)); |
345 return true; |
345 return true; |
346 } |
346 } |
347 |
347 |
348 static Depot* stFindNearestDepot(Vehicle* v, TileIndex tile, Trackdir td) |
348 static Depot* stFindNearestDepot(const Vehicle* v, TileIndex tile, Trackdir td) |
349 { |
349 { |
350 Tpf pf; |
350 Tpf pf; |
351 return pf.FindNearestDepot(v, tile, td); |
351 return pf.FindNearestDepot(v, tile, td); |
352 } |
352 } |
353 |
353 |
354 FORCEINLINE Depot* FindNearestDepot(Vehicle* v, TileIndex tile, Trackdir td) |
354 FORCEINLINE Depot* FindNearestDepot(const Vehicle* v, TileIndex tile, Trackdir td) |
355 { |
355 { |
356 // set origin and destination nodes |
356 // set origin and destination nodes |
357 Yapf().SetOrigin(tile, TrackdirToTrackdirBits(td)); |
357 Yapf().SetOrigin(tile, TrackdirToTrackdirBits(td)); |
358 |
358 |
359 // find the best path |
359 // find the best path |
438 // only what we need to return is the Depot* |
438 // only what we need to return is the Depot* |
439 return GetDepotByTile(tile); |
439 return GetDepotByTile(tile); |
440 } |
440 } |
441 |
441 |
442 // default is YAPF type 2 |
442 // default is YAPF type 2 |
443 typedef Depot* (*PfnFindNearestDepot)(Vehicle*, TileIndex, Trackdir); |
443 typedef Depot* (*PfnFindNearestDepot)(const Vehicle*, TileIndex, Trackdir); |
444 PfnFindNearestDepot pfnFindNearestDepot = &CYapfRoadAnyDepot2::stFindNearestDepot; |
444 PfnFindNearestDepot pfnFindNearestDepot = &CYapfRoadAnyDepot2::stFindNearestDepot; |
445 |
445 |
446 // check if non-default YAPF type should be used |
446 // check if non-default YAPF type should be used |
447 if (_patches.yapf.disable_node_optimization) |
447 if (_patches.yapf.disable_node_optimization) |
448 pfnFindNearestDepot = &CYapfRoadAnyDepot1::stFindNearestDepot; // Trackdir, allow 90-deg |
448 pfnFindNearestDepot = &CYapfRoadAnyDepot1::stFindNearestDepot; // Trackdir, allow 90-deg |
449 |
449 |
450 Depot* ret = pfnFindNearestDepot(const_cast<Vehicle*>(v), tile, trackdir); |
450 Depot* ret = pfnFindNearestDepot(v, tile, trackdir); |
451 return ret; |
451 return ret; |
452 } |
452 } |