|
OpenTTD Source
14.0-beta3
|
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"
17 #include "../timer/timer_game_calendar.h"
19 #include "table/strings.h"
23 #include "../safeguards.h"
53 if (!o->
IsType(OT_GOTO_WAYPOINT))
return;
75 if (wp.delete_ctr != 0)
continue;
79 tile.
m2() = (StationID)wp.index;
108 Debug(sl, 0,
"Found waypoint tile {} with invalid position", t);
111 Debug(sl, 0,
"Found actual waypoint position at {}", t);
121 new_wp->
town = wp.town;
123 new_wp->
name = wp.name;
126 new_wp->
owner = wp.owner;
127 new_wp->
string_id = STR_SV_STNAME_WAYPOINT;
140 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;
164 void ResetOldWaypoints()
170 static const SaveLoad _old_waypoint_desc[] = {
212 wp.town_cn = (wp.string_id & 0xC000) == 0xC000 ? (wp.string_id >> 8) & 0x3F : 0;
239 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.
void MakeRailWaypoint(Tile t, Owner o, StationID sid, Axis a, byte section, RailType rt)
Make the given tile a rail waypoint 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.
@ 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.
Axis
Allow incrementing of DiagDirDiff variables.
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.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
@ SL_MIN_VERSION
First savegame version.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
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.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
uint16_t town_cn
The N-1th waypoint for this town (consecutive number)
Representation of a waypoint.
Wrapper class to abstract away the way the tiles are stored.
debug_inline byte & m5()
General purpose.
Handlers and description of chunk.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
Owner
Enum for all companies/owners.
Owner owner
The owner of this station.
debug_inline byte & m4()
General purpose.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
StringID string_id
Default name (town area) of station.
void SetCustomStationSpecIndex(Tile t, byte specindex)
Set the custom station spec for this tile.
debug_inline uint16_t & m2()
Primarily used for indices to towns, industries and stations.
@ STAT_CLASS_WAYP
Waypoint class.
@ CH_READONLY
Chunk is never saved.
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
void SetDestination(DestinationID destination)
Sets the destination of this order.
std::string CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
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.
std::string name
Custom name.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
@ SL_MAX_VERSION
Highest possible saveload version.
static debug_inline RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
void SetRailStationReservation(Tile t, bool b)
Set the reservation state of the rail station.
uint16_t local_id
id defined by the grf file for this entity
#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.
static debug_inline uint Size()
Get the size of the map.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
byte delete_ctr
Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is ...
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
void SlError(StringID string, const std::string &extra_msg)
Error handler.
@ SLV_17
17.0 3212 17.1 3218
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
@ 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.
debug_inline byte & m3()
General purpose.
Order * next
Pointer to next order. If nullptr, end of list.
void Load() const override
Load the chunk.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
TimerGameCalendar::Date build_date
Date of construction.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.