summaryrefslogtreecommitdiff
path: root/src/train_cmd.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-06-02 20:08:23 +0000
committerpeter1138 <peter1138@openttd.org>2007-06-02 20:08:23 +0000
commit2900732931c2fa5a465edc28826dcce3acd79abb (patch)
treef0cb8d1eb36131b822085e0c146c677c41de309a /src/train_cmd.cpp
parent9f13fc2cf59938ef04f5309986c9e48fd71ec6ad (diff)
downloadopenttd-2900732931c2fa5a465edc28826dcce3acd79abb.tar.xz
(svn r10028) -Fix (r2270/r2951): When deleting the first engine of a train with multiple engines, only reopen the train window if the player had the original train window open. This fixes 'random' windows opening for multiple players of the same company.
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r--src/train_cmd.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 2c300c190..8093cf331 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1205,6 +1205,9 @@ int32 CmdStartStopTrain(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
*/
int32 CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
+ /* Check if we deleted a vehicle window */
+ Window *w = NULL;
+
if (!IsValidVehicleID(p1) || p2 > 2) return CMD_ERROR;
Vehicle *v = GetVehicle(p1);
@@ -1225,7 +1228,8 @@ int32 CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) {
if (v == first && IsFrontEngine(first)) {
- DeleteWindowById(WC_VEHICLE_VIEW, first->index);
+ w = FindWindowById(WC_VEHICLE_VIEW, first->index);
+ if (w != NULL) DeleteWindow(w);
}
InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
RebuildVehicleLists();
@@ -1292,7 +1296,8 @@ int32 CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
first->prev_shared = NULL;
first->next_shared = NULL;
- if (IsLocalPlayer()) ShowTrainViewWindow(new_f);
+ /* If we deleted a window then open a new one for the 'new' train */
+ if (IsLocalPlayer() && w != NULL) ShowTrainViewWindow(new_f);
}
}