OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
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();
139 uint
Crash(
bool flooded =
false);
246 uint32 coeff = RoadTypeIsTram(this->roadtype) ? 40 : 75;
byte overtaking
Set to RVSB_DRIVE_SIDE when overtaking, otherwise 0.
Buses, trucks and trams belong to this class.
virtual ~RoadVehicle()
We want to 'destruct' the right class.
uint32 TileIndex
The index/ID of a Tile.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
int GetDisplaySpeed() const
Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
uint32 GetRollingFriction() const
Returns the rolling friction coefficient of this vehicle.
@ EXPENSES_ROADVEH_RUN
Running costs road vehicles.
uint8 roadveh_slope_steepness
Steepness of hills for road vehicles when using realistic acceleration.
void PreDestructor()
Destroy all stuff that (still) needs the virtual functions to work properly.
Direction
Defines the 8 directions on the map.
bool HasToUseGetSlopePixelZ()
Road vehicles have to use GetSlopePixelZ() to compute their height if they are reversing because in t...
uint16 GetMaxTrackSpeed() const
Gets the maximum speed allowed by the track for this vehicle.
@ PROP_ROADVEH_TRACTIVE_EFFORT
Tractive effort coefficient in 1/256.
AccelStatus GetAccelerationStatus() const
Checks the current acceleration status of this vehicle.
ExpensesType GetExpenseType(bool income) const
Sets the expense type associated to this vehicle type.
bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
T * Next() const
Get next vehicle in the chain.
int UpdateSpeed()
This function looks at the vehicle and updates its speed (cur_speed and subspeed) variables.
static const uint RDE_NEXT_TILE
State information about the Road Vehicle controller.
void OnNewDay()
Calls the new day handler of the vehicle.
@ RVSB_IN_ROAD_STOP
The vehicle is in a road stop.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
RoadVehPathCache path
Cached path.
Money GetRunningCost() const
Gets the running cost of a vehicle.
byte overtaking_ctr
The length of the current overtake attempt.
int GetAccelerationType() const
Allows to know the acceleration type of a vehicle.
uint16 last_speed
The last speed we did display, so we only have to redraw when this changes.
static const uint RDE_TURNED
We just finished turning.
int GetCurrentMaxSpeed() const
Calculates the maximum speed of the vehicle under its current conditions.
@ AS_ACCEL
We want to go faster, if possible of course.
RoadType roadtype
Roadtype of this vehicle.
EngineImageType
Visualisation contexts of vehicles and engines.
@ VEH_ROAD
Road vehicle type.
TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
uint16 cur_speed
current speed
@ RVS_USING_SECOND_BAY
Only used while in a road stop.
uint16 GetWeight() const
Allows to know the weight value that this vehicle will use.
RoadVehicleStates
Road vehicle states.
@ RVSB_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
@ RVS_DRIVE_SIDE
Only used when retrieving move data.
@ TRANSPORT_ROAD
Transport by road vehicle.
byte GetAirDrag() const
Gets the air drag coefficient of this vehicle.
uint16 EngineID
Unique identification number of an engine.
RoadVehicle()
We don't want GCC to zero our struct! It already is zeroed and has an index!
uint32 GetSlopeSteepness() const
Returns the slope steepness used by this vehicle.
TileIndex tile
Current tile index.
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
uint16 GetPoweredPartPower(const RoadVehicle *head) const
Returns a value if this articulated part is powered.
EngineID engine_type
The type of engine used for this vehicle.
Sprite sequence for a vehicle part.
VehicleCargoList cargo
The cargo this vehicle is carrying.
GroundVehicleCache gcache
Cache of often calculated values.
@ RVSB_TRACKDIR_MASK
The mask used to extract track dirs.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ RVS_ENTERED_STOP
Only set when a vehicle has entered the stop.
@ VS_STOPPED
Vehicle is stopped by the player.
bool Tick()
Calls the tick handler of the vehicle.
@ TRACK_BIT_X
X-axis track.
@ RVSB_DRIVE_SIDE
The vehicle is at the opposite side of the road.
uint8 weight
Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
@ RVS_IN_ROAD_STOP
The vehicle is in a road stop.
RoadTypes compatible_roadtypes
Roadtypes this consist is powered on.
Coordinates of a point in 2D.
void MarkDirty()
Marks the vehicles to be redrawn and updates cached variables.
RoadType
The different roadtypes we support.
uint Crash(bool flooded=false)
Crash the (whole) vehicle chain.
bool TileMayHaveSlopedTrack() const
Checks if the vehicle is at a tile that can be sloped.
Direction direction
facing
byte GetTractiveEffort() const
Allows to know the tractive effort value that this vehicle will use.
VehicleCache vcache
Cache of often used vehicle values.
void RoadVehUpdateCache(RoadVehicle *v, bool same_length=false)
Update the cache of a road vehicle.
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...
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a road vehicle image in the GUI.
void UpdateDeltaXY()
Updates the x and y offsets and the size of the sprite used for this vehicle.
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).
bool IsInDepot() const
Check whether the vehicle is in the depot.
Base class for all vehicles that move through ground.
@ TRACKDIR_END
Used for iterations.
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
uint16 crashed_ctr
Animation counter when the vehicle has crashed.
uint16 cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
uint16 GetCurrentSpeed() const
Calculates the current speed of this vehicle.
byte GetAirDragArea() const
Gets the area used for calculating air drag.
TrackBits
Bitfield corresponding to Track.
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.
@ RVSB_WORMHOLE
The vehicle is in a tunnel and/or bridge.
uint16 max_speed
Maximum speed for vehicles travelling on this road type.
static const byte RV_OVERTAKE_TIMEOUT
The number of ticks a vehicle has for overtaking.
bool IsBus() const
Check whether a roadvehicle is a bus.
CargoID cargo_type
type of cargo this vehicle is carrying
@ RVS_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
@ TRACK_BIT_Y
Y-axis track.
static bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
VehicleSettings vehicle
options for vehicles
Trackdir
Enumeration for tracks and directions.
uint16 GetPower() const
Allows to know the power value that this vehicle will use.
@ PROP_ROADVEH_POWER
Power in 10 HP.
RoadVehicle * First() const
Get the first vehicle in the chain.
@ AS_BRAKE
We want to stop.
ExpensesType
Types of expenses.
@ EXPENSES_ROADVEH_INC
Income from road vehicles.
@ RVSB_IN_DEPOT
The vehicle is in a depot.
AccelStatus
What is the status of our acceleration?
Trackdir GetVehicleTrackdir() const
Returns the Trackdir on which the vehicle is currently located.
@ RVSB_ROAD_STOP_TRACKDIR_MASK
Only bits 0 and 3 are used to encode the trackdir for road stops.
@ PROP_ROADVEH_WEIGHT
Weight in 1/4 t.