69static const uint RVC_DEFAULT_START_FRAME = 0;
70static const uint RVC_TURN_AROUND_START_FRAME = 1;
71static const uint RVC_DEPOT_START_FRAME = 6;
72static const uint RVC_START_FRAME_AFTER_LONG_TRAM = 21;
73static const uint RVC_TURN_AROUND_START_FRAME_SHORT_TRAM = 16;
75static const uint RVC_DRIVE_THROUGH_STOP_FRAME = 11;
76static const uint RVC_DEPOT_STOP_FRAME = 11;
85struct RoadVehPathElement {
89 constexpr RoadVehPathElement() {}
93using RoadVehPathCache = std::vector<RoadVehPathElement>;
102 uint16_t blocked_ctr = 0;
106 uint8_t reverse_ctr = 0;
128 bool Tick()
override;
131 uint
Crash(
bool flooded =
false)
override;
244 uint32_t coeff = RoadTypeIsTram(this->roadtype) ? 40 : 75;
298 const RoadVehicle *rv = this->
First();
Types/functions related to cargoes.
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
Direction
Defines the 8 directions on the map.
ExpensesType
Types of expenses.
@ EXPENSES_ROADVEH_RUN
Running costs road vehicles.
@ EXPENSES_ROADVEH_REVENUE
Revenue from road vehicles.
PoolID< uint16_t, struct EngineIDTag, 64000, 0xFFFF > EngineID
Unique identification number of an engine.
VehicleAccelerationModel
Acceleration model of a vehicle.
@ Normal
Default acceleration model.
Base class and functions for all vehicles that move through ground.
AccelStatus
What is the status of our acceleration?
@ AS_BRAKE
We want to stop.
@ AS_ACCEL
We want to go faster, if possible of course.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
#define Point
Macro that prevents name conflicts between included headers.
Functions for NewGRF engines.
@ PROP_ROADVEH_WEIGHT
Weight in 1/4 t.
@ PROP_ROADVEH_TRACTIVE_EFFORT
Tractive effort coefficient in 1/256.
@ PROP_ROADVEH_POWER
Power in 10 HP.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
RoadVehicleStates
Road vehicle states.
@ RVSB_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
@ RVS_ENTERED_STOP
Only set when a vehicle has entered the stop.
@ RVSB_IN_ROAD_STOP
The vehicle is in a road stop.
@ RVS_USING_SECOND_BAY
Only used while in a road stop.
@ RVSB_ROAD_STOP_TRACKDIR_MASK
Only bits 0 and 3 are used to encode the trackdir for road stops.
@ RVS_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
@ RVSB_TRACKDIR_MASK
The mask used to extract track dirs.
@ RVSB_DRIVE_SIDE
The vehicle is at the opposite side of the road.
@ RVS_IN_ROAD_STOP
The vehicle is in a road stop.
@ RVSB_IN_DEPOT
The vehicle is in a depot.
@ RVSB_WORMHOLE
The vehicle is in a tunnel and/or bridge.
@ RVS_DRIVE_SIDE
Only used when retrieving move data.
static const uint RDE_TURNED
We just finished turning.
static const uint8_t RV_OVERTAKE_TIMEOUT
The number of ticks a vehicle has for overtaking.
void GetRoadVehSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a road vehicle sprite heading west (used for lists).
void RoadVehUpdateCache(RoadVehicle *v, bool same_length=false)
Update the cache of a road vehicle.
static const uint RDE_NEXT_TILE
State information about the Road Vehicle controller.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo type.
Structure to return information about the closest depot location, and whether it could be found.
Base class for all vehicles that move through ground.
GroundVehicle(VehicleID index)
GroundVehicle< RoadVehicle, Type > GroundVehicleBase
GroundVehicleCache gcache
Element of the RoadVehPathCache.
Trackdir trackdir
Trackdir for this element.
TileIndex tile
Tile for this element.
Buses, trucks and trams belong to this class.
uint Crash(bool flooded=false) override
Common code executed for crashed ground vehicles.
uint8_t GetAirDragArea() const
Gets the area used for calculating air drag.
TileIndex GetOrderStationLocation(StationID station) override
Determine the location for the station where the vehicle goes to next.
void OnNewEconomyDay() override
Economy day handler.
int GetDisplaySpeed() const override
Gets the speed in km-ish/h that can be sent into string parameters for string processing.
VehicleAccelerationModel GetAccelerationType() const
Allows to know the acceleration type of a vehicle.
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a road vehicle image in the GUI.
uint32_t GetSlopeSteepness() const
Returns the slope steepness used by this vehicle.
uint16_t GetPower() const
Allows to know the power value that this vehicle will use.
Money GetRunningCost() const override
Gets the running cost of a vehicle.
bool IsPrimaryVehicle() const override
Whether this is the primary vehicle in the chain.
uint16_t GetMaxWeight() const override
Calculates the weight value that this vehicle will have when fully loaded with its current cargo.
uint16_t GetCurrentSpeed() const
Calculates the current speed of this vehicle.
RoadTypes compatible_roadtypes
NOSAVE: Roadtypes this consist is powered on.
ExpensesType GetExpenseType(bool income) const override
Sets the expense type associated to this vehicle type.
AccelStatus GetAccelerationStatus() const
Checks the current acceleration status of this vehicle.
void UpdateDeltaXY() override
Updates the x and y offsets and the size of the sprite used for this vehicle.
uint16_t crashed_ctr
Animation counter when the vehicle has crashed.
bool IsBus() const
Check whether a roadvehicle is a bus.
uint8_t overtaking_ctr
The length of the current overtake attempt.
void OnNewCalendarDay() override
Calander day handler.
uint16_t GetMaxTrackSpeed() const
Gets the maximum speed allowed by the track for this vehicle.
uint32_t GetRollingFriction() const
Returns the rolling friction coefficient of this vehicle.
uint8_t GetTractiveEffort() const
Allows to know the tractive effort value that this vehicle will use.
bool IsInDepot() const override
Check whether the vehicle is in the depot.
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const override
Gets the sprite to show for the given direction.
int GetDisplayMaxSpeed() const override
Gets the maximum speed in km-ish/h that can be sent into string parameters for string processing.
RoadVehPathCache path
Cached path.
Trackdir GetVehicleTrackdir() const override
Returns the Trackdir on which the vehicle is currently located.
bool TileMayHaveSlopedTrack() const
Checks if the vehicle is at a tile that can be sloped.
int GetCurrentMaxSpeed() const override
Calculates the maximum speed of the vehicle under its current conditions.
bool HasToUseGetSlopePixelZ()
Road vehicles have to use GetSlopePixelZ() to compute their height if they are reversing because in t...
RoadType roadtype
NOSAVE: Roadtype of this vehicle.
uint8_t overtaking
Set to RVSB_DRIVE_SIDE when overtaking, otherwise 0.
int UpdateSpeed()
This function looks at the vehicle and updates its speed (cur_speed and subspeed) variables.
uint16_t GetPoweredPartPower(const RoadVehicle *) const
Returns a value if this articulated part is powered.
bool Tick() override
Calls the tick handler of the vehicle.
VehicleID disaster_vehicle
NOSAVE: Disaster vehicle targetting this vehicle.
ClosestDepot FindClosestDepot() override
Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should...
uint16_t GetWeight() const
Allows to know the weight value that this vehicle will use.
~RoadVehicle() override
We want to 'destruct' the right class.
void MarkDirty() override
Marks the vehicles to be redrawn and updates cached variables.
uint8_t GetAirDrag() const
Gets the air drag coefficient of this vehicle.
T * Next() const
Get next vehicle in the chain.
RoadVehicle * First() const
Sprite sequence for a vehicle part.
EngineID engine_type
The type of engine used for this vehicle.
Direction direction
facing
VehicleCargoList cargo
The cargo this vehicle is carrying.
VehStates vehstatus
Status.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
CargoType cargo_type
type of cargo this vehicle is carrying
void PreDestructor()
Destroy all stuff that (still) needs the virtual functions to work properly.
VehicleCache vcache
Cache of often used vehicle values.
uint16_t cur_speed
current speed
bool IsFrontEngine() const
Check if the vehicle is a front engine.
TileIndex tile
Current tile index.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Different conversion functions from one kind of track to another.
bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
TrackBits
Allow incrementing of Track variables.
@ TRACK_BIT_Y
Y-axis track.
@ TRACK_BIT_X
X-axis track.
Trackdir
Enumeration for tracks and directions.
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
@ TRACKDIR_END
Used for iterations.
@ TRANSPORT_ROAD
Transport by road vehicle.
@ Stopped
Vehicle is stopped by the player.
EngineImageType
Visualisation contexts of vehicles and engines.
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF > VehicleID
The type all our vehicle IDs have.
@ VEH_ROAD
Road vehicle type.