diff options
author | bjarni <bjarni@openttd.org> | 2006-12-05 22:40:42 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2006-12-05 22:40:42 +0000 |
commit | 686a0d7750405d10088a23732f33359728039aa5 (patch) | |
tree | 7cde78aa4303c23647773e8bf85a100202213917 | |
parent | a9ea304121f708f816f09f1dc77828592ca90e6c (diff) | |
download | openttd-686a0d7750405d10088a23732f33359728039aa5.tar.xz |
(svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
This turned out to be due to continue to drag the old vehicle, that autoreplace sold
This could also be triggered if more than one player used the same company
Now deleting a vehicle will remove all depot highlights of that vehicle
-rw-r--r-- | depot.h | 2 | ||||
-rw-r--r-- | depot_gui.c | 18 | ||||
-rw-r--r-- | vehicle.c | 2 |
3 files changed, 22 insertions, 0 deletions
@@ -107,4 +107,6 @@ Depot *GetDepotByTile(TileIndex tile); void InitializeDepots(void); Depot *AllocateDepot(void); +void DeleteDepotHighlightOfVehicle(const Vehicle *v); + #endif /* DEPOT_H */ diff --git a/depot_gui.c b/depot_gui.c index da879bb42..c0ee00ddc 100644 --- a/depot_gui.c +++ b/depot_gui.c @@ -1033,3 +1033,21 @@ void ShowDepotWindow(TileIndex tile, byte type) ResizeDepotButtons(w); } } + +/** Removes the highlight of a vehicle in a depot window + * @param *v Vehicle to remove all highlights from + */ +void DeleteDepotHighlightOfVehicle(const Vehicle *v) +{ + Window* const *wz; + + FOR_ALL_WINDOWS(wz) { + const Window *w = *wz; + if (w->window_class != WC_VEHICLE_DEPOT) continue; + if (w->window_number != v->tile) continue; + if (WP(w, depot_d).sel == v->index) { + WP(w, depot_d).sel = INVALID_VEHICLE; + ResetObjectToPlace(); + } + } +} @@ -566,6 +566,8 @@ void DestroyVehicle(Vehicle *v) InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); } + DeleteDepotHighlightOfVehicle(v); + UpdateVehiclePosHash(v, INVALID_COORD, 0); v->next_hash = INVALID_VEHICLE; if (v->orders != NULL) DeleteVehicleOrders(v); |