summaryrefslogtreecommitdiff
path: root/src/autoreplace_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-06-22 11:58:59 +0000
committerrubidium <rubidium@openttd.org>2007-06-22 11:58:59 +0000
commitfc201d4ad8268234ce67d2ea1e49d470ab0c2004 (patch)
treefd6fbc96b8d23bef18ed7267fa8174e1689c8e78 /src/autoreplace_cmd.cpp
parentdc82eeb2ae166f3284cda1aa265045c10c29b4c2 (diff)
downloadopenttd-fc201d4ad8268234ce67d2ea1e49d470ab0c2004.tar.xz
(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.
Diffstat (limited to 'src/autoreplace_cmd.cpp')
-rw-r--r--src/autoreplace_cmd.cpp12
1 files changed, 4 insertions, 8 deletions
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);