diff options
author | bjarni <bjarni@openttd.org> | 2008-05-04 10:05:35 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2008-05-04 10:05:35 +0000 |
commit | dbf6e344a419cf453ce8a292a588385b5299c996 (patch) | |
tree | c16aecefc1241e86133980055d11b5c8aadaa468 /src/cargopacket.cpp | |
parent | 8ca10353163dfb34174b4c2a1fad94c3286bb868 (diff) | |
download | openttd-dbf6e344a419cf453ce8a292a588385b5299c996.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.cpp | 12 |
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)); + } +} |