summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vehicle_cmd.cpp15
-rw-r--r--src/vehicle_gui.cpp11
2 files changed, 21 insertions, 5 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 */
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 4ace090dd..10f1d952d 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -701,7 +701,10 @@ struct RefitWindow : public Window {
if (_returned_mail_refit_capacity > 0) {
SetDParam(2, CT_MAIL);
SetDParam(3, _returned_mail_refit_capacity);
- if (money <= 0) {
+ if (this->order != INVALID_VEH_ORDER_ID) {
+ /* No predictable cost */
+ return STR_PURCHASE_INFO_AIRCRAFT_CAPACITY;
+ } else if (money <= 0) {
SetDParam(4, -money);
return STR_REFIT_NEW_CAPACITY_INCOME_FROM_AIRCRAFT_REFIT;
} else {
@@ -709,7 +712,11 @@ struct RefitWindow : public Window {
return STR_REFIT_NEW_CAPACITY_COST_OF_AIRCRAFT_REFIT;
}
} else {
- if (money <= 0) {
+ if (this->order != INVALID_VEH_ORDER_ID) {
+ /* No predictable cost */
+ SetDParam(2, STR_EMPTY);
+ return STR_PURCHASE_INFO_CAPACITY;
+ } else if (money <= 0) {
SetDParam(2, -money);
return STR_REFIT_NEW_CAPACITY_INCOME_FROM_REFIT;
} else {