1
/* $Id: cargopacket.cpp 14271 2008-09-07 22:31:15Z rubidium $ */
1
/* $Id: cargopacket.cpp 15299 2009-01-31 20:16:06Z smatz $ */
3
3
/** @file cargopacket.cpp Implementation of the cargo packets */
8
#include "cargopacket.h"
6
#include "station_base.h"
7
#include "oldpool_func.h"
11
9
/* Initialize the cargopacket-pool */
12
10
DEFINE_OLD_POOL_GENERIC(CargoPacket, CargoPacket)
42
40
return this->source_xy == cp->source_xy && this->days_in_transit == cp->days_in_transit && this->paid_for == cp->paid_for;
45
static const SaveLoad _cargopacket_desc[] = {
46
SLE_VAR(CargoPacket, source, SLE_UINT16),
47
SLE_VAR(CargoPacket, source_xy, SLE_UINT32),
48
SLE_VAR(CargoPacket, loaded_at_xy, SLE_UINT32),
49
SLE_VAR(CargoPacket, count, SLE_UINT16),
50
SLE_VAR(CargoPacket, days_in_transit, SLE_UINT8),
51
SLE_VAR(CargoPacket, feeder_share, SLE_INT64),
52
SLE_VAR(CargoPacket, paid_for, SLE_BOOL),
57
static void Save_CAPA()
61
FOR_ALL_CARGOPACKETS(cp) {
62
SlSetArrayIndex(cp->index);
63
SlObject(cp, _cargopacket_desc);
67
static void Load_CAPA()
71
while ((index = SlIterateArray()) != -1) {
72
CargoPacket *cp = new (index) CargoPacket();
73
SlObject(cp, _cargopacket_desc);
77
extern const ChunkHandler _cargopacket_chunk_handlers[] = {
78
{ 'CAPA', Save_CAPA, Load_CAPA, CH_ARRAY | CH_LAST},
83
45
* Cargo list implementation
244
206
if (mta == MTA_FINAL_DELIVERY && !tmp.Empty()) {
245
207
/* There are some packets that could not be delivered at the station, put them back */
246
tmp.MoveTo(this, MAX_UVALUE(uint));
208
tmp.MoveTo(this, UINT_MAX);
247
209
tmp.packets.clear();