OpenTTD Source: src/saveload/station_sl.cpp File Reference

OpenTTD Source 15.0-beta1

Data Structures | Typedefs | Functions | Variables
station_sl.cpp File Reference

Code handling saving and loading of stations. More...

`#include "../stdafx.h"`
`#include "saveload.h"`
`#include "compat/station_sl_compat.h"`
`#include "../station_base.h"`
`#include "../waypoint_base.h"`
`#include "../roadstop_base.h"`
`#include "../vehicle_base.h"`
`#include "../newgrf_station.h"`
`#include "../newgrf_roadstop.h"`
`#include "../timer/timer_game_calendar.h"`
`#include "table/strings.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | FlowSaveLoad
class | SlStationSpecList< T >
class | SlStationCargo
class | SlStationFlow
class | SlStationGoods
struct | STNSChunkHandler
class | SlRoadStopTileData
class | SlStationBase
| SaveLoad handler for the BaseStation, which all other stations / waypoints make use of. More...
class | SlStationNormal
| SaveLoad handler for a normal station (read: not a waypoint). More...
class | SlStationWaypoint
struct | STNNChunkHandler
struct | ROADChunkHandler

## Typedefs
typedef std::pair< const StationID, std::list< CargoPacket * > > | StationCargoPair

## Functions
static void | UpdateWaypointOrder (Order *o)
| Update the buoy orders to be waypoint orders.
void | MoveBuoysToWaypoints ()
| Perform all steps to upgrade from the old station buoys to the new version that uses waypoints.
void | AfterLoadStations ()
void | AfterLoadRoadStops ()
| (Re)building of road stop caches after loading a savegame.
static void | SwapPackets (GoodsEntry *ge)
| Swap the temporary packets with the packets without specific destination in the given goods entry.
const ChunkHandlerTable | _station_chunk_handlers (station_chunk_handlers)

## Variables
static const SaveLoad | _roadstop_desc []
static uint16_t | _waiting_acceptance
static uint32_t | _old_num_flows
static uint16_t | _cargo_source
static uint32_t | _cargo_source_xy
static uint8_t | _cargo_periods
static Money | _cargo_feeder_share
std::list< CargoPacket * > | _packets
uint32_t | _old_num_dests
static OldPersistentStorage | _old_st_persistent_storage
static const SaveLoad | _old_station_desc []
static const SaveLoad | _station_desc []
static const STNSChunkHandler | STNS
static const STNNChunkHandler | STNN
static const ROADChunkHandler | ROAD
static const ChunkHandlerRef | station_chunk_handlers []

## Detailed Description

Code handling saving and loading of stations.

Definition in file station_sl.cpp.

## Typedef Documentation

## ◆ StationCargoPair

typedef std::pair<const StationID, std::list<CargoPacket *> > StationCargoPair

Definition at line 177 of file station_sl.cpp.

## Function Documentation

## ◆ AfterLoadRoadStops()

void AfterLoadRoadStops | ( |  | ) |

(Re)building of road stop caches after loading a savegame.

Definition at line 138 of file station_sl.cpp.

References DIAGDIR_NE, DIAGDIR_NW, HasBit(), IsDriveThroughStopTile(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_roadstop_pool >::Iterate(), and RoadStop::RSSFB_BASE_ENTRY.

Referenced by AfterLoadGame().

## ◆ AfterLoadStations()

void AfterLoadStations | ( |  | ) |

Definition at line 111 of file station_sl.cpp.

## ◆ MoveBuoysToWaypoints()

void MoveBuoysToWaypoints | ( |  | ) |

Perform all steps to upgrade from the old station buoys to the new version that uses waypoints.

This includes some old saveload mechanics.

Definition at line 45 of file station_sl.cpp.

References BaseStation::build_date, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_station_pool >::CanAllocateItem(), BaseStation::delete_ctr, FACIL_DOCK, FACIL_TRAIN, BaseStation::facilities, GetStationIndex(), GetTileOwner(), HVOT_WAYPOINT, INVALID_TILE, IsBuoyTile(), IsInsideBS(), IsTileType(), SpecializedStation< Station, false >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_orderlist_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Iterate(), Tile::m6(), MP_STATION, BaseStation::name, Town::name, Order::next, BaseStation::owner, OWNER_NONE, BaseStation::rect, SB(), BaseStation::string_id, BaseStation::town, Waypoint::town_cn, BaseStation::train_station, UpdateWaypointOrder(), VEH_SHIP, and VEH_TRAIN.

Referenced by AfterLoadGame().

## ◆ SwapPackets()

static void SwapPackets | ( | GoodsEntry * | ge | ) |
| static

Swap the temporary packets with the packets without specific destination in the given goods entry.

Assert that at least one of those is empty.

Parameters

  ge | Goods entry to swap with.

Definition at line 186 of file station_sl.cpp.

References GoodsEntry::cargo, and CargoList< Tinst, Tcont >::Packets().

## ◆ UpdateWaypointOrder()

static void UpdateWaypointOrder | ( | Order * | o | ) |
| static

Update the buoy orders to be waypoint orders.

Parameters

  o | the order 'list' to check.

Definition at line 31 of file station_sl.cpp.

References SpecializedStation< Station, false >::Get(), Order::GetDestination(), HVOT_WAYPOINT, Order::IsType(), and Order::MakeGoToWaypoint().

Referenced by MoveBuoysToWaypoints().

## Variable Documentation

## ◆ _cargo_feeder_share

Money _cargo_feeder_share
| static

Definition at line 164 of file station_sl.cpp.

## ◆ _cargo_periods

uint8_t _cargo_periods
| static

Definition at line 163 of file station_sl.cpp.

## ◆ _cargo_source

uint16_t _cargo_source
| static

Definition at line 161 of file station_sl.cpp.

## ◆ _cargo_source_xy

uint32_t _cargo_source_xy
| static

Definition at line 162 of file station_sl.cpp.

## ◆ _old_num_dests

uint32_t _old_num_dests

Definition at line 167 of file station_sl.cpp.

## ◆ _old_num_flows

uint32_t _old_num_flows
| static

Definition at line 160 of file station_sl.cpp.

## ◆ _old_st_persistent_storage

OldPersistentStorage _old_st_persistent_storage
| static

Definition at line 179 of file station_sl.cpp.

## ◆ _old_station_desc

const SaveLoad _old_station_desc[]
| static

Definition at line 428 of file station_sl.cpp.

## ◆ _packets

std::list<CargoPacket *> _packets

Definition at line 166 of file station_sl.cpp.

## ◆ _roadstop_desc

const SaveLoad _roadstop_desc[]
| static

Initial value:
= {
SLE_VAR(RoadStop, xy, SLE_UINT32),
SLE_VAR(RoadStop, status, SLE_UINT8),
SLE_REF(RoadStop, next, REF_ROADSTOPS),
}
SLE_REF
#define SLE_REF(base, variable, type)
Storage of a reference in every version of a savegame.
Definition saveload.h:1019
REF_ROADSTOPS
@ REF_ROADSTOPS
Load/save a reference to a bus/truck stop.
Definition saveload.h:606
SLE_VAR
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition saveload.h:1002
RoadStop
A Stop for a Road Vehicle.
Definition roadstop_base.h:22

Definition at line 153 of file station_sl.cpp.

## ◆ _station_desc

const SaveLoad _station_desc[]
| static

Initial value:
= {
SLE_SAVEBYTE(BaseStation, facilities),
SLEG_STRUCT("normal", SlStationNormal),
SLEG_STRUCT("waypoint", SlStationWaypoint),
SLEG_CONDSTRUCTLIST("speclist", SlStationSpecList<StationSpec>, SLV_27, SL_MAX_VERSION),
SLEG_CONDSTRUCTLIST("roadstopspeclist", SlStationSpecList<RoadStopSpec>, SLV_NEWGRF_ROAD_STOPS, SL_MAX_VERSION),
SLEG_CONDSTRUCTLIST("roadstoptiledata", SlRoadStopTileData, SLV_ROAD_STOP_TILE_DATA, SL_MAX_VERSION),
}
SlRoadStopTileData
Definition station_sl.cpp:507
SlStationNormal
SaveLoad handler for a normal station (read: not a waypoint).
Definition station_sl.cpp:561
SlStationSpecList
Definition station_sl.cpp:204
SlStationWaypoint
Definition station_sl.cpp:620
SLE_SAVEBYTE
#define SLE_SAVEBYTE(base, variable)
Only write byte during saving; never read it during loading.
Definition saveload.h:1083
SLEG_STRUCT
#define SLEG_STRUCT(name, handler)
Storage of a structs in every savegame version.
Definition saveload.h:1218
SL_MAX_VERSION
@ SL_MAX_VERSION
Highest possible saveload version.
Definition saveload.h:399
SLV_NEWGRF_ROAD_STOPS
@ SLV_NEWGRF_ROAD_STOPS
303 PR#10144 NewGRF road stops.
Definition saveload.h:343
SLV_27
@ SLV_27
27 4757
Definition saveload.h:75
SLV_ROAD_STOP_TILE_DATA
@ SLV_ROAD_STOP_TILE_DATA
340 PR#12883 Move storage of road stop tile data, also save for road waypoints.
Definition saveload.h:388
SLEG_CONDSTRUCTLIST
#define SLEG_CONDSTRUCTLIST(name, handler, from, to)
Storage of a list of structs in some savegame versions.
Definition saveload.h:1178
BaseStation
Base class for all station-ish types.
Definition base_station_base.h:59

Definition at line 655 of file station_sl.cpp.

## ◆ _waiting_acceptance

uint16_t _waiting_acceptance
| static

Definition at line 159 of file station_sl.cpp.

## ◆ ROAD

const ROADChunkHandler ROAD
| static

Definition at line 743 of file station_sl.cpp.

## ◆ station_chunk_handlers

const ChunkHandlerRef station_chunk_handlers[]
| static

Initial value:
= {
STNS,
STNN,
ROAD,
}

Definition at line 744 of file station_sl.cpp.

## ◆ STNN

const STNNChunkHandler STNN
| static

Definition at line 742 of file station_sl.cpp.

## ◆ STNS

const STNSChunkHandler STNS
| static

Definition at line 741 of file station_sl.cpp.