70 static const uint RVC_DEFAULT_START_FRAME = 0;
71 static const uint RVC_TURN_AROUND_START_FRAME = 1;
72 static const uint RVC_DEPOT_START_FRAME = 6;
73 static const uint RVC_START_FRAME_AFTER_LONG_TRAM = 21;
74 static const uint RVC_TURN_AROUND_START_FRAME_SHORT_TRAM = 16;
76 static const uint RVC_DRIVE_THROUGH_STOP_FRAME = 11;
77 static const uint RVC_DEPOT_STOP_FRAME = 11;
86 std::deque<Trackdir> td;
87 std::deque<TileIndex> tile;
89 inline bool empty()
const {
return this->td.empty(); }
91 inline size_t size()
const 93 assert(this->td.size() == this->tile.size());
94 return this->td.size();
135 int GetDisplayImageWidth(
Point *offset =
nullptr)
const;
139 uint
Crash(
bool flooded =
false);
246 uint32 coeff = RoadTypeIsTram(this->roadtype) ? 40 : 75;
249 return coeff * (128 + this->GetCurrentSpeed()) / 128;
300 const RoadVehicle *rv = this->
First();
314 if (this->direction != rv->
direction)
return true;
VehicleSettings vehicle
options for vehicles
Vehicle is stopped by the player.
VehicleCargoList cargo
The cargo this vehicle is carrying.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Functions for NewGRF engines.
virtual void MarkDirty()
Marks the vehicles to be redrawn and updates cached variables.
Direction direction
facing
uint8 weight
Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
AccelStatus
What is the status of our acceleration?
static const uint RDE_TURNED
We just finished turning.
static bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
uint16 GetPower() const
Allows to know the power value that this vehicle will use.
The vehicle is at the opposite side of the road.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
The vehicle is in a drive-through road stop.
AccelStatus GetAccelerationStatus() const
Checks the current acceleration status of this vehicle.
Trackdir
Enumeration for tracks and directions.
uint16 cur_speed
current speed
int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
bool TileMayHaveSlopedTrack() const
Checks if the vehicle is at a tile that can be sloped.
RoadVehicle()
We don't want GCC to zero our struct! It already is zeroed and has an index!
static const uint RDE_NEXT_TILE
State information about the Road Vehicle controller.
Only used when retrieving move data.
ExpensesType GetExpenseType(bool income) const
Sets the expense type associated to this vehicle type.
virtual void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.
uint32 GetSlopeSteepness() const
Returns the slope steepness used by this vehicle.
T * First() const
Get the first vehicle in the chain.
RoadType
The different roadtypes we support.
uint16 GetMaxTrackSpeed() const
Gets the maximum speed allowed by the track for this vehicle.
EngineImageType
Visualisation contexts of vehicles and engines.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
byte overtaking
Set to RVSB_DRIVE_SIDE when overtaking, otherwise 0.
uint16 cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
RoadVehicleStates
Road vehicle states.
Buses, trucks and trams belong to this class.
RoadType roadtype
Roadtype of this vehicle.
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
The vehicle is in a road stop.
virtual bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse)
Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should...
The vehicle is in a tunnel and/or bridge.
T * Next() const
Get next vehicle in the chain.
byte GetAirDragArea() const
Gets the area used for calculating air drag.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
Direction
Defines the 8 directions on the map.
Only used while in a road stop.
virtual int GetCurrentMaxSpeed() const
Calculates the maximum speed of the vehicle under its current conditions.
The vehicle is in a depot.
CargoID cargo_type
type of cargo this vehicle is carrying
TrackBits
Bitfield corresponding to Track.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
TileIndex tile
Current tile index.
uint16 max_speed
Maximum speed for vehicles travelling on this road type.
virtual void UpdateDeltaXY()
Updates the x and y offsets and the size of the sprite used for this vehicle.
bool HasToUseGetSlopePixelZ()
Road vehicles have to use GetSlopePixelZ() to compute their height if they are reversing because in t...
uint16 GetPoweredPartPower(const RoadVehicle *head) const
Returns a value if this articulated part is powered.
virtual ~RoadVehicle()
We want to 'destruct' the right class.
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
Sprite sequence for a vehicle part.
byte GetTractiveEffort() const
Allows to know the tractive effort value that this vehicle will use.
We want to go faster, if possible of course.
uint16 crashed_ctr
Animation counter when the vehicle has crashed.
byte GetAirDrag() const
Gets the air drag coefficient of this vehicle.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
bool IsInDepot() const
Check whether the vehicle is in the depot.
uint16 last_speed
The last speed we did display, so we only have to redraw when this changes.
virtual Money GetRunningCost() const
Gets the running cost of a vehicle.
static const byte RV_OVERTAKE_TIMEOUT
The number of ticks a vehicle has for overtaking.
The vehicle is in a drive-through road stop.
uint Crash(bool flooded) override
Common code executed for crashed ground vehicles.
static void OnNewDay()
Runs various procedures that have to be done daily.
int GetAccelerationType() const
Allows to know the acceleration type of a vehicle.
Only bits 0 and 3 are used to encode the trackdir for road stops.
void RoadVehUpdateCache(RoadVehicle *v, bool same_length=false)
Update the cache of a road vehicle.
uint32 GetRollingFriction() const
Returns the rolling friction coefficient of this vehicle.
uint16 EngineID
Unique identification number of an engine.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
uint32 TileIndex
The index/ID of a Tile.
Only set when a vehicle has entered the stop.
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
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).
Transport by road vehicle.
The vehicle is in a road stop.
RoadTypes compatible_roadtypes
Roadtypes this consist is powered on.
Types/functions related to cargoes.
Coordinates of a point in 2D.
The mask used to extract track dirs.
Tractive effort coefficient in 1/256.
virtual Trackdir GetVehicleTrackdir() const
Returns the Trackdir on which the vehicle is currently located.
RoadVehPathCache path
Cached path.
EngineID engine_type
The type of engine used for this vehicle.
virtual bool Tick()
Calls the tick handler of the vehicle.
uint8 roadveh_slope_steepness
Steepness of hills for road vehicles when using realistic acceleration.
Income from road vehicles.
bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
Different conversion functions from one kind of track to another.
int GetDisplaySpeed() const
Gets the speed in km-ish/h that can be sent into SetDParam for string processing. ...
Base class for all vehicles that move through ground.
Running costs road vehicles.
VehicleCache vcache
Cache of often used vehicle values.
ExpensesType
Types of expenses.
Base class and functions for all vehicles that move through ground.
GroundVehicleCache gcache
Cache of often calculated values.
byte overtaking_ctr
The length of the current overtake attempt.
uint16 GetCurrentSpeed() const
Calculates the current speed of this vehicle.
uint16 GetWeight() const
Allows to know the weight value that this vehicle will use.