20#include "table/strings.h"
24using OldWaypointID = uint16_t;
36 TimerGameCalendar::Date build_date;
54 if (!o.
IsType(OT_GOTO_WAYPOINT))
return;
76 if (wp.delete_ctr != 0)
continue;
92 if (found != std::end(specs)) wp.spec = *found;
104 Debug(sl, 0,
"Found waypoint tile {} with invalid position", t);
109 Debug(sl, 0,
"Found actual waypoint position at {}",
TileIndex(tile));
119 new_wp->
town = wp.town;
121 new_wp->
name = wp.name;
124 new_wp->
owner = wp.owner;
125 new_wp->
string_id = STR_SV_STNAME_WAYPOINT;
138 if (wp.spec !=
nullptr) {
143 new_wp->
rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
145 wp.new_index = new_wp->index;
150 if (ol->GetFirstSharedVehicle()->type !=
VEH_TRAIN)
continue;
164void ResetOldWaypoints()
170static const SaveLoad _old_waypoint_desc[] = {
188struct CHKPChunkHandler : ChunkHandler {
189 CHKPChunkHandler() : ChunkHandler(
'CHKP',
CH_READONLY) {}
201 wp->index =
static_cast<OldWaypointID
>(index);
212 wp.town_cn = (wp.string_id & 0xC000) == 0xC000 ? (wp.string_id >> 8) & 0x3F : 0;
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr Timpl & Set()
Set all bits.
std::span< Tspec *const > Specs() const
Get read-only span of specs of this class.
static NewGRFClass * Get(StationClassID class_index)
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
Wrapper class to abstract away the way the tiles are stored.
uint8_t & m5()
General purpose.
uint8_t & m4()
General purpose.
uint8_t & m3()
General purpose.
uint16_t & m2()
Primarily used for indices to towns, industries and stations.
Functions related to debugging.
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Axis
Allow incrementing of DiagDirDiff variables.
Base for the NewGRF implementation.
void AssignSpecToStation(const StationSpec *spec, BaseStation *st, uint8_t specindex)
Assign a previously allocated StationSpec specindex to a Station.
std::optional< uint8_t > AllocateSpecToStation(const StationSpec *spec, BaseStation *st)
Allocate a StationSpec to a Station.
Header file for NewGRF stations.
@ STAT_CLASS_WAYP
Waypoint class.
static RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
RailTileType
Different types of Rail-related tiles.
A number of safeguards to prevent using unsafe methods.
void SlError(StringID string, const std::string &extra_msg)
Error handler.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
@ REF_TOWN
Load/save a reference to a town.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
#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.
@ SLV_17
17.0 3212 17.1 3218
@ SL_MAX_VERSION
Highest possible saveload version.
@ SL_MIN_VERSION
First savegame version.
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
@ CH_READONLY
Chunk is never saved.
#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.
std::string CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
void SetCustomStationSpecIndex(Tile t, uint8_t specindex)
Set the custom station spec for this tile.
void SetRailStationReservation(Tile t, bool b)
Set the reservation state of the rail station.
void MakeRailWaypoint(Tile t, Owner o, StationID sid, Axis a, uint8_t section, RailType rt)
Make the given tile a rail waypoint tile.
@ Train
Station with train station.
Definition of base types and functions in a cross-platform compatible way.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
StringID string_id
Default name (town area) of station.
StationFacilities facilities
The facilities that this station has.
Owner owner
The owner of this station.
uint8_t delete_ctr
Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is ...
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
Town * town
The town this station is associated with.
TimerGameCalendar::Date build_date
Date of construction.
std::string name
Custom name.
void Load() const override
Load the chunk.
void FixPointers() const override
Fix the pointers.
uint16_t local_id
id defined by the grf file for this entity
uint32_t grfid
grfid that introduced this entity.
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
Helper structure to convert from the old waypoint system.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
DestinationID GetDestination() const
Gets the destination of this order.
bool IsType(OrderType type) const
Check whether this order is of the given type.
void SetDestination(DestinationID destination)
Sets the destination of this order.
static Pool::IterateWrapper< OrderList > Iterate(size_t from=0)
static Town * Get(auto index)
static bool CanAllocateItem(size_t n=1)
static bool IsValidID(auto index)
static Waypoint * Create(Targs &&... args)
CargoGRFFileProps grf_prop
Link to NewGRF.
Representation of a waypoint.
uint16_t town_cn
The N-1th waypoint for this town (consecutive number).
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ Railway
A tile with railway.
Definition of the game-calendar-timer.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
Base class for all vehicles.
@ VEH_TRAIN
Train vehicle type.
static void UpdateWaypointOrder(Order &o)
Update the waypoint orders to get the new waypoint ID.
static std::vector< OldWaypoint > _old_waypoints
Temporary array with old waypoints.
void MoveWaypointsToBaseStations()
Perform all steps to upgrade from the old waypoints to the new version that uses station.