OpenTTD Source
20240919-master-gdf0233f4c2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
15 #include "../vehicle_base.h"
16 #include "../station_base.h"
18 #include "../safeguards.h"
33 const CargoPacketList *packets = v->cargo.Packets();
96 for (
auto it = v->cargo.Packets()->begin(); it != v->cargo.Packets()->end(); it++) {
98 (*it)->UpdateLoadingTile((*it)->source_xy);
107 for (
auto it = v->cargo.Packets()->begin(); it != v->cargo.Packets()->end(); it++) {
108 (*it)->in_vehicle =
true;
121 static const SaveLoad _cargopacket_desc[] = {
136 return _cargopacket_desc;
147 SlSetArrayIndex(cp->index);
170 extern const ChunkHandlerTable _cargopacket_chunk_handlers(cargopacket_chunk_handlers);
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
CargoPacketList ::const_iterator ConstIterator
The const iterator for our container.
std::span< const struct SaveLoad > SaveLoadTable
A table of SaveLoad entries.
Vector travelled
If cargo is in station: the vector from the unload tile to the source tile. If in vehicle: an interme...
@ SLV_REMOVE_LOADED_AT_XY
318 PR#11276 Remove loaded_at_xy variable from CargoPacket.
const Tcont * Packets() const
Returns a pointer to the cargo packet list (so you can iterate over it etc).
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
#define SLE_CONDVARNAME(base, variable, name, type, from, to)
Storage of a variable in some savegame versions.
@ SL_MIN_VERSION
First savegame version.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
static Station * Get(size_t index)
Gets station with given index.
static bool IsValidID(size_t index)
Tests whether given index is a valid index for station of this type.
Handlers and description of chunk.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
StationID first_station
The station where the cargo came from first.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
TileIndex source_xy
The origin of the cargo.
SaveLoadTable GetCargoPacketDesc()
Wrapper function to get the CargoPacket's internal structure while some of the variables itself are p...
void InvalidateCache()
Invalidates the cached data and rebuilds it.
@ SLV_PERIODS_IN_TRANSIT_RENAME
316 PR#11112 Rename days in transit to (cargo) periods in transit.
@ SL_MAX_VERSION
Highest possible saveload version.
void Save() const override
Save the chunk.
static void AfterLoad()
Savegame conversion for cargopackets.
Stores station stats for a single cargo.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
void Load() const override
Load the chunk.
@ SLV_CARGO_TRAVELLED
319 PR#11283 CargoPacket now tracks how far it travelled inside a vehicle.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
TileIndex xy
Base tile of the station.
Container for cargo from the same location and time.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
@ SLV_MORE_CARGO_AGE
307 PR#10596 Track cargo age for a longer period.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
Hand-rolled multimap as map of lists.
#define SLE_VARNAME(base, variable, name, type)
Storage of a variable in every version of a savegame.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
const SaveLoadCompat _cargopacket_sl_compat[]
Original field order for _cargopacket_desc.