summaryrefslogtreecommitdiff
path: root/src/vehicle_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-08-06 21:01:14 +0000
committerfrosch <frosch@openttd.org>2013-08-06 21:01:14 +0000
commitfbe6b92b1da1f2586738f1cc9b268a2783966321 (patch)
tree2e57895dbdf71d9e8b7fc2f804f2e9b1acdb04f3 /src/vehicle_cmd.cpp
parent8f95bab00174fe3038bbdb14ea5077c11b10f0bb (diff)
downloadopenttd-fbe6b92b1da1f2586738f1cc9b268a2783966321.tar.xz
(svn r25698) -Fix [FS#5700]: Autoreplace/renew also refits free wagons.
Diffstat (limited to 'src/vehicle_cmd.cpp')
-rw-r--r--src/vehicle_cmd.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 8bd6f1b9f..68e6fff1a 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -447,11 +447,12 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (ret.Failed()) return ret;
bool auto_refit = HasBit(p2, 6);
+ bool free_wagon = v->type == VEH_TRAIN && Train::From(front)->IsFreeWagon(); // used by autoreplace/renew
/* Don't allow shadows and such to be refitted. */
if (v != front && (v->type == VEH_SHIP || v->type == VEH_AIRCRAFT)) return CMD_ERROR;
/* Allow auto-refitting only during loading and normal refitting only in a depot. */
- if ((!auto_refit || !front->current_order.IsType(OT_LOADING)) && !front->IsStoppedInDepot()) return_cmd_error(STR_ERROR_TRAIN_MUST_BE_STOPPED_INSIDE_DEPOT + front->type);
+ if (!free_wagon && (!auto_refit || !front->current_order.IsType(OT_LOADING)) && !front->IsStoppedInDepot()) return_cmd_error(STR_ERROR_TRAIN_MUST_BE_STOPPED_INSIDE_DEPOT + front->type);
if (front->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_VEHICLE_IS_DESTROYED);
/* Check cargo */
@@ -490,9 +491,11 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
}
front->MarkDirty();
- InvalidateWindowData(WC_VEHICLE_DETAILS, front->index);
+ if (!free_wagon) {
+ InvalidateWindowData(WC_VEHICLE_DETAILS, front->index);
+ InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
+ }
SetWindowDirty(WC_VEHICLE_DEPOT, front->tile);
- InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
} else {
/* Always invalidate the cache; querycost might have filled it. */
v->InvalidateNewGRFCacheOfChain();