summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2014-04-23 20:22:27 +0000
committerfonsinchen <fonsinchen@openttd.org>2014-04-23 20:22:27 +0000
commit49f27eb247220c2027f4588c7385c392d3ac0a39 (patch)
tree09423bd6d95b437b2eec3f361e1ab37c8976d2f7 /src/economy.cpp
parent0463dbdc9e5b39399765015c394e29dedaf7d041 (diff)
downloadopenttd-49f27eb247220c2027f4588c7385c392d3ac0a39.tar.xz
(svn r26483) -Fix: Allow single-vehicle consists to station-refit in a meaningful way.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r--src/economy.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index fd089f82b..e3b3575b3 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1403,8 +1403,13 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
DoCommand(v_start->tile, v_start->index, cid | 1U << 6 | 0xFF << 8 | 1U << 16, DC_QUERY_COST, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
/* Try to balance different loadable cargoes between parts of the consist, so that
* all of them can be loaded. Avoid a situation where all vehicles suddenly switch
- * to the first loadable cargo for which there is only one packet. */
- if (_returned_refit_capacity > 0 && consist_capleft[cid] < consist_capleft[new_cid]) {
+ * to the first loadable cargo for which there is only one packet. If the capacities
+ * are equal refit to the cargo of which most is available. This is important for
+ * consists of only a single vehicle as those will generally have a consist_capleft
+ * of 0 for all cargoes. */
+ if (_returned_refit_capacity > 0 && (consist_capleft[cid] < consist_capleft[new_cid] ||
+ (consist_capleft[cid] == consist_capleft[new_cid] &&
+ st->goods[cid].cargo.AvailableCount() > st->goods[new_cid].cargo.AvailableCount()))) {
new_cid = cid;
}
}