12 #include "../stdafx.h" 13 #include "../waypoint_base.h" 14 #include "../newgrf_station.h" 15 #include "../vehicle_base.h" 17 #include "../newgrf.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;
78 _m[wp->xy].
m2 = (StationID)wp->index;
104 new_wp->
town = wp->town;
106 new_wp->
name = wp->name;
109 new_wp->
owner = wp->owner;
111 new_wp->
string_id = STR_SV_STNAME_WAYPOINT;
125 if (wp->spec != NULL) {
128 new_wp->
rect.BeforeAddTile(t, StationRect::ADD_FORCE);
131 wp->new_index = new_wp->
index;
136 FOR_ALL_ORDER_LISTS(ol) {
149 _old_waypoints.
Reset();
152 static const SaveLoad _old_waypoint_desc[] = {
172 static void Load_WAYP()
175 _old_waypoints.
Clear();
181 memset(wp, 0,
sizeof(*wp));
188 static void Ptrs_WAYP()
194 wp->town_cn = (wp->string_id & 0xC000) == 0xC000 ? (wp->string_id >> 8) & 0x3F : 0;
204 _old_waypoints.
Clear();
215 extern const ChunkHandler _waypoint_chunk_handlers[] = {
216 {
'CHKP', NULL, Load_WAYP, Ptrs_WAYP, NULL, CH_ARRAY |
CH_LAST},
static void SetCustomStationSpecIndex(TileIndex t, byte specindex)
Set the custom station spec for this tile.
uint16 town_cn
The N-1th waypoint for this town (consecutive number)
static void UpdateWaypointOrder(Order *o)
Update the waypoint orders to get the new waypoint ID.
#define SLE_CONDSTR(base, variable, type, length, from, to)
Storage of a string in some savegame versions.
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
static Titem * Get(size_t index)
Returns Titem with given index.
uint GetSpecCount() const
Get the number of allocated specs within the class.
void Reset()
Remove all items from the list and free allocated memory.
uint16 m2
Primarily used for indices to towns, industries and stations.
Tile * _m
Tiles of the map.
void NORETURN SlError(StringID string, const char *extra_msg)
Error handler.
char * CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
void Clear()
Remove all items from the list.
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
const T * Begin() const
Get the pointer to the first item (const)
Tindex index
Index of this pool item.
Load/save a reference to a town.
Representation of a waypoint.
static void SetRailStationReservation(TileIndex t, bool b)
Set the reservation state of the rail station.
Simple vector template class.
Town * town
The town this station is associated with.
Vehicle * GetFirstSharedVehicle() const
Get the first vehicle of this vehicle chain.
const T * End() const
Get the pointer behind the last valid item (const)
Helper structure to convert from the old waypoint system.
T * Append(uint to_add=1)
Append an item and return it.
byte delete_ctr
Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is ...
Order * next
Pointer to next order. If NULL, end of list.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold...
Struct containing information relating to NewGRF classes for stations and airports.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a give tiletype.
uint Length() const
Get the number of items in the list.
static void MakeRailWaypoint(TileIndex 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 Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec)
Allocate a StationSpec to a Station.
Order * GetFirstOrder() const
Get the first order of the order chain.
StationFacilityByte facilities
The facilities that this station has.
void MoveWaypointsToBaseStations()
Perform all steps to upgrade from the old waypoints to the new version that uses station.
#define SL_MAX_VERSION
Highest possible savegame version.
static bool IsSavegameVersionBefore(uint16 major, byte minor=0)
Checks whether the savegame is below major.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Handlers and description of chunk.
static RailTileType GetRailTileType(TileIndex t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
OwnerByte owner
The owner of this station.
#define SLE_END()
End marker of a struct/class save or load.
DestinationID GetDestination() const
Gets the destination of this order.
uint32 TileIndex
The index/ID of a Tile.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
void SlObject(void *object, const SaveLoad *sld)
Main SaveLoad function.
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Station with train station.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
static SmallVector< OldWaypoint, 16 > _old_waypoints
Temporary array with old waypoints.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
uint16 local_id
id defined by the grf file for this entity
void SetDestination(DestinationID destination)
Sets the destination of this order.
int32 Date
The type to store our dates in.
const struct GRFFile * grffile
grf file that introduced this entity
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
#define FOR_ALL_VEHICLES(var)
Iterate over all vehicles.
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
StringID string_id
Default name (town area) of station.
Declaration of functions used in more save/load files.
VehicleTypeByte type
Type of vehicle.
Axis
Allow incrementing of DiagDirDiff variables.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
Order current_order
The current order (+ status, like: loading)
Date build_date
Date of construction.
Last chunk in this array.