From ba66343558684a8fce9b17dde9dcf9baed0dd0ba Mon Sep 17 00:00:00 2001 From: fonsinchen Date: Wed, 23 Apr 2014 20:22:27 +0000 Subject: [PATCH] (svn r26483) -Fix: Allow single-vehicle consists to station-refit in a meaningful way. --- src/economy.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/economy.cpp b/src/economy.cpp index fd089f82b5..e3b3575b3d 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; } }