From 4020719227e591fb6ab13938033289b9ba9d1dc2 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 28 Feb 2020 18:52:02 +0000 Subject: [PATCH] Exclude effect and disaster vehicles from vehicle tile hash --- src/vehicle.cpp | 14 ++------------ src/vehicle_base.h | 11 ++++++++++- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 623dcacfd3..49827ca4d6 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -760,7 +760,7 @@ CommandCost EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits) return CommandCost(); } -static void UpdateVehicleTileHash(Vehicle *v, bool remove) +void UpdateVehicleTileHash(Vehicle *v, bool remove) { Vehicle **old_hash = v->hash_tile_current; Vehicle **new_hash; @@ -1078,7 +1078,7 @@ Vehicle::~Vehicle() delete v; - UpdateVehicleTileHash(this, true); + if (this->type < VEH_COMPANY_END) UpdateVehicleTileHash(this, true); UpdateVehicleViewportHash(this, INVALID_COORD, 0); DeleteVehicleNews(this->index, INVALID_STRING_ID); DeleteNewGRFInspectWindow(GetGrfSpecFeature(this->type), this->index); @@ -2330,16 +2330,6 @@ void VehicleEnterDepot(Vehicle *v) } } - -/** - * Update the position of the vehicle. This will update the hash that tells - * which vehicles are on a tile. - */ -void Vehicle::UpdatePosition() -{ - UpdateVehicleTileHash(this, false); -} - /** * Update the vehicle on the viewport, updating the right hash and setting the * new coordinates. diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 365e4e38cd..b4032cbac4 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -864,7 +864,16 @@ public: void UpdateVisualEffect(bool allow_power_change = true); void ShowVisualEffect() const; - void UpdatePosition(); + /** + * Update the position of the vehicle. This will update the hash that tells + * which vehicles are on a tile. + */ + void UpdatePosition() + { + extern void UpdateVehicleTileHash(Vehicle *v, bool remove); + if (this->type < VEH_COMPANY_END) UpdateVehicleTileHash(this, false); + } + void UpdateViewport(bool dirty); void UpdatePositionAndViewport(); void MarkAllViewportsDirty() const;