summaryrefslogtreecommitdiff
path: root/src/vehicle_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2015-10-30 17:27:21 +0000
committerfrosch <frosch@openttd.org>2015-10-30 17:27:21 +0000
commit0974f5489bea9ebb8c2a4b3aa70b8de257a9ab64 (patch)
treeb7bf00c61ebe071a1c57a6c91fb9751e27a486de /src/vehicle_cmd.cpp
parent2d636266f59e8f5e88c3460b9adb8889442108d8 (diff)
downloadopenttd-0974f5489bea9ebb8c2a4b3aa70b8de257a9ab64.tar.xz
(svn r27428) -Fix: When selecting a refit cargo for orders, do not check whether the vehicle is in a depot or station, and do not ask whether the vehicle currently allows station-refitting. Also hide the refit cost for orders, it is not predictable.
Diffstat (limited to 'src/vehicle_cmd.cpp')
-rw-r--r--src/vehicle_cmd.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 72cff271a..3b664defb 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -358,8 +358,10 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
bool auto_refit_allowed;
CommandCost refit_cost = GetRefitCost(v, v->engine_type, new_cid, actual_subtype, &auto_refit_allowed);
- if (auto_refit && !auto_refit_allowed) {
- /* Sorry, auto-refitting not allowed, subtract the cargo amount again from the total. */
+ if (auto_refit && (flags & DC_QUERY_COST) == 0 && !auto_refit_allowed) {
+ /* Sorry, auto-refitting not allowed, subtract the cargo amount again from the total.
+ * When querrying cost/capacity (for example in order refit GUI), we always assume 'allowed'.
+ * It is not predictable. */
total_capacity -= amount;
total_mail_capacity -= mail_capacity;
@@ -446,8 +448,15 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
/* 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 (!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 ((flags & DC_QUERY_COST) == 0 && // used by the refit GUI, including the order refit GUI.
+ !free_wagon && // used by autoreplace/renew
+ (!auto_refit || !front->current_order.IsType(OT_LOADING)) && // refit inside stations
+ !front->IsStoppedInDepot()) { // refit inside depots
+ 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 */