|
@@ -6,12 +6,13 @@
|
|
|
#define CARGOPACKET_H
|
|
|
|
|
|
#include "core/pool_type.hpp"
|
|
|
#include "economy_type.h"
|
|
|
#include "tile_type.h"
|
|
|
#include "station_type.h"
|
|
|
#include "cargo_type.h"
|
|
|
#include <list>
|
|
|
|
|
|
typedef uint32 CargoPacketID;
|
|
|
struct CargoPacket;
|
|
|
|
|
|
/** We want to use a pool */
|
|
@@ -27,33 +28,39 @@ struct CargoPacket : CargoPacketPool::Po
|
|
|
TileIndex loaded_at_xy; ///< Location where this cargo has been loaded into the vehicle
|
|
|
StationID source; ///< The station where the cargo came from first
|
|
|
|
|
|
uint16 count; ///< The amount of cargo in this packet
|
|
|
byte days_in_transit; ///< Amount of days this packet has been in transit
|
|
|
|
|
|
SourceTypeByte source_type; ///< Type of #source_id
|
|
|
SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid
|
|
|
|
|
|
/**
|
|
|
* Creates a new cargo packet
|
|
|
* @param source the source of the packet
|
|
|
* @param count the number of cargo entities to put in this packet
|
|
|
* @pre count != 0 || source == INVALID_STATION
|
|
|
*/
|
|
|
CargoPacket(StationID source = INVALID_STATION, uint16 count = 0);
|
|
|
CargoPacket(StationID source = INVALID_STATION, uint16 count = 0, SourceType source_type = ST_INDUSTRY, SourceID source_id = INVALID_SOURCE);
|
|
|
|
|
|
/** Destroy the packet */
|
|
|
~CargoPacket() { }
|
|
|
|
|
|
/**
|
|
|
* Checks whether the cargo packet is from (exactly) the same source
|
|
|
* in time and location.
|
|
|
* @param cp the cargo packet to compare to
|
|
|
* @return true if and only if days_in_transit and source_xy are equal
|
|
|
*/
|
|
|
FORCEINLINE bool SameSource(const CargoPacket *cp) const
|
|
|
{
|
|
|
return this->source_xy == cp->source_xy && this->days_in_transit == cp->days_in_transit;
|
|
|
return this->source_xy == cp->source_xy && this->days_in_transit == cp->days_in_transit &&
|
|
|
this->source_type == cp->source_type && this->source_id == cp->source_id;
|
|
|
}
|
|
|
|
|
|
static void InvalidateAllFrom(SourceType src_type, SourceID src);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Iterate over all _valid_ cargo packets from the given start
|
|
|
* @param var the variable used as "iterator"
|
|
|
* @param start the cargo packet ID of the first packet to iterate over
|