2007-06-22 11:58:59 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file cargopacket.h Base class for cargo packets. */
|
2007-06-22 11:58:59 +00:00
|
|
|
|
|
|
|
#ifndef CARGOPACKET_H
|
|
|
|
#define CARGOPACKET_H
|
|
|
|
|
2009-05-22 15:39:22 +00:00
|
|
|
#include "core/pool_type.hpp"
|
2007-12-21 22:50:51 +00:00
|
|
|
#include "economy_type.h"
|
2008-01-09 21:27:39 +00:00
|
|
|
#include "tile_type.h"
|
2008-03-28 16:33:28 +00:00
|
|
|
#include "station_type.h"
|
2009-08-08 16:42:55 +00:00
|
|
|
#include "cargo_type.h"
|
2009-10-06 23:01:35 +00:00
|
|
|
#include "vehicle_type.h"
|
2007-06-22 11:58:59 +00:00
|
|
|
#include <list>
|
|
|
|
|
2009-10-06 19:52:27 +00:00
|
|
|
/** Unique identifier for a single cargo packet. */
|
2007-08-02 10:49:24 +00:00
|
|
|
typedef uint32 CargoPacketID;
|
|
|
|
struct CargoPacket;
|
|
|
|
|
2009-10-06 19:52:27 +00:00
|
|
|
/** Type of the pool for cargo packets. */
|
2009-05-22 15:13:50 +00:00
|
|
|
typedef Pool<CargoPacket, CargoPacketID, 1024, 1048576> CargoPacketPool;
|
2009-10-06 19:52:27 +00:00
|
|
|
/** The actual pool with cargo packets */
|
2009-05-22 15:13:50 +00:00
|
|
|
extern CargoPacketPool _cargopacket_pool;
|
2007-08-02 10:49:24 +00:00
|
|
|
|
2009-10-18 14:28:26 +00:00
|
|
|
template <class Tinst> class CargoList;
|
2009-10-06 17:23:15 +00:00
|
|
|
extern const struct SaveLoad *GetCargoPacketDesc();
|
|
|
|
|
2007-06-22 11:58:59 +00:00
|
|
|
/**
|
|
|
|
* Container for cargo from the same location and time
|
|
|
|
*/
|
2009-05-22 15:13:50 +00:00
|
|
|
struct CargoPacket : CargoPacketPool::PoolItem<&_cargopacket_pool> {
|
2009-10-06 17:23:15 +00:00
|
|
|
private:
|
2009-10-18 17:53:34 +00:00
|
|
|
Money feeder_share; ///< Value of feeder pickup to be paid for on delivery of cargo
|
|
|
|
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 \c source_id
|
|
|
|
SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid
|
|
|
|
StationID source; ///< The station where the cargo came from first
|
|
|
|
TileIndex source_xy; ///< The origin of the cargo (first station in feeder chain)
|
|
|
|
TileIndex loaded_at_xy; ///< Location where this cargo has been loaded into the vehicle
|
2007-06-22 11:58:59 +00:00
|
|
|
|
2009-10-06 17:23:15 +00:00
|
|
|
/** The CargoList caches, thus needs to know about it. */
|
2009-10-18 14:28:26 +00:00
|
|
|
template <class Tinst> friend class CargoList;
|
2009-10-18 13:39:00 +00:00
|
|
|
friend class VehicleCargoList;
|
|
|
|
friend class StationCargoList;
|
2009-10-06 17:23:15 +00:00
|
|
|
/** We want this to be saved, right? */
|
|
|
|
friend const struct SaveLoad *GetCargoPacketDesc();
|
|
|
|
public:
|
2009-10-06 17:28:06 +00:00
|
|
|
/** Maximum number of items in a single cargo packet. */
|
|
|
|
static const uint16 MAX_COUNT = UINT16_MAX;
|
2009-10-06 17:23:15 +00:00
|
|
|
|
2009-10-20 22:24:34 +00:00
|
|
|
/**
|
|
|
|
* Create a new packet for savegame loading.
|
|
|
|
*/
|
|
|
|
CargoPacket();
|
|
|
|
|
2007-06-22 11:58:59 +00:00
|
|
|
/**
|
|
|
|
* Creates a new cargo packet
|
2009-10-20 22:24:34 +00:00
|
|
|
* @param source the source station of the packet
|
|
|
|
* @param source_xy the source location of the packet
|
2009-10-06 17:23:15 +00:00
|
|
|
* @param count the number of cargo entities to put in this packet
|
2009-09-19 09:51:14 +00:00
|
|
|
* @param source_type the 'type' of source the packet comes from (for subsidies)
|
2009-10-06 17:23:15 +00:00
|
|
|
* @param source_id the actual source of the packet (for subsidies)
|
2009-10-20 22:24:34 +00:00
|
|
|
* @pre count != 0
|
2007-06-22 11:58:59 +00:00
|
|
|
*/
|
2009-10-20 22:24:34 +00:00
|
|
|
CargoPacket(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id);
|
2007-06-22 11:58:59 +00:00
|
|
|
|
2009-10-06 17:23:15 +00:00
|
|
|
/**
|
|
|
|
* Creates a new cargo packet. Initializes the fields that cannot be changed later.
|
|
|
|
* Used when loading or splitting packets.
|
|
|
|
* @param count the number of cargo entities to put in this packet
|
|
|
|
* @param days_in_transit number of days the cargo has been in transit
|
2009-10-18 17:52:44 +00:00
|
|
|
* @param source the station the cargo was initially loaded
|
|
|
|
* @param source_xy the station location the cargo was initially loaded
|
|
|
|
* @param loaded_at_xy the location the cargo was loaded last
|
2009-10-06 17:23:15 +00:00
|
|
|
* @param feeder_share feeder share the packet has already accumulated
|
|
|
|
* @param source_type the 'type' of source the packet comes from (for subsidies)
|
|
|
|
* @param source_id the actual source of the packet (for subsidies)
|
|
|
|
*/
|
2009-10-18 17:52:44 +00:00
|
|
|
CargoPacket(uint16 count, byte days_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share = 0, SourceType source_type = ST_INDUSTRY, SourceID source_id = INVALID_SOURCE);
|
2009-10-06 17:23:15 +00:00
|
|
|
|
2007-06-22 11:58:59 +00:00
|
|
|
/** Destroy the packet */
|
2009-05-22 15:13:50 +00:00
|
|
|
~CargoPacket() { }
|
2007-06-22 11:58:59 +00:00
|
|
|
|
2009-10-06 17:23:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the number of 'items' in this packet.
|
|
|
|
* @return the item count
|
|
|
|
*/
|
|
|
|
FORCEINLINE uint16 Count() const
|
|
|
|
{
|
|
|
|
return this->count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the amount of money already paid to earlier vehicles in
|
|
|
|
* the feeder chain.
|
|
|
|
* @return the feeder share
|
|
|
|
*/
|
|
|
|
FORCEINLINE Money FeederShare() const
|
|
|
|
{
|
|
|
|
return this->feeder_share;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the number of days this cargo has been in transit.
|
|
|
|
* This number isn't really in days, but in 2.5 days (185 ticks) and
|
|
|
|
* it is capped at 255.
|
|
|
|
* @return the length this cargo has been in transit
|
|
|
|
*/
|
|
|
|
FORCEINLINE byte DaysInTransit() const
|
|
|
|
{
|
|
|
|
return this->days_in_transit;
|
|
|
|
}
|
|
|
|
|
2009-10-18 17:53:34 +00:00
|
|
|
/**
|
|
|
|
* Gets the type of the cargo's source. industry, town or head quarter
|
|
|
|
* @return the source type
|
|
|
|
*/
|
|
|
|
FORCEINLINE SourceType SourceSubsidyType() const
|
|
|
|
{
|
|
|
|
return this->source_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the ID of the cargo's source. An IndustryID, TownID or CompanyID
|
|
|
|
* @return the source ID
|
|
|
|
*/
|
|
|
|
FORCEINLINE SourceID SourceSubsidyID() const
|
|
|
|
{
|
|
|
|
return this->source_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the ID of the station where the cargo was loaded for the first time
|
|
|
|
* @return the StationID
|
|
|
|
*/
|
|
|
|
FORCEINLINE SourceID SourceStation() const
|
|
|
|
{
|
|
|
|
return this->source;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the coordinates of the cargo's source station
|
|
|
|
* @return the source station's coordinates
|
|
|
|
*/
|
|
|
|
FORCEINLINE TileIndex SourceStationXY() const
|
|
|
|
{
|
|
|
|
return this->source_xy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the coordinates of the cargo's last loading station
|
|
|
|
* @return the last loading station's coordinates
|
|
|
|
*/
|
|
|
|
FORCEINLINE TileIndex LoadedAtXY() const
|
|
|
|
{
|
|
|
|
return this->loaded_at_xy;
|
|
|
|
}
|
|
|
|
|
2009-10-06 17:23:15 +00:00
|
|
|
|
2009-08-08 16:42:55 +00:00
|
|
|
static void InvalidateAllFrom(SourceType src_type, SourceID src);
|
2009-10-18 17:26:10 +00:00
|
|
|
static void InvalidateAllFrom(StationID sid);
|
2009-10-18 17:47:38 +00:00
|
|
|
static void AfterLoad();
|
2007-06-22 11:58:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iterate over all _valid_ cargo packets from the given start
|
2009-05-22 14:23:36 +00:00
|
|
|
* @param var the variable used as "iterator"
|
2007-06-22 11:58:59 +00:00
|
|
|
* @param start the cargo packet ID of the first packet to iterate over
|
|
|
|
*/
|
2009-05-22 14:23:36 +00:00
|
|
|
#define FOR_ALL_CARGOPACKETS_FROM(var, start) FOR_ALL_ITEMS_FROM(CargoPacket, cargopacket_index, var, start)
|
2007-06-22 11:58:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Iterate over all _valid_ cargo packets from the begin of the pool
|
2009-05-22 14:23:36 +00:00
|
|
|
* @param var the variable used as "iterator"
|
2007-06-22 11:58:59 +00:00
|
|
|
*/
|
2009-05-22 14:23:36 +00:00
|
|
|
#define FOR_ALL_CARGOPACKETS(var) FOR_ALL_CARGOPACKETS_FROM(var, 0)
|
2007-06-22 11:58:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple collection class for a list of cargo packets
|
2009-10-18 14:28:26 +00:00
|
|
|
* @tparam Tinst The actual instantation of this cargo list
|
2007-06-22 11:58:59 +00:00
|
|
|
*/
|
2009-10-18 14:28:26 +00:00
|
|
|
template <class Tinst>
|
2007-06-22 11:58:59 +00:00
|
|
|
class CargoList {
|
|
|
|
public:
|
2009-10-19 09:15:47 +00:00
|
|
|
/** Container with cargo packets */
|
2007-06-22 11:58:59 +00:00
|
|
|
typedef std::list<CargoPacket *> List;
|
2009-10-19 09:15:47 +00:00
|
|
|
/** The iterator for our container */
|
|
|
|
typedef List::iterator Iterator;
|
|
|
|
/** The const iterator for our container */
|
|
|
|
typedef List::const_iterator ConstIterator;
|
2007-06-22 11:58:59 +00:00
|
|
|
|
|
|
|
/** Kind of actions that could be done with packets on move */
|
|
|
|
enum MoveToAction {
|
|
|
|
MTA_FINAL_DELIVERY, ///< "Deliver" the packet to the final destination, i.e. destroy the packet
|
|
|
|
MTA_CARGO_LOAD, ///< Load the packet onto a vehicle, i.e. set the last loaded station ID
|
2009-06-29 19:55:36 +00:00
|
|
|
MTA_TRANSFER, ///< The cargo is moved as part of a transfer
|
|
|
|
MTA_UNLOAD, ///< The cargo is moved as part of a forced unload
|
2007-06-22 11:58:59 +00:00
|
|
|
};
|
|
|
|
|
2009-10-18 13:39:00 +00:00
|
|
|
protected:
|
2009-10-06 21:24:03 +00:00
|
|
|
uint count; ///< Cache for the number of cargo entities
|
|
|
|
uint cargo_days_in_transit; ///< Cache for the sum of number of days in transit of each entity; comparable to man-hours
|
2007-06-22 11:58:59 +00:00
|
|
|
|
2009-10-06 21:24:03 +00:00
|
|
|
List packets; ///< The cargo packets in this list
|
2009-10-06 21:19:20 +00:00
|
|
|
|
2009-10-07 08:25:12 +00:00
|
|
|
/**
|
|
|
|
* Update the cache to reflect adding of this packet.
|
2009-10-21 10:05:22 +00:00
|
|
|
* Increases count and days_in_transit
|
2009-10-07 08:25:12 +00:00
|
|
|
* @param cp a new packet to be inserted
|
|
|
|
*/
|
|
|
|
void AddToCache(const CargoPacket *cp);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the cached values to reflect the removal of this packet.
|
2009-10-21 10:05:22 +00:00
|
|
|
* Decreases count and days_in_transit
|
2009-10-07 08:25:12 +00:00
|
|
|
* @param cp Packet to be removed from cache
|
|
|
|
*/
|
|
|
|
void RemoveFromCache(const CargoPacket *cp);
|
|
|
|
|
2007-06-22 11:58:59 +00:00
|
|
|
public:
|
|
|
|
/** Create the cargo list */
|
2009-10-19 15:36:35 +00:00
|
|
|
CargoList() {}
|
2007-06-22 11:58:59 +00:00
|
|
|
/** And destroy it ("frees" all cargo packets) */
|
|
|
|
~CargoList();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a pointer to the cargo packet list (so you can iterate over it etc).
|
|
|
|
* @return pointer to the packet list
|
|
|
|
*/
|
2009-10-18 14:28:26 +00:00
|
|
|
FORCEINLINE const List *Packets() const
|
2009-10-06 19:52:27 +00:00
|
|
|
{
|
|
|
|
return &this->packets;
|
|
|
|
}
|
2007-06-22 11:58:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether this list is empty
|
|
|
|
* @return true if and only if the list is empty
|
|
|
|
*/
|
2009-10-06 19:52:27 +00:00
|
|
|
FORCEINLINE bool Empty() const
|
|
|
|
{
|
2009-10-06 21:12:35 +00:00
|
|
|
return this->count == 0;
|
2009-10-06 19:52:27 +00:00
|
|
|
}
|
2007-06-22 11:58:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of cargo entities in this list
|
|
|
|
* @return the before mentioned number
|
|
|
|
*/
|
2009-10-06 19:52:27 +00:00
|
|
|
FORCEINLINE uint Count() const
|
|
|
|
{
|
|
|
|
return this->count;
|
|
|
|
}
|
2007-06-22 11:58:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns source of the first cargo packet in this list
|
|
|
|
* @return the before mentioned source
|
|
|
|
*/
|
2009-10-06 19:52:27 +00:00
|
|
|
FORCEINLINE StationID Source() const
|
|
|
|
{
|
2009-10-06 21:12:35 +00:00
|
|
|
return this->Empty() ? INVALID_STATION : this->packets.front()->source;
|
2009-10-06 19:52:27 +00:00
|
|
|
}
|
2007-06-22 11:58:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns average number of days in transit for a cargo entity
|
|
|
|
* @return the before mentioned number
|
|
|
|
*/
|
2009-10-06 19:52:27 +00:00
|
|
|
FORCEINLINE uint DaysInTransit() const
|
|
|
|
{
|
2009-10-06 21:24:03 +00:00
|
|
|
return this->count == 0 ? 0 : this->cargo_days_in_transit / this->count;
|
2009-10-06 19:52:27 +00:00
|
|
|
}
|
2007-06-22 11:58:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends the given cargo packet
|
|
|
|
* @warning After appending this packet may not exist anymore!
|
|
|
|
* @note Do not use the cargo packet anymore after it has been appended to this CargoList!
|
|
|
|
* @param cp the cargo packet to add
|
|
|
|
* @pre cp != NULL
|
|
|
|
*/
|
|
|
|
void Append(CargoPacket *cp);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Truncates the cargo in this list to the given amount. It leaves the
|
|
|
|
* first count cargo entities and removes the rest.
|
2009-10-07 08:31:42 +00:00
|
|
|
* @param max_remaining the maximum amount of entities to be in the list after the command
|
2007-06-22 11:58:59 +00:00
|
|
|
*/
|
2009-10-07 08:31:42 +00:00
|
|
|
void Truncate(uint max_remaining);
|
2007-06-22 11:58:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves the given amount of cargo to another list.
|
|
|
|
* Depending on the value of mta the side effects of this function differ:
|
|
|
|
* - MTA_FINAL_DELIVERY: destroys the packets that do not originate from a specific station
|
|
|
|
* - MTA_CARGO_LOAD: sets the loaded_at_xy value of the moved packets
|
2009-06-29 19:55:36 +00:00
|
|
|
* - MTA_TRANSFER: just move without side effects
|
|
|
|
* - MTA_UNLOAD: just move without side effects
|
2007-06-22 11:58:59 +00:00
|
|
|
* @param dest the destination to move the cargo to
|
|
|
|
* @param count the amount of cargo entities to move
|
|
|
|
* @param mta how to handle the moving (side effects)
|
|
|
|
* @param data Depending on mta the data of this variable differs:
|
|
|
|
* - MTA_FINAL_DELIVERY - station ID of packet's origin not to remove
|
|
|
|
* - MTA_CARGO_LOAD - station's tile index of load
|
2009-06-29 19:55:36 +00:00
|
|
|
* - MTA_TRANSFER - unused
|
|
|
|
* - MTA_UNLOAD - unused
|
|
|
|
* @param payment The payment helper
|
|
|
|
*
|
|
|
|
* @pre mta == MTA_FINAL_DELIVERY || dest != NULL
|
|
|
|
* @pre mta == MTA_UNLOAD || mta == MTA_CARGO_LOAD || payment != NULL
|
2007-06-22 11:58:59 +00:00
|
|
|
* @return true if there are still packets that might be moved from this cargo list
|
|
|
|
*/
|
2009-10-18 14:28:26 +00:00
|
|
|
template <class Tother_inst>
|
2009-10-18 18:47:43 +00:00
|
|
|
bool MoveTo(Tother_inst *dest, uint count, MoveToAction mta, CargoPayment *payment, uint data = 0);
|
2007-06-22 11:58:59 +00:00
|
|
|
|
|
|
|
/** Invalidates the cached data and rebuild it */
|
|
|
|
void InvalidateCache();
|
|
|
|
};
|
|
|
|
|
2009-10-18 13:39:00 +00:00
|
|
|
/**
|
|
|
|
* CargoList that is used for vehicles.
|
|
|
|
*/
|
2009-10-18 14:28:26 +00:00
|
|
|
class VehicleCargoList : public CargoList<VehicleCargoList> {
|
2009-10-19 01:12:51 +00:00
|
|
|
protected:
|
|
|
|
/** The (direct) parent of this class */
|
|
|
|
typedef CargoList<VehicleCargoList> Parent;
|
|
|
|
|
|
|
|
Money feeder_share; ///< Cache for the feeder share
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the cache to reflect adding of this packet.
|
|
|
|
* Increases count, feeder share and days_in_transit
|
|
|
|
* @param cp a new packet to be inserted
|
|
|
|
*/
|
|
|
|
void AddToCache(const CargoPacket *cp);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the cached values to reflect the removal of this packet.
|
|
|
|
* Decreases count, feeder share and days_in_transit
|
|
|
|
* @param cp Packet to be removed from cache
|
|
|
|
*/
|
|
|
|
void RemoveFromCache(const CargoPacket *cp);
|
|
|
|
|
2009-10-18 13:39:00 +00:00
|
|
|
public:
|
2009-10-19 01:12:51 +00:00
|
|
|
/** The super class ought to know what it's doing */
|
|
|
|
friend class CargoList<VehicleCargoList>;
|
2009-10-18 13:39:00 +00:00
|
|
|
/** The vehicles have a cargo list (and we want that saved). */
|
|
|
|
friend const struct SaveLoad *GetVehicleDescription(VehicleType vt);
|
|
|
|
|
2009-10-19 01:12:51 +00:00
|
|
|
/**
|
|
|
|
* Returns total sum of the feeder share for all packets
|
|
|
|
* @return the before mentioned number
|
|
|
|
*/
|
|
|
|
FORCEINLINE Money FeederShare() const
|
|
|
|
{
|
|
|
|
return this->feeder_share;
|
|
|
|
}
|
|
|
|
|
2009-10-18 13:39:00 +00:00
|
|
|
/**
|
|
|
|
* Ages the all cargo in this list
|
|
|
|
*/
|
|
|
|
void AgeCargo();
|
2009-10-18 14:30:37 +00:00
|
|
|
|
2009-10-19 01:12:51 +00:00
|
|
|
/** Invalidates the cached data and rebuild it */
|
|
|
|
void InvalidateCache();
|
|
|
|
|
2009-10-18 14:30:37 +00:00
|
|
|
/**
|
|
|
|
* Are two the two CargoPackets mergeable in the context of
|
|
|
|
* a list of CargoPackets for a Vehicle?
|
|
|
|
* @param cp1 the first CargoPacket
|
|
|
|
* @param cp2 the second CargoPacket
|
|
|
|
* @return true if they are mergeable
|
|
|
|
*/
|
|
|
|
static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
|
|
|
|
{
|
|
|
|
return cp1->source_xy == cp2->source_xy &&
|
|
|
|
cp1->days_in_transit == cp2->days_in_transit &&
|
|
|
|
cp1->source_type == cp2->source_type &&
|
|
|
|
cp1->source_id == cp2->source_id &&
|
|
|
|
cp1->loaded_at_xy == cp2->loaded_at_xy;
|
|
|
|
}
|
2009-10-18 13:39:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CargoList that is used for stations.
|
|
|
|
*/
|
2009-10-18 14:28:26 +00:00
|
|
|
class StationCargoList : public CargoList<StationCargoList> {
|
2009-10-18 13:39:00 +00:00
|
|
|
public:
|
2009-10-19 01:12:51 +00:00
|
|
|
/** The super class ought to know what it's doing */
|
|
|
|
friend class CargoList<StationCargoList>;
|
2009-10-18 13:39:00 +00:00
|
|
|
/** The stations, via GoodsEntry, have a CargoList. */
|
|
|
|
friend const struct SaveLoad *GetGoodsDesc();
|
2009-10-18 14:30:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Are two the two CargoPackets mergeable in the context of
|
|
|
|
* a list of CargoPackets for a Vehicle?
|
|
|
|
* @param cp1 the first CargoPacket
|
|
|
|
* @param cp2 the second CargoPacket
|
|
|
|
* @return true if they are mergeable
|
|
|
|
*/
|
|
|
|
static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
|
|
|
|
{
|
|
|
|
return cp1->source_xy == cp2->source_xy &&
|
|
|
|
cp1->days_in_transit == cp2->days_in_transit &&
|
|
|
|
cp1->source_type == cp2->source_type &&
|
|
|
|
cp1->source_id == cp2->source_id;
|
|
|
|
}
|
2009-10-18 13:39:00 +00:00
|
|
|
};
|
|
|
|
|
2007-06-22 11:58:59 +00:00
|
|
|
#endif /* CARGOPACKET_H */
|