diff options
author | rubidium <rubidium@openttd.org> | 2013-05-19 14:22:04 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2013-05-19 14:22:04 +0000 |
commit | 39474532777a1f7beadfd940abf29292bc39879a (patch) | |
tree | 59165ada9556ce5b154ec31cbb994827e7e90fe6 /src/vehicle_cmd.cpp | |
parent | 0cc3d8df4b79628c702ba1293cdc00c099dd0b60 (diff) | |
download | openttd-39474532777a1f7beadfd940abf29292bc39879a.tar.xz |
(svn r25259) -Codechange: track capacities and usage of links
Diffstat (limited to 'src/vehicle_cmd.cpp')
-rw-r--r-- | src/vehicle_cmd.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 7cdb4eb49..a7e2f305b 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -397,20 +397,16 @@ 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; - 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->refit_cap = (u->cargo_type == new_cid) ? min(result->capacity, u->refit_cap) : 0; + if (u->cargo.TotalCount() > u->refit_cap) u->cargo.Truncate(u->cargo.TotalCount() - u->refit_cap); u->cargo_type = new_cid; u->cargo_cap = result->capacity; u->cargo_subtype = result->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->refit_cap = min(w->refit_cap, result->mail_capacity); w->cargo_cap = result->mail_capacity; + if (w->cargo.TotalCount() > w->refit_cap) w->cargo.Truncate(w->cargo.TotalCount() - w->refit_cap); } } } |