From fc201d4ad8268234ce67d2ea1e49d470ab0c2004 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 22 Jun 2007 11:58:59 +0000 Subject: (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it. --- src/autoreplace_cmd.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/autoreplace_cmd.cpp') diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 14c5e3310..88df05c5c 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -25,27 +25,23 @@ static void MoveVehicleCargo(Vehicle *dest, Vehicle *source) { Vehicle *v = dest; - int units_moved; do { do { if (source->cargo_type != dest->cargo_type) continue; // cargo not compatible - if (dest->cargo_count == dest->cargo_cap) + if (dest->cargo.Count() == dest->cargo_cap) continue; // the destination vehicle is already full - units_moved = min(source->cargo_count, dest->cargo_cap - dest->cargo_count); - source->cargo_count -= units_moved; - dest->cargo_count += units_moved; - dest->cargo_source = source->cargo_source; + uint units_moved = min(source->cargo.Count(), dest->cargo_cap - dest->cargo.Count()); + source->cargo.MoveTo(&dest->cargo, units_moved); // copy the age of the cargo - dest->cargo_days = source->cargo_days; dest->day_counter = source->day_counter; dest->tick_counter = source->tick_counter; - } while (source->cargo_count > 0 && (dest = dest->next) != NULL); + } while (source->cargo.Count() > 0 && (dest = dest->next) != NULL); dest = v; } while ((source = source->next) != NULL); -- cgit v1.2.3-54-g00ecf