Fix ship collision avoidance near docks when dock not under station sign
See #77
This commit is contained in:
@@ -647,7 +647,13 @@ static bool HandleSpeedOnAqueduct(Ship *v, TileIndex tile, TileIndex ramp)
|
|||||||
*/
|
*/
|
||||||
static void CheckDistanceBetweenShips(TileIndex tile, Ship *v, TrackBits tracks, Track *track_old, DiagDirection diagdir)
|
static void CheckDistanceBetweenShips(TileIndex tile, Ship *v, TrackBits tracks, Track *track_old, DiagDirection diagdir)
|
||||||
{
|
{
|
||||||
if (DistanceManhattan(v->dest_tile, tile) <= 3 && !v->current_order.IsType(OT_GOTO_WAYPOINT)) return; // No checking close to docks and depots.
|
// No checking close to docks and depots.
|
||||||
|
if (v->current_order.IsType(OT_GOTO_STATION)) {
|
||||||
|
Station *st = Station::Get(v->current_order.GetDestination());
|
||||||
|
if (st->IsWithinRangeOfDockingTile(tile, 3)) return;
|
||||||
|
} else if (!v->current_order.IsType(OT_GOTO_WAYPOINT)) {
|
||||||
|
if (DistanceManhattan(v->dest_tile, tile) <= 3) return;
|
||||||
|
}
|
||||||
|
|
||||||
Track track = *track_old;
|
Track track = *track_old;
|
||||||
TrackBits track_bits = TrackToTrackBits(track);
|
TrackBits track_bits = TrackToTrackBits(track);
|
||||||
|
@@ -318,6 +318,15 @@ bool Station::IsDockingTile(TileIndex tile) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Station::IsWithinRangeOfDockingTile(TileIndex tile, uint max_distance) const
|
||||||
|
{
|
||||||
|
if (DistanceManhattan(this->xy, tile) > _settings_game.station.station_spread + max_distance) return false;
|
||||||
|
for (const Dock *d = this->docks; d != NULL; d = d->next) {
|
||||||
|
if (DistanceManhattan(d->GetDockingTile(), tile) <= max_distance) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** Rect and pointer to IndustryVector */
|
/** Rect and pointer to IndustryVector */
|
||||||
struct RectAndIndustryVector {
|
struct RectAndIndustryVector {
|
||||||
Rect rect; ///< The rectangle to search the industries in.
|
Rect rect; ///< The rectangle to search the industries in.
|
||||||
|
@@ -515,6 +515,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IsDockingTile(TileIndex tile) const;
|
bool IsDockingTile(TileIndex tile) const;
|
||||||
|
bool IsWithinRangeOfDockingTile(TileIndex tile, uint max_distance) const;
|
||||||
|
|
||||||
/* virtual */ uint32 GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const;
|
/* virtual */ uint32 GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user