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

OpenTTD Source 1.11.0-RC1

Data Structures | Typedefs | Functions | Variables
station_sl.cpp File Reference
`#include "../stdafx.h"`
`#include "../station_base.h"`
`#include "../waypoint_base.h"`
`#include "../roadstop_base.h"`
`#include "../vehicle_base.h"`
`#include "../newgrf_station.h"`
`#include "saveload.h"`
`#include "table/strings.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | FlowSaveLoad

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

## Functions
static void | UpdateWaypointOrder (Order *o)
| Update the buoy orders to be waypoint orders. More...
void | MoveBuoysToWaypoints ()
| Perform all steps to upgrade from the old station buoys to the new version that uses waypoints. More...
void | AfterLoadStations ()
void | AfterLoadRoadStops ()
| (Re)building of road stop caches after loading a savegame.
const SaveLoad * | GetGoodsDesc ()
| Wrapper function to get the GoodsEntry's internal structure while some of the variables itself are private. More...
static void | SwapPackets (GoodsEntry *ge)
| Swap the temporary packets with the packets without specific destination in the given goods entry. More...
static void | Load_STNS ()
static void | Ptrs_STNS ()
const SaveLoad * | GetBaseStationDescription ()
| Get the base station description to be used for SL_ST_INCLUDE. More...
static void | RealSave_STNN (BaseStation *bst)
static void | Save_STNN ()
static void | Load_STNN ()
static void | Ptrs_STNN ()
static void | Save_ROADSTOP ()
static void | Load_ROADSTOP ()
static void | Ptrs_ROADSTOP ()

## Variables
static const SaveLoad | _roadstop_desc []
static const SaveLoad | _old_station_desc []
static uint16 | _waiting_acceptance
static uint32 | _num_flows
static uint16 | _cargo_source
static uint32 | _cargo_source_xy
static uint8 | _cargo_days
static Money | _cargo_feeder_share
static const SaveLoad | _station_speclist_desc []
std::list< CargoPacket * > | _packets
uint32 | _num_dests
static const SaveLoad | _flow_desc []
static const SaveLoad | _cargo_list_desc []
static const SaveLoad | _base_station_desc []
static OldPersistentStorage | _old_st_persistent_storage
static const SaveLoad | _station_desc []
static const SaveLoad | _waypoint_desc []
const ChunkHandler | _station_chunk_handlers []

## Detailed Description

Code handling saving and loading of stations.

Definition in file station_sl.cpp.

## Function Documentation

## ◆ GetBaseStationDescription()

const SaveLoad* GetBaseStationDescription | ( |  | ) |

Get the base station description to be used for SL_ST_INCLUDE.

Returns
  the base station description.

Definition at line 464 of file station_sl.cpp.

## ◆ GetGoodsDesc()

const SaveLoad* GetGoodsDesc | ( |  | ) |

Wrapper function to get the GoodsEntry's internal structure while some of the variables itself are private.

The stations, via GoodsEntry, have a CargoList.

Returns
  the saveload description for GoodsEntry.

Definition at line 258 of file station_sl.cpp.

References SLEG_CONDVAR.

## ◆ 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 40 of file station_sl.cpp.

References _me, BaseStation::build_date, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_station_pool >::CanAllocateItem(), BaseStation::delete_ctr, GetStationIndex(), GetTileOwner(), HVOT_WAYPOINT, INVALID_TILE, 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(), MP_STATION, BaseStation::name, Town::name, Order::next, BaseStation::owner, OWNER_NONE, SB(), BaseStation::string_id, TILE_AREA_LOOP, BaseStation::town, Waypoint::town_cn, UpdateWaypointOrder(), VEH_SHIP, and VEH_TRAIN.

## ◆ 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 301 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 26 of file station_sl.cpp.

References Order::IsType().

Referenced by MoveBuoysToWaypoints().

## Variable Documentation

## ◆ _base_station_desc

const SaveLoad _base_station_desc[]
| static

Initial value:
= {
SLE_VAR(BaseStation, xy, SLE_UINT32),
SLE_REF(BaseStation, town, REF_TOWN),
SLE_VAR(BaseStation, string_id, SLE_STRINGID),
SLE_SSTR(BaseStation, name, SLE_STR | SLF_ALLOW_CONTROL),
SLE_VAR(BaseStation, delete_ctr, SLE_UINT8),
SLE_VAR(BaseStation, owner, SLE_UINT8),
SLE_VAR(BaseStation, facilities, SLE_UINT8),
SLE_VAR(BaseStation, build_date, SLE_INT32),
SLE_VAR(BaseStation, random_bits, SLE_UINT16),
SLE_VAR(BaseStation, waiting_triggers, SLE_UINT8),
SLE_VAR(BaseStation, num_specs, SLE_UINT8),
}

Definition at line 387 of file station_sl.cpp.

## ◆ _cargo_list_desc

const SaveLoad _cargo_list_desc[]
| static

Initial value:
= {
SLE_VAR(StationCargoPair, first, SLE_UINT16),
SLE_LST(StationCargoPair, second, REF_CARGO_PACKET),
}

Definition at line 290 of file station_sl.cpp.

## ◆ _flow_desc

const SaveLoad _flow_desc[]
| static

Initial value:
= {
SLE_VAR(FlowSaveLoad, source, SLE_UINT16),
SLE_VAR(FlowSaveLoad, via, SLE_UINT16),
SLE_VAR(FlowSaveLoad, share, SLE_UINT32),
SLE_CONDVAR(FlowSaveLoad, restricted, SLE_BOOL, SLV_187, SL_MAX_VERSION),
}

Definition at line 245 of file station_sl.cpp.

## ◆ _roadstop_desc

const SaveLoad _roadstop_desc[]
| static

Initial value:
= {
SLE_VAR(RoadStop, xy, SLE_UINT32),
SLE_CONDNULL(1, SL_MIN_VERSION, SLV_45),
SLE_VAR(RoadStop, status, SLE_UINT8),
SLE_CONDNULL(4, SL_MIN_VERSION, SLV_9),
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_45),
SLE_CONDNULL(1, SL_MIN_VERSION, SLV_26),
SLE_REF(RoadStop, next, REF_ROADSTOPS),
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_45),
SLE_CONDNULL(4, SL_MIN_VERSION, SLV_25),
SLE_CONDNULL(1, SLV_25, SLV_26),
}

Definition at line 143 of file station_sl.cpp.

## ◆ _station_chunk_handlers

const ChunkHandler _station_chunk_handlers[]

Initial value:
= {
{ 'STNS', nullptr, Load_STNS, Ptrs_STNS, nullptr, CH_ARRAY },
{ 'STNN', Save_STNN, Load_STNN, Ptrs_STNN, nullptr, CH_ARRAY },
{ 'ROAD', Save_ROADSTOP, Load_ROADSTOP, Ptrs_ROADSTOP, nullptr, CH_ARRAY | CH_LAST},
}

## ◆ _station_speclist_desc

const SaveLoad _station_speclist_desc[]
| static

Initial value:
= {
SLE_CONDVAR(StationSpecList, grfid, SLE_UINT32, SLV_27, SL_MAX_VERSION),
SLE_CONDVAR(StationSpecList, localidx, SLE_UINT8, SLV_27, SL_MAX_VERSION),
}

Definition at line 227 of file station_sl.cpp.

## ◆ _waypoint_desc

const SaveLoad _waypoint_desc[]
| static

Initial value:
= {
SLE_WRITEBYTE(Waypoint, facilities),
SLE_ST_INCLUDE(),
SLE_VAR(Waypoint, town_cn, SLE_UINT16),
SLE_CONDVAR(Waypoint, train_station.tile, SLE_UINT32, SLV_124, SL_MAX_VERSION),
SLE_CONDVAR(Waypoint, train_station.w, SLE_FILE_U8 | SLE_VAR_U16, SLV_124, SL_MAX_VERSION),
SLE_CONDVAR(Waypoint, train_station.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_124, SL_MAX_VERSION),
}

Definition at line 447 of file station_sl.cpp.

SLV_187
@ SLV_187
187 25899 Linkgraph - restricted flows
Definition: saveload.h:267
SL_MIN_VERSION
@ SL_MIN_VERSION
First savegame version.
Definition: saveload.h:31
REF_TOWN
@ REF_TOWN
Load/save a reference to a town.
Definition: saveload.h:393
REF_ROADSTOPS
@ REF_ROADSTOPS
Load/save a reference to a bus/truck stop.
Definition: saveload.h:395
SLV_124
@ SLV_124
124 16993
Definition: saveload.h:191
StationSpecList
Definition: base_station_base.h:21
SLE_CONDVAR
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition: saveload.h:551
SLE_STR
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
Definition: saveload.h:647
Waypoint
Representation of a waypoint.
Definition: waypoint_base.h:16
CH_LAST
@ CH_LAST
Last chunk in this array.
Definition: saveload.h:410
Window::owner
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
Definition: window_gui.h:324
SLE_WRITEBYTE
#define SLE_WRITEBYTE(base, variable)
Translate values ingame to different values in the savegame and vv.
Definition: saveload.h:680
SLE_CONDNULL
#define SLE_CONDNULL(length, from, to)
Empty space in some savegame versions.
Definition: saveload.h:677
SLE_REF
#define SLE_REF(base, variable, type)
Storage of a reference in every version of a savegame.
Definition: saveload.h:629
SLF_ALLOW_CONTROL
@ SLF_ALLOW_CONTROL
allow control codes in the strings
Definition: saveload.h:489
SLV_27
@ SLV_27
27 4757
Definition: saveload.h:75
SLV_45
@ SLV_45
45 8501
Definition: saveload.h:97
SLE_LST
#define SLE_LST(base, variable, type)
Storage of a list in every savegame version.
Definition: saveload.h:663
REF_CARGO_PACKET
@ REF_CARGO_PACKET
Load/save a reference to a cargo packet.
Definition: saveload.h:397
SLV_25
@ SLV_25
25 4259
Definition: saveload.h:73
SL_MAX_VERSION
@ SL_MAX_VERSION
Highest possible saveload version.
Definition: saveload.h:328
SLE_VAR
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition: saveload.h:621
BaseStation
Base class for all station-ish types.
Definition: base_station_base.h:52
SLE_SSTR
#define SLE_SSTR(base, variable, type)
Storage of a std::string in every savegame version.
Definition: saveload.h:655
RoadStop
A Stop for a Road Vehicle.
Definition: roadstop_base.h:22
SLV_26
@ SLV_26
26 4466
Definition: saveload.h:74
SLV_9
@ SLV_9
9.0 1909
Definition: saveload.h:50
FlowSaveLoad
Definition: station_sl.cpp:237