OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "../waypoint_base.h"
13 #include "../newgrf_station.h"
14 #include "../vehicle_base.h"
16 #include "../newgrf.h"
18 #include "table/strings.h"
22 #include "../safeguards.h"
52 if (!o->
IsType(OT_GOTO_WAYPOINT))
return;
74 if (wp.delete_ctr != 0)
continue;
77 _m[wp.xy].
m2 = (StationID)wp.index;
106 Debug(sl, 0,
"Found waypoint tile {} with invalid position", t);
107 for (t = 0; t <
MapSize(); t++) {
109 Debug(sl, 0,
"Found actual waypoint position at {}", t);
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;
137 if (wp.spec !=
nullptr) {
140 new_wp->
rect.BeforeAddTile(t, StationRect::ADD_FORCE);
142 wp.new_index = new_wp->
index;
147 if (ol->GetFirstSharedVehicle()->type !=
VEH_TRAIN)
continue;
161 void ResetOldWaypoints()
167 static const SaveLoad _old_waypoint_desc[] = {
209 wp.town_cn = (wp.string_id & 0xC000) == 0xC000 ? (wp.string_id >> 8) & 0x3F : 0;
236 extern const ChunkHandlerTable _waypoint_chunk_handlers(waypoint_chunk_handlers);
int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec)
Allocate a StationSpec to a Station.
StationFacility facilities
The facilities that this station has.
uint32 TileIndex
The index/ID of a Tile.
bool IsType(OrderType type) const
Check whether this order is of the given type.
static Titem * Get(size_t index)
Returns Titem with given index.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
@ SL_MIN_VERSION
First savegame version.
@ REF_TOWN
Load/save a reference to a town.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
Town * town
The town this station is associated with.
static void SetCustomStationSpecIndex(TileIndex t, byte specindex)
Set the custom station spec for this tile.
uint GetSpecCount() const
Get the number of allocated specs within the class.
DestinationID GetDestination() const
Gets the destination of this order.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
void MoveWaypointsToBaseStations()
Perform all steps to upgrade from the old waypoints to the new version that uses station.
static void SetRailStationReservation(TileIndex t, bool b)
Set the reservation state of the rail station.
uint16 town_cn
The N-1th waypoint for this town (consecutive number)
Tindex index
Index of this pool item.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Helper structure to convert from the old waypoint system.
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Representation of a waypoint.
uint16 m2
Primarily used for indices to towns, industries and stations.
Handlers and description of chunk.
Owner
Enum for all companies/owners.
Owner owner
The owner of this station.
StringID string_id
Default name (town area) of station.
static void MakeRailWaypoint(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
Make the given tile a rail waypoint tile.
static uint MapSize()
Get the size of the map.
@ STAT_CLASS_WAYP
Waypoint class.
A trimmed down version of what std::span will be in C++20.
@ CH_READONLY
Chunk is never saved.
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
static RailTileType GetRailTileType(TileIndex t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
void SetDestination(DestinationID destination)
Sets the destination of this order.
std::string CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
int32 Date
The type to store our dates in.
Struct containing information relating to NewGRF classes for stations and airports.
void FixPointers() const override
Fix the pointers.
static void UpdateWaypointOrder(Order *o)
Update the waypoint orders to get the new waypoint ID.
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
static std::vector< OldWaypoint > _old_waypoints
Temporary array with old waypoints.
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
std::string name
Custom name.
@ SLV_17
17.0 3212 17.1 3218
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
@ SL_MAX_VERSION
Highest possible saveload version.
void NORETURN SlError(StringID string, const char *extra_msg)
Error handler.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
@ FACIL_TRAIN
Station with train station.
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
byte delete_ctr
Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is ...
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Axis
Allow incrementing of DiagDirDiff variables.
uint16 local_id
id defined by the grf file for this entity
@ VEH_TRAIN
Train vehicle type.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
const struct GRFFile * grffile
grf file that introduced this entity
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
Date build_date
Date of construction.
Order * next
Pointer to next order. If nullptr, end of list.
void Load() const override
Load the chunk.
Tile * _m
Tiles of the map.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.