summaryrefslogtreecommitdiff
path: root/src/cargopacket.cpp
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2008-05-04 10:05:35 +0000
committerbjarni <bjarni@openttd.org>2008-05-04 10:05:35 +0000
commit63fea0790b405ee5c48c1b48c51d93dc4639e8d3 (patch)
treec16aecefc1241e86133980055d11b5c8aadaa468 /src/cargopacket.cpp
parentb35100e2a9b109581086a078f9adec0addd7284f (diff)
downloadopenttd-63fea0790b405ee5c48c1b48c51d93dc4639e8d3.tar.xz
(svn r12940) -Fix [FS#1974](r12913): [autoreplace] a vehicle backup should include the cargo packets in the vehicle as well
Diffstat (limited to 'src/cargopacket.cpp')
-rw-r--r--src/cargopacket.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp
index d4c8d0871..b743ebd16 100644
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -273,3 +273,15 @@ void CargoList::InvalidateCache()
days_in_transit = dit / count;
source = (*packets.begin())->source;
}
+
+/** Restore an array of cargo packets from a backup
+ * The end of the row should be marked by an invalid packet
+ */
+void CargoPacket::RestoreBackup() const
+{
+ for (const CargoPacket *cargo = this; cargo->IsValid(); cargo++) {
+ CargoPacket *dest = GetCargoPacket(cargo->index);
+ assert(!dest->IsValid());
+ memcpy(dest, cargo, sizeof(CargoPacket));
+ }
+}