summaryrefslogtreecommitdiff
path: root/src/vehicle_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-02-17 14:10:15 +0000
committerrubidium <rubidium@openttd.org>2013-02-17 14:10:15 +0000
commit2795ed5b091fa5580976547b3669bac78cd595ce (patch)
tree9b0d3c0b5444157729363fc0323b6a2236e53d49 /src/vehicle_cmd.cpp
parent6647cb917963c4e0d6d633b7a92af78167050893 (diff)
downloadopenttd-2795ed5b091fa5580976547b3669bac78cd595ce.tar.xz
(svn r25008) -Codechange: Make CargoList::Truncate behave similarly to CargoList::MoveTo, i.e. pass the amount to truncate (fonsinchen)
Diffstat (limited to 'src/vehicle_cmd.cpp')
-rw-r--r--src/vehicle_cmd.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 7271d27b0..2cbe2c654 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -386,14 +386,20 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
/* Store the result */
for (RefitResult *result = refit_result.Begin(); result != refit_result.End(); result++) {
Vehicle *u = result->v;
- u->cargo.Truncate((u->cargo_type == new_cid) ? result->capacity : 0);
+ if (u->cargo_type != new_cid) {
+ u->cargo.Truncate(u->cargo_cap);
+ } else if (u->cargo_cap > result->capacity) {
+ u->cargo.Truncate(u->cargo_cap - result->capacity);
+ }
u->cargo_type = new_cid;
u->cargo_cap = result->capacity;
u->cargo_subtype = new_subtype;
if (u->type == VEH_AIRCRAFT) {
Vehicle *w = u->Next();
+ if (w->cargo_cap > result->mail_capacity) {
+ w->cargo.Truncate(w->cargo_cap - result->mail_capacity);
+ }
w->cargo_cap = result->mail_capacity;
- w->cargo.Truncate(result->mail_capacity);
}
}
}