File diff r12647:3ada08b745f5 → r12648:24c912bd53f6
src/cargopacket.cpp
Show inline comments
 
@@ -16,17 +16,33 @@ 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;
 
	}
 
}
 

	
 
/*
 
@@ -149,6 +165,9 @@ bool CargoList::MoveTo(CargoList *dest, 
 
				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);