|
OpenTTD Source 20260208-master-g43af8e94d0
|
A Stop for a Road Vehicle. More...
#include <roadstop_base.h>
Data Structures | |
| struct | Entry |
| Container for each entry point of a drive through road stop. More... | |
| struct | Entries |
| Container for both east and west entry points. More... | |
Public Types | |
| enum class | RoadStopStatusFlag : uint8_t { Bay0Free = 0 , Bay1Free = 1 , BaseEntry = 6 , EntryBusy = 7 } |
| Flags describing the status of a single road stop. More... | |
| using | RoadStopStatusFlags = EnumBitSet<RoadStopStatusFlag, uint8_t> |
Public Member Functions | |
| RoadStop (RoadStopID index, TileIndex tile=INVALID_TILE) | |
| Initializes a RoadStop. | |
| ~RoadStop () | |
| De-Initializes RoadStops. | |
| bool | HasFreeBay () const |
| Checks whether there is a free bay in this road stop. | |
| bool | IsFreeBay (uint nr) const |
| Checks whether the given bay is free in this road stop. | |
| bool | IsEntranceBusy () const |
| Checks whether the entrance of the road stop is occupied by a vehicle. | |
| void | SetEntranceBusy (bool busy) |
| Makes an entrance occupied or free. | |
| const Entry & | GetEntry (DiagDirection dir) const |
| Get the drive through road stop entry struct for the given direction. | |
| Entry & | GetEntry (DiagDirection dir) |
| Get the drive through road stop entry struct for the given direction. | |
| void | MakeDriveThrough () |
| Join this road stop to another 'base' road stop if possible; fill all necessary data to become an actual drive through road stop. | |
| void | ClearDriveThrough () |
| Prepare for removal of this stop; update other neighbouring stops if needed. | |
| void | Leave (RoadVehicle *rv) |
| Leave the road stop. | |
| bool | Enter (RoadVehicle *rv) |
| Enter the road stop. | |
| RoadStop * | GetNextRoadStop (const struct RoadVehicle *v) const |
| Get the next road stop accessible by this vehicle. | |
Static Public Member Functions | |
| static RoadStop * | GetByTile (TileIndex tile, RoadStopType type) |
| Find a roadstop at given tile. | |
| static bool | IsDriveThroughRoadStopContinuation (TileIndex rs, TileIndex next) |
| Checks whether the 'next' tile is still part of the road same drive through stop 'rs' in the same direction for the same vehicle. | |
Data Fields | |
| RoadStopStatusFlags | status {RoadStopStatusFlag::Bay0Free, RoadStopStatusFlag::Bay1Free} |
| Current status of the Stop. Access using *Bay and *Busy functions. | |
| TileIndex | xy = INVALID_TILE |
| Position on the map. | |
| RoadStop * | next = nullptr |
| Next stop of the given type at this station. | |
Private Member Functions | |
| uint | AllocateBay () |
| Allocates a bay. | |
| void | AllocateDriveThroughBay (uint nr) |
| Allocates a bay in a drive-through road stop. | |
| void | FreeBay (uint nr) |
| Frees the given bay. | |
Private Attributes | |
| Entries * | entries = nullptr |
| Information about available and allocated bays. | |
A Stop for a Road Vehicle.
Definition at line 21 of file roadstop_base.h.
| using RoadStop::RoadStopStatusFlags = EnumBitSet<RoadStopStatusFlag, uint8_t> |
Definition at line 29 of file roadstop_base.h.
|
strong |
Flags describing the status of a single road stop.
Definition at line 23 of file roadstop_base.h.
|
inline |
Initializes a RoadStop.
Definition at line 75 of file roadstop_base.h.
References INVALID_TILE, and xy.
Referenced by ClearDriveThrough(), GetByTile(), GetNextRoadStop(), MakeDriveThrough(), and ~RoadStop().
| RoadStop::~RoadStop | ( | ) |
De-Initializes RoadStops.
Definition at line 27 of file roadstop.cpp.
References BaseEntry, RoadStop(), and status.
|
inlineprivate |
Allocates a bay.
Definition at line 160 of file roadstop_base.h.
References AllocateDriveThroughBay(), HasFreeBay(), and IsFreeBay().
Referenced by Enter().
|
inlineprivate |
Allocates a bay in a drive-through road stop.
| nr | the number of the bay to allocate |
Definition at line 176 of file roadstop_base.h.
References Bay0Free, Bay1Free, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset().
Referenced by AllocateBay().
| void RoadStop::ClearDriveThrough | ( | ) |
Prepare for removal of this stop; update other neighbouring stops if needed.
Also update the length etc.
Definition at line 122 of file roadstop.cpp.
References BaseEntry, RoadStop::Entries::east, entries, GetByTile(), GetDriveThroughStopAxis(), GetRoadStopType(), IsDriveThroughRoadStopContinuation(), RoadStop::Entry::length, RoadStop::Entry::Rebuild(), RoadStop(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), status, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TILE_SIZE, TileOffsByAxis(), RoadStop::Entries::west, and xy.
Referenced by RemoveRoadStop().
| bool RoadStop::Enter | ( | RoadVehicle * | rv | ) |
Enter the road stop.
| rv | the vehicle that enters the stop |
Definition at line 220 of file roadstop.cpp.
References AllocateBay(), Vehicle::direction, DirToDiagDir(), RoadStop::Entry::Enter(), GetEntry(), Vehicle::HasArticulatedPart(), HasFreeBay(), IsBayRoadStopTile(), IsEntranceBusy(), RVS_IN_DT_ROAD_STOP, RVS_IN_ROAD_STOP, RVS_USING_SECOND_BAY, SB(), SetBit(), SetEntranceBusy(), RoadVehicle::state, and xy.
|
inlineprivate |
Frees the given bay.
| nr | the number of the bay to free |
Definition at line 189 of file roadstop_base.h.
References Bay0Free, Bay1Free, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().
Referenced by Leave().
|
static |
Find a roadstop at given tile.
| tile | tile with roadstop |
| type | roadstop type |
Definition at line 253 of file roadstop.cpp.
References BaseStation::GetByTile(), next, and RoadStop().
Referenced by ClearDriveThrough(), RoadVehicle::Crash(), DeleteLastRoadVeh(), MakeDriveThrough(), CYapfCostRoadT< Types >::OneTileCost(), Vehicle::PreDestructor(), RemoveRoadStop(), and RoadFindPathToDest().
|
inline |
Get the drive through road stop entry struct for the given direction.
| dir | The direction to get the entry for. |
Definition at line 135 of file roadstop_base.h.
References DIAGDIR_SW, and entries.
|
inline |
Get the drive through road stop entry struct for the given direction.
| dir | The direction to get the entry for. |
Definition at line 125 of file roadstop_base.h.
References DIAGDIR_SW, and entries.
Referenced by Enter(), Leave(), and CYapfCostRoadT< Types >::OneTileCost().
| RoadStop * RoadStop::GetNextRoadStop | ( | const struct RoadVehicle * | v | ) | const |
Get the next road stop accessible by this vehicle.
| v | the vehicle to get the next road stop for. |
Definition at line 40 of file roadstop.cpp.
References RoadVehicle::compatible_roadtypes, Vehicle::HasArticulatedPart(), HasTileAnyRoadType(), IsBayRoadStopTile(), next, and RoadStop().
|
inline |
Checks whether there is a free bay in this road stop.
Definition at line 83 of file roadstop_base.h.
References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Bay0Free, and Bay1Free.
Referenced by AllocateBay(), and Enter().
Checks whether the 'next' tile is still part of the road same drive through stop 'rs' in the same direction for the same vehicle.
| rs | the road stop tile to check against |
| next | the 'next' tile to check |
Definition at line 292 of file roadstop.cpp.
References GetDriveThroughStopAxis(), GetStationIndex(), GetStationType(), IsDriveThroughStopTile(), IsTileType(), next, and Station.
Referenced by RoadStop::Entry::CheckIntegrity(), ClearDriveThrough(), MakeDriveThrough(), CYapfCostRoadT< Types >::OneTileCost(), and RoadStop::Entry::Rebuild().
|
inline |
Checks whether the entrance of the road stop is occupied by a vehicle.
Definition at line 106 of file roadstop_base.h.
References EntryBusy, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
Referenced by Enter().
|
inline |
Checks whether the given bay is free in this road stop.
| nr | bay to check |
Definition at line 93 of file roadstop_base.h.
References Bay0Free, Bay1Free, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
Referenced by AllocateBay(), and CYapfCostRoadT< Types >::OneTileCost().
| void RoadStop::Leave | ( | RoadVehicle * | rv | ) |
Leave the road stop.
| rv | the vehicle that leaves the stop |
Definition at line 203 of file roadstop.cpp.
References Vehicle::direction, DirToDiagDir(), FreeBay(), GetEntry(), HasBit(), IsBayRoadStopTile(), RoadStop::Entry::Leave(), RVS_USING_SECOND_BAY, SetEntranceBusy(), RoadVehicle::state, and Vehicle::tile.
Referenced by RoadVehicle::Crash(), DeleteLastRoadVeh(), and Vehicle::PreDestructor().
| void RoadStop::MakeDriveThrough | ( | ) |
Join this road stop to another 'base' road stop if possible; fill all necessary data to become an actual drive through road stop.
Also update the length etc.
Definition at line 60 of file roadstop.cpp.
References BaseEntry, RoadStop::Entries::east, entries, GetByTile(), GetDriveThroughStopAxis(), GetRoadStopType(), IsDriveThroughRoadStopContinuation(), RoadStop::Entry::occupied, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), RoadStop(), status, TILE_SIZE, TileOffsByAxis(), RoadStop::Entries::west, and xy.
Referenced by CmdBuildRoadStop().
|
inline |
Makes an entrance occupied or free.
| busy | If true, marks busy; free otherwise. |
Definition at line 115 of file roadstop_base.h.
References EntryBusy, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().
|
private |
Information about available and allocated bays.
Definition at line 153 of file roadstop_base.h.
Referenced by RoadStop::Entry::CheckIntegrity(), ClearDriveThrough(), GetEntry(), GetEntry(), MakeDriveThrough(), and RoadStop::Entry::Rebuild().
| RoadStop* RoadStop::next = nullptr |
Next stop of the given type at this station.
Definition at line 72 of file roadstop_base.h.
Referenced by FindRoadStopSpot(), GetByTile(), GetNextRoadStop(), Station::GetPrimaryRoadStop(), GetVehicleCannotUseStationReason(), IsDriveThroughRoadStopContinuation(), and RemoveRoadStop().
| RoadStopStatusFlags RoadStop::status {RoadStopStatusFlag::Bay0Free, RoadStopStatusFlag::Bay1Free} |
Current status of the Stop. Access using *Bay and *Busy functions.
Definition at line 70 of file roadstop_base.h.
Referenced by RoadStop::Entry::CheckIntegrity(), ClearDriveThrough(), MakeDriveThrough(), RoadStop::Entry::Rebuild(), and ~RoadStop().
| TileIndex RoadStop::xy = INVALID_TILE |
Position on the map.
Definition at line 71 of file roadstop_base.h.
Referenced by RoadStop::Entry::CheckIntegrity(), ClearDriveThrough(), Enter(), Station::GetPrimaryRoadStop(), GetVehicleCannotUseStationReason(), MakeDriveThrough(), RoadStop::Entry::Rebuild(), and RoadStop().