|
OpenTTD Source 20260108-master-g8ba1860eaa
|
Handling of NewGRF road stops. More...
#include "stdafx.h"#include "debug.h"#include "station_base.h"#include "roadstop_base.h"#include "newgrf_badge.h"#include "newgrf_roadstop.h"#include "newgrf_cargo.h"#include "newgrf_roadtype.h"#include "gfx_type.h"#include "company_func.h"#include "road.h"#include "window_type.h"#include "timer/timer_game_calendar.h"#include "town.h"#include "tile_cmd.h"#include "viewport_func.h"#include "newgrf_animation_base.h"#include "newgrf_sound.h"#include "table/strings.h"#include "newgrf_class_func.h"#include "safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | RoadStopAnimationFrameAnimationHelper |
| struct | RoadStopAnimationBase |
| Helper class for animation control. More... | |
Functions | |
| uint16_t | GetRoadStopCallback (CallbackID callback, uint32_t param1, uint32_t param2, const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, RoadType roadtype, StationType type, uint8_t view, std::span< int32_t > regs100) |
| void | DrawRoadStopTile (int x, int y, RoadType roadtype, const RoadStopSpec *spec, StationType type, int view) |
| Draw representation of a road stop tile for GUI purposes. | |
| std::optional< SpriteLayoutProcessor > | GetRoadStopLayout (TileInfo *ti, const RoadStopSpec *spec, BaseStation *st, StationType type, int view, std::span< int32_t > regs100) |
| uint16_t | GetAnimRoadStopCallback (CallbackID callback, uint32_t param1, uint32_t param2, const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, int) |
| Wrapper for animation control, see GetRoadStopCallback. | |
| void | AnimateRoadStopTile (TileIndex tile) |
| void | TriggerRoadStopAnimation (BaseStation *st, TileIndex trigger_tile, StationAnimationTrigger trigger, CargoType cargo_type) |
| void | TriggerRoadStopRandomisation (BaseStation *st, TileIndex tile, StationRandomTrigger trigger, CargoType cargo_type) |
| Trigger road stop randomisation. | |
| bool | GetIfNewStopsByType (RoadStopType rs, RoadType roadtype) |
| Checks if there's any new stations by a specific RoadStopType. | |
| bool | GetIfClassHasNewStopsByType (const RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype) |
| Checks if the given RoadStopClass has any specs assigned to it, compatible with the given RoadStopType. | |
| bool | GetIfStopIsForType (const RoadStopSpec *roadstopspec, RoadStopType rs, RoadType roadtype) |
| Checks if the given RoadStopSpec is compatible with the given RoadStopType. | |
| const RoadStopSpec * | GetRoadStopSpec (TileIndex t) |
| std::optional< uint8_t > | AllocateSpecToRoadStop (const RoadStopSpec *spec, BaseStation *st) |
| Allocate a RoadStopSpec to a Station. | |
| void | AssignSpecToRoadStop (const RoadStopSpec *spec, BaseStation *st, uint8_t specindex) |
| Assign a previously allocated RoadStopSpec specindex to a Station. | |
| void | DeallocateSpecFromRoadStop (BaseStation *st, uint8_t specindex) |
| Deallocate a RoadStopSpec from a Station. | |
| void | RoadStopUpdateCachedTriggers (BaseStation *st) |
| Update the cached animation trigger bitmask for a station. | |
Variables | |
| static const uint | NUM_ROADSTOPSPECS_PER_STATION = 63 |
| Maximum number of parts per station. | |
Handling of NewGRF road stops.
Definition in file newgrf_roadstop.cpp.
| std::optional< uint8_t > AllocateSpecToRoadStop | ( | const RoadStopSpec * | spec, |
| BaseStation * | st | ||
| ) |
Allocate a RoadStopSpec to a Station.
This is called once per build operation.
| spec | RoadStopSpec to allocate. |
| st | Station to allocate it to. |
Definition at line 568 of file newgrf_roadstop.cpp.
References NUM_ROADSTOPSPECS_PER_STATION, and BaseStation::roadstop_speclist.
Referenced by CmdBuildRoadStop(), and CmdBuildRoadWaypoint().
| void AnimateRoadStopTile | ( | TileIndex | tile | ) |
Definition at line 373 of file newgrf_roadstop.cpp.
| void AssignSpecToRoadStop | ( | const RoadStopSpec * | spec, |
| BaseStation * | st, | ||
| uint8_t | specindex | ||
| ) |
Assign a previously allocated RoadStopSpec specindex to a Station.
| spec | RoadStopSpec to assign.. |
| st | Station to allocate it to. |
| specindex | Spec index of allocation. |
Definition at line 601 of file newgrf_roadstop.cpp.
References RoadStopSpec::grf_prop, GRFFilePropsBase::grfid, GRFFilePropsBase::local_id, BaseStation::roadstop_speclist, and RoadStopUpdateCachedTriggers().
Referenced by CmdBuildRoadStop(), and CmdBuildRoadWaypoint().
| void DeallocateSpecFromRoadStop | ( | BaseStation * | st, |
| uint8_t | specindex | ||
| ) |
Deallocate a RoadStopSpec from a Station.
Called when removing a single roadstop tile.
| st | Station to work with. |
| specindex | Index of the custom roadstop within the Station's roadstop spec list. |
Definition at line 618 of file newgrf_roadstop.cpp.
References BaseStation::cached_roadstop_anim_triggers, BaseStation::cached_roadstop_cargo_triggers, BaseStation::custom_roadstop_tile_data, GetCustomRoadStopSpecIndex(), BaseStation::roadstop_speclist, and RoadStopUpdateCachedTriggers().
Referenced by RemoveRoadStop(), and RemoveRoadWaypointStop().
| void DrawRoadStopTile | ( | int | x, |
| int | y, | ||
| RoadType | roadtype, | ||
| const RoadStopSpec * | spec, | ||
| StationType | type, | ||
| int | view | ||
| ) |
Draw representation of a road stop tile for GUI purposes.
| x | position x of image. |
| y | position y of image. |
| image | an int offset for the sprite. |
| roadtype | the RoadType of the underlying road. |
| spec | the RoadStop's spec. |
Definition at line 282 of file newgrf_roadstop.cpp.
References _local_company, DrawCommonTileSeqInGUI(), DrawModeRegister, DrawSprite(), GB(), GetCompanyPalette(), GetCustomRoadSprite(), SpriteLayoutProcessor::GetLayout(), GetRoadTypeInfo(), GroundSpritePaletteTransform(), INVALID_ROADTYPE, INVALID_TILE, Overlay, TileLayoutSpriteGroup::ProcessRegisters(), Road, ROTSG_GROUND, ROTSG_OVERLAY, ROTSG_ROADSTOP, SPRITE_WIDTH, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and WaypGround.
Referenced by RoadStopPickerCallbacks< roadstoptype >::DrawType(), RoadWaypointPickerCallbacks::DrawType(), and BuildRoadStationWindow::DrawWidget().
| uint16_t GetAnimRoadStopCallback | ( | CallbackID | callback, |
| uint32_t | param1, | ||
| uint32_t | param2, | ||
| const RoadStopSpec * | roadstopspec, | ||
| BaseStation * | st, | ||
| TileIndex | tile, | ||
| int | |||
| ) |
Wrapper for animation control, see GetRoadStopCallback.
Definition at line 354 of file newgrf_roadstop.cpp.
References GetStationGfx(), GetStationType(), and INVALID_ROADTYPE.
| bool GetIfClassHasNewStopsByType | ( | const RoadStopClass * | roadstopclass, |
| RoadStopType | rs, | ||
| RoadType | roadtype | ||
| ) |
Checks if the given RoadStopClass has any specs assigned to it, compatible with the given RoadStopType.
| roadstopclass | the RoadStopClass to check. |
| rs | the RoadStopType to check. |
| roadtype | the RoadType to check. |
Definition at line 513 of file newgrf_roadstop.cpp.
References GetIfStopIsForType(), and NewGRFClass< Tspec, Tindex, Tmax >::Specs().
Referenced by GetIfNewStopsByType(), and BuildRoadToolbarWindow::OnPlaceMouseUp().
| bool GetIfNewStopsByType | ( | RoadStopType | rs, |
| RoadType | roadtype | ||
| ) |
Checks if there's any new stations by a specific RoadStopType.
| rs | the RoadStopType to check. |
| roadtype | the RoadType to check. |
Definition at line 494 of file newgrf_roadstop.cpp.
References NewGRFClass< Tspec, Tindex, Tmax >::Classes(), GetIfClassHasNewStopsByType(), IsWaypointClass(), and ROADSTOP_CLASS_DFLT.
| bool GetIfStopIsForType | ( | const RoadStopSpec * | roadstopspec, |
| RoadStopType | rs, | ||
| RoadType | roadtype | ||
| ) |
Checks if the given RoadStopSpec is compatible with the given RoadStopType.
| roadstopspec | the RoadStopSpec to check. |
| rs | the RoadStopType to check. |
| roadtype | the RoadType to check. |
Definition at line 528 of file newgrf_roadstop.cpp.
References Bus, RoadOnly, ROADSTOPTYPE_ALL, ROADSTOPTYPE_FREIGHT, ROADSTOPTYPE_PASSENGER, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TramOnly, and Truck.
Referenced by GetIfClassHasNewStopsByType().
| uint16_t GetRoadStopCallback | ( | CallbackID | callback, |
| uint32_t | param1, | ||
| uint32_t | param2, | ||
| const RoadStopSpec * | roadstopspec, | ||
| BaseStation * | st, | ||
| TileIndex | tile, | ||
| RoadType | roadtype, | ||
| StationType | type, | ||
| uint8_t | view, | ||
| std::span< int32_t > | regs100 | ||
| ) |
Definition at line 267 of file newgrf_roadstop.cpp.
| std::optional< SpriteLayoutProcessor > GetRoadStopLayout | ( | TileInfo * | ti, |
| const RoadStopSpec * | spec, | ||
| BaseStation * | st, | ||
| StationType | type, | ||
| int | view, | ||
| std::span< int32_t > | regs100 | ||
| ) |
Definition at line 342 of file newgrf_roadstop.cpp.
| const RoadStopSpec * GetRoadStopSpec | ( | TileIndex | t | ) |
Definition at line 553 of file newgrf_roadstop.cpp.
| void RoadStopUpdateCachedTriggers | ( | BaseStation * | st | ) |
Update the cached animation trigger bitmask for a station.
| st | Station to update. |
Definition at line 659 of file newgrf_roadstop.cpp.
References BaseStation::cached_roadstop_anim_triggers, BaseStation::cached_roadstop_cargo_triggers, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().
Referenced by AssignSpecToRoadStop(), and DeallocateSpecFromRoadStop().
| void TriggerRoadStopAnimation | ( | BaseStation * | st, |
| TileIndex | trigger_tile, | ||
| StationAnimationTrigger | trigger, | ||
| CargoType | cargo_type | ||
| ) |
Definition at line 381 of file newgrf_roadstop.cpp.
| void TriggerRoadStopRandomisation | ( | BaseStation * | st, |
| TileIndex | tile, | ||
| StationRandomTrigger | trigger, | ||
| CargoType | cargo_type | ||
| ) |
Trigger road stop randomisation.
| st | the station being triggered |
| tile | the exact tile of the station that should be triggered |
| trigger | trigger type |
| cargo_type | cargo type causing the trigger |
Definition at line 418 of file newgrf_roadstop.cpp.
References BaseStation::cached_roadstop_cargo_triggers, RoadStopSpec::cargo_triggers, CargoTaken, BaseStation::custom_roadstop_tile_data, SpecializedStation< Station, false >::From(), GetEmptyMask(), GetStationGfx(), GetStationType(), HasBit(), INVALID_ROADTYPE, IsValidCargoType(), MarkTileDirtyByTile(), NewCargo, Random, BaseStation::random_bits, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), and BaseStation::waiting_random_triggers.
Referenced by Vehicle::LeaveStation(), and LoadUnloadVehicle().
|
static |
Maximum number of parts per station.
Definition at line 54 of file newgrf_roadstop.cpp.
Referenced by AllocateSpecToRoadStop().