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;
93using RoadVehPathCache = std::vector<RoadVehPathElement>;
102 uint16_t blocked_ctr;
129 bool Tick()
override;
132 uint
Crash(
bool flooded =
false)
override;
245 uint32_t coeff = RoadTypeIsTram(this->roadtype) ? 40 : 75;
Types/functions related to cargoes.
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
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.
uint16_t EngineID
Unique identification number of an engine.
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.
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.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
RoadType
The different roadtypes we support.
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.
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.
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 ID.
Structure to return information about the closest depot location, and whether it could be found.
VehicleSettings vehicle
options for vehicles
uint16_t last_speed
The last speed we did display, so we only have to redraw when this changes.
Base class for all vehicles that move through ground.
GroundVehicleCache gcache
Cache of often calculated values.
Coordinates of a point in 2D.
Element of the RoadVehPathCache.
Trackdir trackdir
Trackdir for this element.
TileIndex tile
Tile for this element.
uint8_t air_drag
Coefficient of air drag.
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 SetDParam for string processing.
virtual ~RoadVehicle()
We want to 'destruct' the right class.
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
Calandar 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.
int GetAccelerationType() const
Allows to know the acceleration type of a 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 SetDParam 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.
RoadVehicle()
We don't want GCC to zero our struct! It already is zeroed and has an index!
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.
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.
T * First() const
Get the first vehicle in the chain.
uint16_t cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
uint8_t roadveh_slope_steepness
Steepness of hills for road vehicles when using realistic acceleration.
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.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
debug_inline bool IsFrontEngine() const
Check if the vehicle is a front engine.
void PreDestructor()
Destroy all stuff that (still) needs the virtual functions to work properly.
CargoID cargo_type
type of cargo this vehicle is carrying
VehicleCache vcache
Cache of often used vehicle values.
uint16_t cur_speed
current speed
TileIndex tile
Current tile index.
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.
@ VS_STOPPED
Vehicle is stopped by the player.
EngineImageType
Visualisation contexts of vehicles and engines.
@ VEH_ROAD
Road vehicle type.
uint32_t VehicleID
The type all our vehicle IDs have.
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.