15#include "../vehicle_base.h"
16#include "../station_base.h"
18#include "../safeguards.h"
33 const CargoPacketList *packets = v->cargo.Packets();
70 for (
GoodsEntry &ge : st->goods) ge.cargo.InvalidateCache();
83 for (
auto it = ge.cargo.Packets()->begin(); it != ge.cargo.Packets()->end(); ++it) {
85 if (cp->source_xy !=
INVALID_TILE && cp->source_xy != st->xy) {
86 cp->travelled.x =
TileX(cp->source_xy) -
TileX(st->xy);
87 cp->travelled.y =
TileY(cp->source_xy) -
TileY(st->xy);
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);
170extern const ChunkHandlerTable _cargopacket_chunk_handlers(cargopacket_chunk_handlers);
SaveLoadTable GetCargoPacketDesc()
Wrapper function to get the CargoPacket's internal structure while some of the variables itself are p...
Loading for cargopacket chunks before table headers were added.
const SaveLoadCompat _cargopacket_sl_compat[]
Original field order for _cargopacket_desc.
Tcont::const_iterator ConstIterator
The const iterator for our container.
Hand-rolled multimap as map of lists.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
Functions/types related to saving and loading games.
#define SLE_VARNAME(base, variable, name, type)
Storage of a variable in every version of a savegame.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
@ SL_MAX_VERSION
Highest possible saveload version.
@ SL_MIN_VERSION
First savegame version.
@ SLV_CARGO_TRAVELLED
319 PR#11283 CargoPacket now tracks how far it travelled inside a vehicle.
@ SLV_PERIODS_IN_TRANSIT_RENAME
316 PR#11112 Rename days in transit to (cargo) periods in transit.
@ SLV_MORE_CARGO_AGE
307 PR#10596 Track cargo age for a longer period.
@ SLV_REMOVE_LOADED_AT_XY
318 PR#11276 Remove loaded_at_xy variable from CargoPacket.
std::span< const struct SaveLoad > SaveLoadTable
A table of SaveLoad entries.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
#define SLE_CONDVARNAME(base, variable, name, type, from, to)
Storage of a variable in some savegame versions.
TileIndex xy
Base tile of the station.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
Container for cargo from the same location and time.
TileIndex source_xy
The origin of the cargo.
static void AfterLoad()
Savegame conversion for cargopackets.
StationID first_station
The station where the cargo came from first.
Handlers and description of chunk.
Stores station stats for a single cargo.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
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.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.