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... | |
Public Types | |
enum | RoadStopStatusFlags { RSSFB_BAY0_FREE = 0, RSSFB_BAY1_FREE = 1, RSSFB_BAY_COUNT = 2, RSSFB_BASE_ENTRY = 6, RSSFB_ENTRY_BUSY = 7 } |
Public Member Functions | |
FORCEINLINE | RoadStop (TileIndex tile=INVALID_TILE) |
Initializes a RoadStop. | |
~RoadStop () | |
De-Initializes RoadStops. | |
FORCEINLINE bool | HasFreeBay () const |
Checks whether there is a free bay in this road stop. | |
FORCEINLINE bool | IsFreeBay (uint nr) const |
Checks whether the given bay is free in this road stop. | |
FORCEINLINE bool | IsEntranceBusy () const |
Checks whether the entrance of the road stop is occupied by a vehicle. | |
FORCEINLINE void | SetEntranceBusy (bool busy) |
Makes an entrance occupied or free. | |
FORCEINLINE const Entry * | GetEntry (DiagDirection dir) const |
Get the drive through road stop entry struct for the given direction. | |
FORCEINLINE 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 |
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 | |
TileIndex | xy |
Position on the map. | |
byte | status |
Current status of the Stop,. | |
struct RoadStop * | next |
Next stop of the given type at this station. | |
Private Member Functions | |
FORCEINLINE uint | AllocateBay () |
Allocates a bay. | |
FORCEINLINE void | AllocateDriveThroughBay (uint nr) |
Allocates a bay in a drive-through road stop. | |
FORCEINLINE void | FreeBay (uint nr) |
Frees the given bay. | |
Private Attributes | |
Entry * | east |
The vehicles that entered from the east. | |
Entry * | west |
The vehicles that entered from the west. |
A Stop for a Road Vehicle.
Definition at line 25 of file roadstop_base.h.
Definition at line 26 of file roadstop_base.h.
FORCEINLINE uint RoadStop::AllocateBay | ( | ) | [inline, private] |
Allocates a bay.
Definition at line 161 of file roadstop_base.h.
References ClrBit(), HasBit(), HasFreeBay(), and status.
Referenced by Enter().
FORCEINLINE void RoadStop::AllocateDriveThroughBay | ( | uint | nr | ) | [inline, private] |
Allocates a bay in a drive-through road stop.
nr | the number of the bay to allocate |
Definition at line 177 of file roadstop_base.h.
References ClrBit(), RSSFB_BAY_COUNT, and status.
void RoadStop::ClearDriveThrough | ( | ) |
Prepare for removal of this stop; update other neighbouring stops if needed.
Also update the length etc.
Definition at line 130 of file roadstop.cpp.
References abs(), ClrBit(), east, GetByTile(), GetRoadStopDir(), GetRoadStopType(), HasBit(), IsDriveThroughRoadStopContinuation(), RoadStop::Entry::length, RoadStop::Entry::Rebuild(), RSSFB_BASE_ENTRY, SetBit(), status, TILE_SIZE, TileOffsByDiagDir(), 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 233 of file roadstop.cpp.
References AllocateBay(), DirToDiagDir(), RoadStop::Entry::Enter(), GetEntry(), RoadVehicle::HasArticulatedPart(), HasFreeBay(), IsEntranceBusy(), IsStandardRoadStopTile(), RVS_IN_DT_ROAD_STOP, RVS_IN_ROAD_STOP, RVS_USING_SECOND_BAY, SB(), SetBit(), SetEntranceBusy(), RoadVehicle::state, and xy.
FORCEINLINE void RoadStop::FreeBay | ( | uint | nr | ) | [inline, private] |
Frees the given bay.
nr | the number of the bay to free |
Definition at line 187 of file roadstop_base.h.
References RSSFB_BAY_COUNT, SetBit(), and status.
Referenced by Leave().
RoadStop * RoadStop::GetByTile | ( | TileIndex | tile, | |
RoadStopType | type | |||
) | [static] |
Find a roadstop at given tile.
tile | tile with roadstop | |
type | roadstop type |
Definition at line 266 of file roadstop.cpp.
References next.
Referenced by ClearDriveThrough(), RoadVehicle::Crash(), MakeDriveThrough(), CYapfCostRoadT< Types >::OneTileCost(), Vehicle::PreDestructor(), RemoveRoadStop(), and RoadFindPathToDest().
FORCEINLINE Entry* RoadStop::GetEntry | ( | DiagDirection | dir | ) | [inline] |
Get the drive through road stop entry struct for the given direction.
direction | the direciton to get the entry for |
Definition at line 135 of file roadstop_base.h.
FORCEINLINE const Entry* RoadStop::GetEntry | ( | DiagDirection | dir | ) | const [inline] |
Get the drive through road stop entry struct for the given direction.
direction | the direciton to get the entry for |
Definition at line 125 of file roadstop_base.h.
References east, HasBit(), and west.
Referenced by AfterLoadRoadStops(), CheckCaches(), Enter(), Leave(), and CYapfCostRoadT< Types >::OneTileCost().
FORCEINLINE bool RoadStop::HasFreeBay | ( | ) | const [inline] |
Checks whether there is a free bay in this road stop.
Definition at line 86 of file roadstop_base.h.
References GB(), RSSFB_BAY_COUNT, and status.
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 305 of file roadstop.cpp.
References GetRoadStopDir(), GetStationIndex(), GetStationType(), IsDriveThroughStopTile(), IsTileType(), and MP_STATION.
Referenced by RoadStop::Entry::CheckIntegrity(), ClearDriveThrough(), MakeDriveThrough(), CYapfCostRoadT< Types >::OneTileCost(), and RoadStop::Entry::Rebuild().
FORCEINLINE bool RoadStop::IsEntranceBusy | ( | ) | const [inline] |
Checks whether the entrance of the road stop is occupied by a vehicle.
Definition at line 106 of file roadstop_base.h.
References HasBit(), RSSFB_ENTRY_BUSY, and status.
Referenced by Enter().
FORCEINLINE bool RoadStop::IsFreeBay | ( | uint | nr | ) | const [inline] |
Checks whether the given bay is free in this road stop.
nr | bay to check |
Definition at line 96 of file roadstop_base.h.
References HasBit(), RSSFB_BAY_COUNT, and status.
Referenced by CYapfCostRoadT< Types >::OneTileCost().
void RoadStop::Leave | ( | RoadVehicle * | rv | ) |
Leave the road stop.
rv | the vehicle that leaves the stop |
Definition at line 216 of file roadstop.cpp.
References DirToDiagDir(), FreeBay(), GetEntry(), HasBit(), IsStandardRoadStopTile(), RoadStop::Entry::Leave(), RVS_USING_SECOND_BAY, SetEntranceBusy(), RoadVehicle::state, and Vehicle::tile.
Referenced by RoadVehicle::Crash(), 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 62 of file roadstop.cpp.
References abs(), ClrBit(), east, GetByTile(), GetRoadStopDir(), GetRoadStopType(), IsDriveThroughRoadStopContinuation(), RoadStop::Entry::length, RoadStop::Entry::occupied, RSSFB_BASE_ENTRY, SetBit(), status, TILE_SIZE, TileOffsByDiagDir(), west, and xy.
Referenced by AfterLoadRoadStops(), and CmdBuildRoadStop().
FORCEINLINE void RoadStop::SetEntranceBusy | ( | bool | busy | ) | [inline] |
Makes an entrance occupied or free.
busy | if true, marks busy; free otherwise |
Definition at line 115 of file roadstop_base.h.
References RSSFB_ENTRY_BUSY, SB(), and status.
byte RoadStop::status |
Current status of the Stop,.
Definition at line 71 of file roadstop_base.h.
Referenced by AfterLoadRoadStops(), AllocateBay(), AllocateDriveThroughBay(), RoadStop::Entry::CheckIntegrity(), ClearDriveThrough(), FreeBay(), HasFreeBay(), IsEntranceBusy(), IsFreeBay(), MakeDriveThrough(), RoadStop::Entry::Rebuild(), and SetEntranceBusy().