|
OpenTTD Source 20251117-master-g7398d2e290
|
Functions for dealing with station classes and custom stations. More...
#include "stdafx.h"#include "debug.h"#include "station_base.h"#include "waypoint_base.h"#include "roadstop_base.h"#include "newgrf_badge.h"#include "newgrf_cargo.h"#include "newgrf_station.h"#include "newgrf_spritegroup.h"#include "newgrf_sound.h"#include "newgrf_railtype.h"#include "town.h"#include "newgrf_town.h"#include "company_func.h"#include "tunnelbridge_map.h"#include "newgrf_animation_base.h"#include "timer/timer_game_calendar.h"#include "table/strings.h"#include "newgrf_class_func.h"#include "safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | StationAnimationBase |
| Helper class for animation control. More... | |
Enumerations | |
| enum | TriggerArea : uint8_t { TA_TILE , TA_PLATFORM , TA_WHOLE } |
Functions | |
| TileArea | GetRailTileArea (const BaseStation *st, TileIndex tile, TriggerArea ta) |
| Get the tile area of a rail station with trigger area type. | |
| 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. | |
| static TileIndex | FindRailStationEnd (TileIndex tile, TileIndexDiff delta, bool check_type, bool check_axis) |
| Find the end of a railway station, from the tile, in the direction of delta. | |
| static uint32_t | GetPlatformInfoHelper (TileIndex tile, bool check_type, bool check_axis, bool centred) |
| static uint32_t | GetRailContinuationInfo (TileIndex tile) |
| SpriteID | GetCustomStationRelocation (const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32_t var10) |
| Resolve sprites for drawing a station tile. | |
| void | GetCustomStationRelocation (SpriteLayoutProcessor &processor, const StationSpec *statspec, BaseStation *st, TileIndex 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, std::span< int32_t > regs100) |
| 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. | |
| std::optional< uint8_t > | AllocateSpecToStation (const StationSpec *spec, BaseStation *st) |
| Allocate a StationSpec to a Station. | |
| void | AssignSpecToStation (const StationSpec *spec, BaseStation *st, uint8_t specindex) |
| Assign a previously allocated StationSpec specindex 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. | |
| const StationSpec * | GetStationSpec (TileIndex t) |
| uint16_t | GetAnimStationCallback (CallbackID callback, uint32_t param1, uint32_t param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int) |
| Wrapper for animation control, see GetStationCallback. | |
| void | AnimateStationTile (TileIndex tile) |
| void | TriggerStationAnimation (BaseStation *st, TileIndex trigger_tile, StationAnimationTrigger trigger, CargoType cargo_type) |
| void | TriggerStationRandomisation (BaseStation *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoType cargo_type) |
| Trigger station randomisation. | |
| void | StationUpdateCachedTriggers (BaseStation *st) |
| Update the cached animation trigger bitmask for a station. | |
Variables | |
| static const uint | NUM_STATIONSSPECS_PER_STATION = 255 |
| Maximum number of parts per station. | |
Functions for dealing with station classes and custom stations.
Definition in file newgrf_station.cpp.
| enum TriggerArea : uint8_t |
Definition at line 70 of file newgrf_station.cpp.
| std::optional< uint8_t > AllocateSpecToStation | ( | const StationSpec * | spec, |
| BaseStation * | st | ||
| ) |
Allocate a StationSpec to a Station.
This is called once per build operation.
| spec | StationSpec to allocate. |
| st | Station to allocate it to. |
Definition at line 699 of file newgrf_station.cpp.
References NUM_STATIONSSPECS_PER_STATION, and BaseStation::speclist.
Referenced by CmdBuildRailStation(), CmdBuildRailWaypoint(), and MoveWaypointsToBaseStations().
| void AnimateStationTile | ( | TileIndex | tile | ) |
Definition at line 890 of file newgrf_station.cpp.
| void AssignSpecToStation | ( | const StationSpec * | spec, |
| BaseStation * | st, | ||
| uint8_t | specindex | ||
| ) |
Assign a previously allocated StationSpec specindex to a Station.
| spec | StationSpec to assign.. |
| st | Station to allocate it to. |
| specindex | Spec index of allocation. |
Definition at line 734 of file newgrf_station.cpp.
References StationSpec::grf_prop, GRFFilePropsBase::grfid, GRFFilePropsBase::local_id, BaseStation::speclist, and StationUpdateCachedTriggers().
Referenced by CmdBuildRailStation(), CmdBuildRailWaypoint(), and MoveWaypointsToBaseStations().
| 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 station spec list. |
Definition at line 751 of file newgrf_station.cpp.
References BaseStation::cached_anim_triggers, BaseStation::cached_cargo_triggers, GetCustomStationSpecIndex(), GetRailTileArea(), 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 798 of file newgrf_station.cpp.
References _local_company, CALLBACK_FAILED, StationSpec::callback_mask, CBID_STATION_DRAW_TILE_LAYOUT, DrawRailTileSeqInGUI(), DrawSprite(), DrawTileLayout, RailTypeInfo::fallback_railtype, StationSpec::flags, NewGRFClass< Tspec, Tindex, Tmax >::Get(), GetCompanyPalette(), GetCustomRailSprite(), GetCustomStationRelocation(), SpriteLayoutProcessor::GetLayout(), GetRailTypeInfo(), RailTypeInfo::GetRailtypeSpriteOffset(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpec(), GetStationTileLayout(), DrawTileSprites::ground, GroundSpritePaletteTransform(), HasBit(), INVALID_TILE, NewGRFSpriteLayout::NeedsPreprocessing(), PalSpriteID::pal, StationSpec::renderdata, RTSG_GROUND, SeparateGround, SplitGroundSpriteForOverlay(), PalSpriteID::sprite, SPRITE_MODIFIER_CUSTOM_SPRITE, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
Referenced by StationPickerCallbacks::DrawType(), DrawWaypointSprite(), and BuildRailStationWindow::DrawWidget().
|
static |
Find the end of a railway station, from the tile, in the direction of delta.
| tile | Start tile. |
| delta | Movement direction. |
| check_type | Stop when the custom station type changes. |
| check_axis | Stop when the station direction changes. |
Definition at line 158 of file newgrf_station.cpp.
References AXIS_X, GetCustomStationSpecIndex(), GetRailStationAxis(), GetStationIndex(), HasStationRail(), IsTileType(), MP_STATION, and TileAdd().
| uint16_t GetAnimStationCallback | ( | CallbackID | callback, |
| uint32_t | param1, | ||
| uint32_t | param2, | ||
| const StationSpec * | statspec, | ||
| BaseStation * | st, | ||
| TileIndex | tile, | ||
| int | |||
| ) |
Wrapper for animation control, see GetStationCallback.
Definition at line 876 of file newgrf_station.cpp.
| 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 641 of file newgrf_station.cpp.
References CBID_NO_CALLBACK.
Referenced by DrawCustomStationFoundations().
| 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 StationSpecFlag::SeparateGround is set. |
Definition at line 613 of file newgrf_station.cpp.
References CBID_NO_CALLBACK.
Referenced by DrawStationTile().
| void GetCustomStationRelocation | ( | SpriteLayoutProcessor & | processor, |
| const StationSpec * | statspec, | ||
| BaseStation * | st, | ||
| TileIndex | tile | ||
| ) |
Definition at line 621 of file newgrf_station.cpp.
| 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 120 of file newgrf_station.cpp.
References AXIS_X, Clamp(), and SB().
Referenced by CmdBuildRailStation().
|
static |
Definition at line 181 of file newgrf_station.cpp.
|
static |
Definition at line 197 of file newgrf_station.cpp.
| TileArea GetRailTileArea | ( | const BaseStation * | st, |
| TileIndex | tile, | ||
| TriggerArea | ta | ||
| ) |
Get the tile area of a rail station with trigger area type.
| st | The rail station or rail waypoint. |
| tile | Origin tile. |
| ta | Trigger area type. |
Definition at line 83 of file newgrf_station.cpp.
References GetRailStationAxis(), BaseStation::GetTileArea(), IsCompatibleTrainStationTile(), SpecializedStation< Station, false >::IsExpected(), IsRailStationTile(), TileOffsByAxis(), TileX(), and TileY().
Referenced by DeallocateSpecFromStation(), and TriggerStationRandomisation().
| uint16_t GetStationCallback | ( | CallbackID | callback, |
| uint32_t | param1, | ||
| uint32_t | param2, | ||
| const StationSpec * | statspec, | ||
| BaseStation * | st, | ||
| TileIndex | tile, | ||
| std::span< int32_t > | regs100 | ||
| ) |
Definition at line 655 of file newgrf_station.cpp.
| const StationSpec * GetStationSpec | ( | TileIndex | t | ) |
Definition at line 866 of file newgrf_station.cpp.
| 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 671 of file newgrf_station.cpp.
References AXIS_Y, CALLBACK_FAILED, CBID_STATION_LAND_SLOPE_CHECK, GetErrorMessageFromLocationCallbackResult(), GetTileSlope(), StationSpec::grf_prop, GRFFilePropsBase::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 1020 of file newgrf_station.cpp.
References BaseStation::cached_anim_triggers, BaseStation::cached_cargo_triggers, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().
Referenced by AssignSpecToStation(), and DeallocateSpecFromStation().
| void TriggerStationAnimation | ( | BaseStation * | st, |
| TileIndex | trigger_tile, | ||
| StationAnimationTrigger | trigger, | ||
| CargoType | cargo_type | ||
| ) |
Definition at line 898 of file newgrf_station.cpp.
| void TriggerStationRandomisation | ( | BaseStation * | st, |
| TileIndex | trigger_tile, | ||
| StationRandomTrigger | trigger, | ||
| CargoType | 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 944 of file newgrf_station.cpp.
References BaseStation::cached_cargo_triggers, StationSpec::cargo_triggers, CargoTaken, CBID_RANDOM_TRIGGER, SpecializedStation< Station, false >::From(), GetEmptyMask(), GetRailTileArea(), GetStationTileRandomBits(), HasBit(), IsValidCargoType(), MarkTileDirtyByTile(), Random, BaseStation::random_bits, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetStationTileRandomBits(), BaseStation::TileBelongsToRailStation(), and BaseStation::waiting_random_triggers.
Referenced by Vehicle::LeaveStation(), LoadUnloadVehicle(), CYapfReserveTrack< Types >::ReserveRailStationPlatform(), CYapfReserveTrack< Types >::ReserveSingleTrack(), TrainEnterStation(), and TryReserveRailTrack().
|
static |
Maximum number of parts per station.
Definition at line 54 of file newgrf_station.cpp.
Referenced by AllocateSpecToStation().