18#include "../station_map.h"
19#include "../tunnelbridge_map.h"
21#include "../safeguards.h"
30static std::vector<LabelObject<RailTypeLabel>> _railtype_list;
31static std::vector<LabelObject<RoadTypeLabel>> _roadtype_list;
39 std::vector<RailType> railtype_conversion_map;
40 bool needs_conversion =
false;
42 for (
auto it = std::begin(_railtype_list); it != std::end(_railtype_list); ++it) {
48 railtype_conversion_map.push_back(rt);
51 if (it->label != 0 && rt != std::distance(std::begin(_railtype_list), it)) needs_conversion =
true;
53 if (!needs_conversion)
return;
91 std::vector<RoadType> roadtype_conversion_map;
92 bool needs_conversion =
false;
93 for (
auto it = std::begin(_roadtype_list); it != std::end(_roadtype_list); ++it) {
99 roadtype_conversion_map.push_back(rt);
102 if (it->label != 0 && rt != std::distance(std::begin(_roadtype_list), it)) needs_conversion =
true;
104 if (!needs_conversion)
return;
136 _railtype_list.clear();
141 _roadtype_list.clear();
158 _railtype_list.clear();
159 _roadtype_list.clear();
165 static inline const SaveLoad description[] = {
192 _railtype_list.push_back(lo);
200 static inline const SaveLoad description[] = {
213 lo.
subtype = GetRoadTramType(r);
230 _roadtype_list.push_back(lo);
243extern const ChunkHandlerTable _labelmaps_chunk_handlers(labelmaps_chunk_handlers);
RailTypeLabel label
Unique 32 bit rail type identifier.
RoadTypeLabel label
Unique 32 bit road type identifier.
static void SetCurrentLabelLists()
Populate label lists with current values.
static void ConvertRoadTypes()
Test if any saved road type labels are different to the currently loaded road types.
static void ConvertRailTypes()
Test if any saved rail type labels are different to the currently loaded rail types.
void AfterLoadLabelMaps()
Perform rail type and road type conversion if necessary.
Loading of labelmaps chunks before table headers were added.
const SaveLoadCompat _label_object_sl_compat[]
Original field order for _label_object_desc.
RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels)
Get the rail type for a given label.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
void SetRailType(Tile t, RailType r)
Sets the rail type of the given tile.
RailType
Enumeration for all possible railtypes.
@ RAILTYPE_BEGIN
Used for iterations.
@ RAILTYPE_END
Used for iterations.
@ INVALID_RAILTYPE
Flag for invalid railtype.
@ RAILTYPE_RAIL
Standard non-electric rails.
RoadType GetRoadTypeByLabel(RoadTypeLabel label, bool allow_alternate_labels)
Get the road type for a given label.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
void SetRoadTypeRoad(Tile t, RoadType rt)
Set the road road type of a tile.
void SetRoadTypeTram(Tile t, RoadType rt)
Set the tram road type of a tile.
bool IsLevelCrossing(Tile t)
Return whether a tile is a level crossing.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
@ ROADTYPE_ROAD
Basic road type.
@ ROADTYPE_END
Used for iterations.
@ ROADTYPE_BEGIN
Used for iterations.
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.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Declaration of functions used in more save/load files.
bool IsRoadWaypoint(Tile t)
Is the station at t a road waypoint?
bool IsStationRoadStop(Tile t)
Is the station at t a road station?
bool HasStationRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
Handlers and description of chunk.
Container for a label for rail or road type conversion.
uint8_t subtype
Subtype of type (road or tram).
T label
Label of rail or road type.
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
@ MP_ROAD
A tile with road (or tram tracks)
@ MP_STATION
A tile of a station.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
@ TRANSPORT_RAIL
Transport by train.
@ TRANSPORT_ROAD
Transport by road vehicle.
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...