diff options
author | fonsinchen <fonsinchen@openttd.org> | 2013-06-07 22:22:52 +0000 |
---|---|---|
committer | fonsinchen <fonsinchen@openttd.org> | 2013-06-07 22:22:52 +0000 |
commit | 478fcadd21936412332717b0f1eab564e8e88eaa (patch) | |
tree | 9e2d297ef0c0cb0372767b6066c86d39197dcf0f /src | |
parent | a1a96b2e8b6919a5e133b2f021672c3285ce9185 (diff) | |
download | openttd-478fcadd21936412332717b0f1eab564e8e88eaa.tar.xz |
(svn r25330) -Fix [FS#5583]: return some reserved cargo if vehicle is overloaded by station stopping acceptance for cargo scheduled to be delivered
Diffstat (limited to 'src')
-rw-r--r-- | src/economy.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index aa7d94ce3..7ae5daccb 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1299,6 +1299,7 @@ static void ReserveConsist(Station *st, Vehicle *u, CargoArray *consist_capleft) continue; } + assert(v->cargo_cap >= v->cargo.RemainingCount()); uint cap = v->cargo_cap - v->cargo.RemainingCount(); /* Nothing to do if the vehicle is full */ @@ -1398,6 +1399,12 @@ static void LoadUnloadVehicle(Vehicle *front) v->cargo.Reassign(v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER), VehicleCargoList::MTA_DELIVER, VehicleCargoList::MTA_TRANSFER); } else { + uint new_remaining = v->cargo.RemainingCount() + v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER); + if (v->cargo_cap < new_remaining) { + /* Return some of the reserved cargo to not overload the vehicle. */ + v->cargo.Return(new_remaining - v->cargo_cap, &ge->cargo); + } + /* Keep instead of delivering. This may lead to no cargo being unloaded, so ...*/ v->cargo.Reassign(v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER), VehicleCargoList::MTA_DELIVER, VehicleCargoList::MTA_KEEP); |