summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-12-14 22:38:15 +0000
committermichi_cc <michi_cc@openttd.org>2011-12-14 22:38:15 +0000
commitcaebb5ac63d055c9cd1e99be49c78862e5459988 (patch)
tree25be134a4923a9817f0b10dd3b5d4a6af082a373 /src
parent66d1848f5e1b99e7e8884ad20203c617ca671b31 (diff)
downloadopenttd-caebb5ac63d055c9cd1e99be49c78862e5459988.tar.xz
(svn r23518) -Fix (r23124): [NewGRF] The refit cost callback wasn't called if only the subtype differed.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle_cmd.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 4914bcfb3..b101a16bc 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -228,7 +228,7 @@ static int GetRefitCostFactor(const Vehicle *v, EngineID engine_type, CargoID ne
}
*auto_refit_allowed = e->info.refit_cost == 0;
- return e->info.refit_cost;
+ return (v->cargo_type != new_cid) ? e->info.refit_cost : 0;
}
/**
@@ -335,17 +335,15 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
v->cargo_type = temp_cid;
v->cargo_subtype = temp_subtype;
- if (new_cid != v->cargo_type) {
- bool auto_refit_allowed;
- CommandCost refit_cost = GetRefitCost(v, v->engine_type, new_cid, new_subtype, &auto_refit_allowed);
- if (auto_refit && !auto_refit_allowed) {
- /* Sorry, auto-refitting not allowed, subtract the cargo amount again from the total. */
- total_capacity -= amount;
- total_mail_capacity -= mail_capacity;
- continue;
- }
- cost.AddCost(refit_cost);
+ bool auto_refit_allowed;
+ CommandCost refit_cost = GetRefitCost(v, v->engine_type, new_cid, new_subtype, &auto_refit_allowed);
+ if (auto_refit && !auto_refit_allowed) {
+ /* Sorry, auto-refitting not allowed, subtract the cargo amount again from the total. */
+ total_capacity -= amount;
+ total_mail_capacity -= mail_capacity;
+ continue;
}
+ cost.AddCost(refit_cost);
if (flags & DC_EXEC) {
v->cargo.Truncate((v->cargo_type == new_cid) ? amount : 0);