OpenTTD Source 20241224-master-gf74b0cf984
|
Header file for NewGRF stations. More...
#include "core/enum_type.hpp"
#include "newgrf_animation_type.h"
#include "newgrf_callbacks.h"
#include "newgrf_class.h"
#include "newgrf_commons.h"
#include "cargo_type.h"
#include "station_type.h"
#include "rail_type.h"
#include "newgrf_spritegroup.h"
#include "newgrf_town.h"
Go to the source code of this file.
Data Structures | |
struct | StationScopeResolver |
Scope resolver for stations. More... | |
struct | StationResolverObject |
Station resolver. More... | |
struct | StationSpec |
Station specification. More... | |
Typedefs | |
using | StationClass = NewGRFClass< StationSpec, StationClassID, STAT_CLASS_MAX > |
Class containing information relating to station classes. | |
Enumerations | |
enum | StationClassID : uint16_t { STAT_CLASS_BEGIN = 0 , STAT_CLASS_DFLT = 0 , STAT_CLASS_WAYP , STAT_CLASS_MAX = UINT16_MAX } |
enum | StationSpecFlags { SSF_SEPARATE_GROUND , SSF_DIV_BY_STATION_SIZE , SSF_CB141_RANDOM_BITS , SSF_CUSTOM_FOUNDATIONS , SSF_EXTENDED_FOUNDATIONS } |
Allow incrementing of StationClassID variables. More... | |
enum | StationRandomTrigger { SRT_NEW_CARGO , SRT_CARGO_TAKEN , SRT_TRAIN_ARRIVES , SRT_TRAIN_DEPARTS , SRT_TRAIN_LOADS , SRT_PATH_RESERVATION } |
Randomisation triggers for stations. More... | |
Functions | |
DECLARE_ENUM_AS_BIT_SET (StationSpec::TileFlags) | |
const StationSpec * | GetStationSpec (TileIndex t) |
uint16_t | GetStationLayoutKey (uint8_t platforms, uint8_t length) |
Get the station layout key for a given station layout size. | |
bool | IsWaypointClass (const StationClass &cls) |
Test if a StationClass is the waypoint class. | |
uint32_t | GetPlatformInfo (Axis axis, uint8_t tile, int platforms, int length, int x, int y, bool centred) |
Evaluate a tile's position within a station, and return the result in a bit-stuffed format. | |
SpriteID | GetCustomStationRelocation (const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32_t var10=0) |
Resolve sprites for drawing a station tile. | |
SpriteID | GetCustomStationFoundationRelocation (const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info) |
Resolve the sprites for custom station foundations. | |
uint16_t | GetStationCallback (CallbackID callback, uint32_t param1, uint32_t param2, const StationSpec *statspec, BaseStation *st, TileIndex tile) |
CommandCost | PerformStationTileSlopeCheck (TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, uint8_t plat_len, uint8_t numtracks) |
Check the slope of a tile of a new station. | |
int | AllocateSpecToStation (const StationSpec *statspec, BaseStation *st, bool exec) |
Allocate a StationSpec to a Station. | |
void | DeallocateSpecFromStation (BaseStation *st, uint8_t specindex) |
Deallocate a StationSpec from a Station. | |
bool | DrawStationTile (int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station) |
Draw representation of a station tile for GUI purposes. | |
void | AnimateStationTile (TileIndex tile) |
void | TriggerStationAnimation (BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type=INVALID_CARGO) |
void | TriggerStationRandomisation (Station *st, TileIndex tile, StationRandomTrigger trigger, CargoID cargo_type=INVALID_CARGO) |
Trigger station randomisation. | |
void | StationUpdateCachedTriggers (BaseStation *st) |
Update the cached animation trigger bitmask for a station. | |
Variables | |
static const uint32_t | STATION_CLASS_LABEL_DEFAULT = 'DFLT' |
static const uint32_t | STATION_CLASS_LABEL_WAYPOINT = 'WAYP' |
Header file for NewGRF stations.
Definition in file newgrf_station.h.
Class containing information relating to station classes.
Definition at line 179 of file newgrf_station.h.
enum StationClassID : uint16_t |
Enumerator | |
---|---|
STAT_CLASS_BEGIN | the lowest valid value |
STAT_CLASS_DFLT | Default station class. |
STAT_CLASS_WAYP | Waypoint class. |
STAT_CLASS_MAX | Maximum number of classes. |
Definition at line 86 of file newgrf_station.h.
enum StationRandomTrigger |
Randomisation triggers for stations.
Definition at line 105 of file newgrf_station.h.
enum StationSpecFlags |
Allow incrementing of StationClassID variables.
Definition at line 96 of file newgrf_station.h.
int AllocateSpecToStation | ( | const StationSpec * | statspec, |
BaseStation * | st, | ||
bool | exec | ||
) |
Allocate a StationSpec to a Station.
This is called once per build operation.
statspec | StationSpec to allocate. |
st | Station to allocate it to. |
exec | Whether to actually allocate the spec. |
Definition at line 685 of file newgrf_station.cpp.
References StationSpec::grf_prop, GRFFilePropsBase< Tcnt >::grfid, GRFFilePropsBase< Tcnt >::local_id, NUM_STATIONSSPECS_PER_STATION, BaseStation::speclist, and StationUpdateCachedTriggers().
Referenced by CmdBuildRailStation(), CmdBuildRailWaypoint(), and MoveWaypointsToBaseStations().
void AnimateStationTile | ( | TileIndex | tile | ) |
Definition at line 870 of file newgrf_station.cpp.
void DeallocateSpecFromStation | ( | BaseStation * | st, |
uint8_t | specindex | ||
) |
Deallocate a StationSpec from a Station.
Called when removing a single station tile.
st | Station to work with. |
specindex | Index of the custom station within the Station's spec list. |
Definition at line 727 of file newgrf_station.cpp.
References BaseStation::cached_anim_triggers, BaseStation::cached_cargo_triggers, GetCustomStationSpecIndex(), INVALID_TILE, BaseStation::speclist, StationUpdateCachedTriggers(), and BaseStation::TileBelongsToRailStation().
Referenced by CmdBuildRailStation(), CmdBuildRailWaypoint(), and RemoveFromRailBaseStation().
bool DrawStationTile | ( | int | x, |
int | y, | ||
RailType | railtype, | ||
Axis | axis, | ||
StationClassID | sclass, | ||
uint | station | ||
) |
Draw representation of a station tile for GUI purposes.
x | Position x of image. |
y | Position y of image. |
axis | Axis. |
railtype | Rail type. |
sclass,station | Type of station. |
station | station ID |
Definition at line 775 of file newgrf_station.cpp.
References _local_company, CALLBACK_FAILED, StationSpec::callback_mask, CBID_STATION_DRAW_TILE_LAYOUT, CBM_STATION_DRAW_TILE_LAYOUT, DrawRailTileSeqInGUI(), DrawSprite(), RailTypeInfo::fallback_railtype, StationSpec::flags, NewGRFClass< Tspec, Tindex, Tmax >::Get(), GetCustomRailSprite(), GetCustomStationRelocation(), NewGRFSpriteLayout::GetLayout(), GetRailTypeInfo(), RailTypeInfo::GetRailtypeSpriteOffset(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpec(), GetStationTileLayout(), DrawTileSprites::ground, GroundSpritePaletteTransform(), HasBit(), INVALID_TILE, NewGRFSpriteLayout::NeedsPreprocessing(), PalSpriteID::pal, NewGRFSpriteLayout::PrepareLayout(), NewGRFSpriteLayout::ProcessRegisters(), StationSpec::renderdata, RTSG_GROUND, DrawTileSprites::seq, SplitGroundSpriteForOverlay(), PalSpriteID::sprite, SPRITE_MODIFIER_CUSTOM_SPRITE, and SSF_SEPARATE_GROUND.
Referenced by StationPickerCallbacks::DrawType(), DrawWaypointSprite(), and BuildRailStationWindow::DrawWidget().
SpriteID GetCustomStationFoundationRelocation | ( | const StationSpec * | statspec, |
BaseStation * | st, | ||
TileIndex | tile, | ||
uint | layout, | ||
uint | edge_info | ||
) |
Resolve the sprites for custom station foundations.
statspec | Station spec |
st | Station |
tile | Station tile being drawn |
layout | Spritelayout as returned by previous callback |
edge_info | Information about northern tile edges; whether they need foundations or merge into adjacent tile's foundations. |
Definition at line 628 of file newgrf_station.cpp.
References CBID_NO_CALLBACK, GetRegister(), and SpriteGroup::Resolve().
SpriteID GetCustomStationRelocation | ( | const StationSpec * | statspec, |
BaseStation * | st, | ||
TileIndex | tile, | ||
uint32_t | var10 | ||
) |
Resolve sprites for drawing a station tile.
statspec | Station spec |
st | Station (nullptr in GUI) |
tile | Station tile being drawn (INVALID_TILE in GUI) |
var10 | Value to put in variable 10; normally 0; 1 when resolving the groundsprite and SSF_SEPARATE_GROUND is set. |
Definition at line 611 of file newgrf_station.cpp.
References CBID_NO_CALLBACK, and SpriteGroup::Resolve().
Referenced by DrawStationTile().
uint32_t GetPlatformInfo | ( | Axis | axis, |
uint8_t | tile, | ||
int | platforms, | ||
int | length, | ||
int | x, | ||
int | y, | ||
bool | centred | ||
) |
Evaluate a tile's position within a station, and return the result in a bit-stuffed format.
if not centered: .TNLcCpP, if centered: .TNL..CP
if centered, C/P start from the centre and c/p are not available.
Definition at line 104 of file newgrf_station.cpp.
References AXIS_X, Clamp(), SB(), and Swap().
Referenced by CmdBuildRailStation().
uint16_t GetStationCallback | ( | CallbackID | callback, |
uint32_t | param1, | ||
uint32_t | param2, | ||
const StationSpec * | statspec, | ||
BaseStation * | st, | ||
TileIndex | tile | ||
) |
Definition at line 641 of file newgrf_station.cpp.
|
inline |
Get the station layout key for a given station layout size.
platforms | Number of platforms. |
length | Length of platforms. |
Definition at line 189 of file newgrf_station.h.
Referenced by GetStationLayout(), and StationChangeInfo().
const StationSpec * GetStationSpec | ( | TileIndex | t | ) |
Definition at line 846 of file newgrf_station.cpp.
|
inline |
Test if a StationClass is the waypoint class.
cls | StationClass to test. |
Definition at line 199 of file newgrf_station.h.
References GB(), and NewGRFClass< Tspec, Tindex, Tmax >::global_id.
CommandCost PerformStationTileSlopeCheck | ( | TileIndex | north_tile, |
TileIndex | cur_tile, | ||
const StationSpec * | statspec, | ||
Axis | axis, | ||
uint8_t | plat_len, | ||
uint8_t | numtracks | ||
) |
Check the slope of a tile of a new station.
north_tile | Norther tile of the station rect. |
cur_tile | Tile to check. |
statspec | Station spec. |
axis | Axis of the new station. |
plat_len | Platform length. |
numtracks | Number of platforms. |
Definition at line 657 of file newgrf_station.cpp.
References AXIS_Y, CALLBACK_FAILED, CBID_STATION_LAND_SLOPE_CHECK, GetErrorMessageFromLocationCallbackResult(), GetTileSlope(), StationSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), SLOPE_EW, TileX(), TileY(), and ToggleBit().
Referenced by CheckFlatLandRailStation().
void StationUpdateCachedTriggers | ( | BaseStation * | st | ) |
Update the cached animation trigger bitmask for a station.
st | Station to update. |
Definition at line 994 of file newgrf_station.cpp.
References BaseStation::cached_anim_triggers, and BaseStation::cached_cargo_triggers.
Referenced by AllocateSpecToStation(), and DeallocateSpecFromStation().
void TriggerStationAnimation | ( | BaseStation * | st, |
TileIndex | tile, | ||
StationAnimationTrigger | trigger, | ||
CargoID | cargo_type = INVALID_CARGO |
||
) |
Definition at line 878 of file newgrf_station.cpp.
void TriggerStationRandomisation | ( | Station * | st, |
TileIndex | trigger_tile, | ||
StationRandomTrigger | trigger, | ||
CargoID | cargo_type | ||
) |
Trigger station randomisation.
st | station being triggered |
trigger_tile | specific tile of platform to trigger |
trigger | trigger type |
cargo_type | cargo type causing trigger |
Definition at line 919 of file newgrf_station.cpp.
References BaseStation::cached_cargo_triggers, StationSpec::cargo_triggers, CBID_RANDOM_TRIGGER, BaseStation::GetByTile(), GetEmptyMask(), GetStationTileRandomBits(), HasBit(), IsValidCargoID(), MarkTileDirtyByTile(), BaseStation::random_bits, SpriteGroup::Resolve(), SetBit(), SetStationTileRandomBits(), SRT_CARGO_TAKEN, Station::TileBelongsToRailStation(), and BaseStation::waiting_triggers.
Referenced by Vehicle::LeaveStation(), LoadUnloadVehicle(), CYapfReserveTrack< Types >::ReserveRailStationPlatform(), TrainEnterStation(), and TryReserveRailTrack().
|
static |
Definition at line 83 of file newgrf_station.h.
|
static |
Definition at line 84 of file newgrf_station.h.