|
OpenTTD
|
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_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 "newgrf_class_func.h"#include "safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | ETileArea |
| struct | StationAnimationBase |
| Helper class for animation control. More... | |
Enumerations | |
| enum | TriggerArea { TA_TILE, TA_PLATFORM, TA_WHOLE } |
Functions | |
| uint32 | GetPlatformInfo (Axis axis, byte 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 | GetPlatformInfoHelper (TileIndex tile, bool check_type, bool check_axis, bool centred) |
| static uint32 | GetRailContinuationInfo (TileIndex tile) |
| SpriteID | GetCustomStationRelocation (const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10) |
| 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 | GetStationCallback (CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile) |
| CommandCost | PerformStationTileSlopeCheck (TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, byte plat_len, byte 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, byte 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) |
| bool | IsStationTileBlocked (TileIndex tile) |
| Check whether a rail station tile is NOT traversable. | |
| bool | CanStationTileHavePylons (TileIndex tile) |
| Check if a rail station tile shall have pylons when electrified. | |
| bool | CanStationTileHaveWires (TileIndex tile) |
| Check if a rail station tile shall have wires when electrified. | |
| uint16 | GetAnimStationCallback (CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int extra_data) |
| Wrapper for animation control, see #GetStationCallback. | |
| void | AnimateStationTile (TileIndex tile) |
| void | TriggerStationAnimation (BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type) |
| void | TriggerStationRandomisation (Station *st, TileIndex tile, StationRandomTrigger trigger, CargoID 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. | |
| struct { | |
| uint32 v40 | |
| uint32 v41 | |
| uint32 v45 | |
| uint32 v46 | |
| uint32 v47 | |
| uint32 v49 | |
| uint8 valid | |
Bits indicating what variable is valid (for each bit, 0 is invalid, 1 is valid). | |
| } | _svc |
| Station variable cache This caches 'expensive' station variable lookups which iterate over several tiles that may be called multiple times per Resolve(). | |
Functions for dealing with station classes and custom stations.
Definition in file newgrf_station.cpp.
| 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 687 of file newgrf_station.cpp.
References StationSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, StationSpecList::grfid, GRFFilePropsBase< Tcnt >::local_id, StationSpecList::localidx, BaseStation::num_specs, NUM_STATIONSSPECS_PER_STATION, ReallocT(), BaseStation::speclist, and StationUpdateCachedTriggers().
Referenced by CmdBuildRailStation(), CmdBuildRailWaypoint(), and MoveWaypointsToBaseStations().
| bool CanStationTileHavePylons | ( | TileIndex | tile | ) |
Check if a rail station tile shall have pylons when electrified.
| tile | Tile to test. |
Definition at line 888 of file newgrf_station.cpp.
References GetStationGfx(), HasBit(), and StationSpec::pylons.
Referenced by DrawRailCatenaryRailway().
| bool CanStationTileHaveWires | ( | TileIndex | tile | ) |
Check if a rail station tile shall have wires when electrified.
| tile | Tile to test. |
Definition at line 902 of file newgrf_station.cpp.
References GetStationGfx(), HasBit(), and StationSpec::wires.
Referenced by DrawRailCatenaryRailway(), and MaskWireBits().
| void DeallocateSpecFromStation | ( | BaseStation * | st, |
| byte | 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 740 of file newgrf_station.cpp.
References BaseStation::cached_anim_triggers, BaseStation::cached_cargo_triggers, free(), GetCustomStationSpecIndex(), StationSpecList::grfid, INVALID_TILE, StationSpecList::localidx, BaseStation::num_specs, ReallocT(), BaseStation::speclist, StationUpdateCachedTriggers(), TILE_AREA_LOOP, 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 787 of file newgrf_station.cpp.
References _local_company, CALLBACK_FAILED, StationSpec::callback_mask, CBID_STATION_SPRITE_LAYOUT, CBM_STATION_SPRITE_LAYOUT, DrawRailTileSeqInGUI(), DrawSprite(), RailtypeInfo::fallback_railtype, StationSpec::flags, FOR_EACH_SET_BIT, NewGRFClass< Tspec, Tid, Tmax >::Get(), GetCustomRailSprite(), GetCustomStationRelocation(), NewGRFSpriteLayout::GetLayout(), GetRailTypeInfo(), RailtypeInfo::GetRailtypeSpriteOffset(), 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, SSF_SEPARATE_GROUND, and StationSpec::tiles.
Referenced by 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 145 of file newgrf_station.cpp.
References AXIS_X, GetCustomStationSpecIndex(), GetRailStationAxis(), GetStationIndex(), HasStationRail(), IsTileType(), MP_STATION, and TILE_ADD.
| uint16 GetAnimStationCallback | ( | CallbackID | callback, |
| uint32 | param1, | ||
| uint32 | param2, | ||
| const StationSpec * | statspec, | ||
| BaseStation * | st, | ||
| TileIndex | tile, | ||
| int | extra_data | ||
| ) |
Wrapper for animation control, see #GetStationCallback.
Definition at line 909 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 630 of file newgrf_station.cpp.
References CBID_NO_CALLBACK, GetRegister(), and SpriteGroup::Resolve().
| SpriteID GetCustomStationRelocation | ( | const StationSpec * | statspec, |
| BaseStation * | st, | ||
| TileIndex | tile, | ||
| uint32 | var10 | ||
| ) |
Resolve sprites for drawing a station tile.
| statspec | Station spec |
| st | Station (NULL 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 613 of file newgrf_station.cpp.
References CBID_NO_CALLBACK, and SpriteGroup::Resolve().
Referenced by DrawStationTile().
| uint32 GetPlatformInfo | ( | Axis | axis, |
| byte | 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 107 of file newgrf_station.cpp.
References AXIS_X, Clamp(), min(), SB(), and Swap().
Referenced by CmdBuildRailStation().
| bool IsStationTileBlocked | ( | TileIndex | tile | ) |
Check whether a rail station tile is NOT traversable.
| tile | Tile to test. |
Definition at line 875 of file newgrf_station.cpp.
References StationSpec::blocked, GetStationGfx(), and HasBit().
Referenced by AfterLoadCompanyStats(), AfterLoadGame(), CmdBuildRailStation(), CmdConvertRail(), ExploreSegment(), IsCompatibleTrainStationTile(), and RemoveFromRailBaseStation().
| CommandCost PerformStationTileSlopeCheck | ( | TileIndex | north_tile, |
| TileIndex | cur_tile, | ||
| const StationSpec * | statspec, | ||
| Axis | axis, | ||
| byte | plat_len, | ||
| byte | 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 659 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 1050 of file newgrf_station.cpp.
References BaseStation::cached_anim_triggers, BaseStation::cached_cargo_triggers, StationSpec::cargo_triggers, BaseStation::num_specs, BaseStation::speclist, and AnimationInfo::triggers.
Referenced by AllocateSpecToStation(), and DeallocateSpecFromStation().
| void TriggerStationRandomisation | ( | Station * | st, |
| TileIndex | tile, | ||
| StationRandomTrigger | trigger, | ||
| CargoID | cargo_type | ||
| ) |
Trigger station randomisation.
| st | station being triggered |
| tile | specific tile of platform to trigger |
| trigger | trigger type |
| cargo_type | cargo type causing trigger |
Definition at line 972 of file newgrf_station.cpp.
References BaseStation::cached_cargo_triggers, GoodsEntry::cargo, StationSpec::cargo_triggers, CBID_RANDOM_TRIGGER, CT_INVALID, SpecializedStation< Station, false >::GetByTile(), GetStationTileRandomBits(), Station::goods, HasBit(), MarkTileDirtyByTile(), NUM_CARGO, BaseStation::random_bits, SpriteGroup::Resolve(), SetBit(), SetStationTileRandomBits(), SRT_CARGO_TAKEN, TILE_AREA_LOOP, Station::TileBelongsToRailStation(), and StationCargoList::TotalCount().
Referenced by Vehicle::LeaveStation(), LoadUnloadVehicle(), CYapfReserveTrack< Types >::ReserveRailStationPlatform(), TrainEnterStation(), and TryReserveRailTrack().
1.8.1.2