|
@@ -13,23 +13,39 @@ INSTANTIATE_POOL_METHODS(CargoPacket)
|
|
|
|
|
|
void InitializeCargoPackets()
|
|
|
{
|
|
|
_cargopacket_pool.CleanPool();
|
|
|
}
|
|
|
|
|
|
CargoPacket::CargoPacket(StationID source, uint16 count)
|
|
|
CargoPacket::CargoPacket(StationID source, uint16 count, SourceType source_type, SourceID source_id)
|
|
|
{
|
|
|
if (source != INVALID_STATION) assert(count != 0);
|
|
|
|
|
|
this->source = source;
|
|
|
// this->feeder_share = 0; // no need to zero already zeroed data (by operator new)
|
|
|
this->source_xy = (source != INVALID_STATION) ? Station::Get(source)->xy : 0;
|
|
|
this->loaded_at_xy = this->source_xy;
|
|
|
this->source = source;
|
|
|
|
|
|
this->count = count;
|
|
|
this->days_in_transit = 0;
|
|
|
this->feeder_share = 0;
|
|
|
// this->days_in_transit = 0;
|
|
|
|
|
|
this->source_type = source_type;
|
|
|
this->source_id = source_id;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Invalidates (sets source_id to INVALID_SOURCE) all cargo packets from given source
|
|
|
* @param src_type type of source
|
|
|
* @param src index of source
|
|
|
*/
|
|
|
/* static */ void CargoPacket::InvalidateAllFrom(SourceType src_type, SourceID src)
|
|
|
{
|
|
|
CargoPacket *cp;
|
|
|
FOR_ALL_CARGOPACKETS(cp) {
|
|
|
if (cp->source_type == src_type && cp->source_id == src) cp->source_id = INVALID_SOURCE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*
|
|
|
* Cargo list implementation
|
|
|
*
|
|
@@ -146,12 +162,15 @@ bool CargoList::MoveTo(CargoList *dest,
|
|
|
cp_new->source_xy = cp->source_xy;
|
|
|
cp_new->loaded_at_xy = (mta == MTA_CARGO_LOAD) ? data : cp->loaded_at_xy;
|
|
|
|
|
|
cp_new->days_in_transit = cp->days_in_transit;
|
|
|
cp_new->feeder_share = fs;
|
|
|
|
|
|
cp_new->source_type = cp->source_type;
|
|
|
cp_new->source_id = cp->source_id;
|
|
|
|
|
|
cp_new->count = count;
|
|
|
dest->packets.push_back(cp_new);
|
|
|
|
|
|
if (mta == MTA_TRANSFER) payment->PayTransfer(cp_new, count);
|
|
|
} else {
|
|
|
payment->PayFinalDelivery(cp, count);
|