|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
69 static const uint RVC_DEFAULT_START_FRAME = 0;
70 static const uint RVC_TURN_AROUND_START_FRAME = 1;
71 static const uint RVC_DEPOT_START_FRAME = 6;
72 static const uint RVC_START_FRAME_AFTER_LONG_TRAM = 21;
73 static const uint RVC_TURN_AROUND_START_FRAME_SHORT_TRAM = 16;
75 static const uint RVC_DRIVE_THROUGH_STOP_FRAME = 11;
76 static const uint RVC_DEPOT_STOP_FRAME = 11;
85 std::deque<Trackdir> td;
86 std::deque<TileIndex> tile;
88 inline bool empty()
const {
return this->td.empty(); }
90 inline size_t size()
const
92 assert(this->td.size() == this->tile.size());
93 return this->td.size();
110 uint16_t blocked_ctr;
136 bool Tick()
override;
139 uint
Crash(
bool flooded =
false)
override;
252 uint32_t 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.
debug_inline bool IsFrontEngine() const
Check if the vehicle is a front engine.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
@ EXPENSES_ROADVEH_RUN
Running costs road vehicles.
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...
@ PROP_ROADVEH_TRACTIVE_EFFORT
Tractive effort coefficient in 1/256.
uint16_t GetPoweredPartPower(const RoadVehicle *) const
Returns a value if this articulated part is powered.
AccelStatus GetAccelerationStatus() const
Checks the current acceleration status of this vehicle.
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.
@ 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.
uint32_t GetSlopeSteepness() const
Returns the slope steepness used by this vehicle.
byte overtaking_ctr
The length of the current overtake attempt.
int GetAccelerationType() const
Allows to know the acceleration type of a vehicle.
static const uint RDE_TURNED
We just finished turning.
@ 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.
@ RVS_USING_SECOND_BAY
Only used while in a road stop.
void UpdateDeltaXY() override
Updates the x and y offsets and the size of the sprite used for this vehicle.
RoadVehicleStates
Road vehicle states.
uint16_t last_speed
The last speed we did display, so we only have to redraw when this changes.
@ 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.
virtual void GetImage([[maybe_unused]] Direction direction, [[maybe_unused]] EngineImageType image_type, [[maybe_unused]] VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.
uint16_t cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
byte GetAirDrag() const
Gets the air drag coefficient of this vehicle.
uint16_t GetMaxWeight() const override
Calculates the weight value that this vehicle will have when fully loaded with its current cargo.
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.
RoadVehicle()
We don't want GCC to zero our struct! It already is zeroed and has an index!
RoadTypes
The different roadtypes we support, but then a bitmask of them.
TileIndex tile
Current tile index.
Money GetRunningCost() const override
Gets the running cost of a vehicle.
EngineID engine_type
The type of engine used for this vehicle.
int GetDisplayMaxSpeed() const override
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
Sprite sequence for a vehicle part.
VehicleCargoList cargo
The cargo this vehicle is carrying.
GroundVehicleCache gcache
Cache of often calculated values.
virtual ExpensesType GetExpenseType([[maybe_unused]] bool income) const
Sets the expense type associated to this vehicle type.
bool IsInDepot() const override
Check whether the vehicle is in the depot.
@ RVSB_TRACKDIR_MASK
The mask used to extract track dirs.
uint16_t cur_speed
current speed
uint8_t air_drag
Coefficient of air drag.
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.
int GetCurrentMaxSpeed() const override
Calculates the maximum speed of the vehicle under its current conditions.
@ VS_STOPPED
Vehicle is stopped by the player.
uint Crash(bool flooded=false) override
Crash the (whole) vehicle chain.
@ TRACK_BIT_X
X-axis track.
@ RVSB_DRIVE_SIDE
The vehicle is at the opposite side of the road.
bool Tick() override
Calls the tick handler of the vehicle.
@ RVS_IN_ROAD_STOP
The vehicle is in a road stop.
RoadTypes compatible_roadtypes
Roadtypes this consist is powered on.
void MarkDirty() override
Marks the vehicles to be redrawn and updates cached variables.
Coordinates of a point in 2D.
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
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.
Direction direction
facing
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
uint16_t GetWeight() const
Allows to know the weight value that this vehicle will use.
byte GetTractiveEffort() const
Allows to know the tractive effort value that this vehicle will use.
VehicleCache vcache
Cache of often used vehicle values.
void OnNewCalendarDay() override
Calandar day handler.
void RoadVehUpdateCache(RoadVehicle *v, bool same_length=false)
Update the cache of a road vehicle.
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a road vehicle image in the GUI.
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).
Base class for all vehicles that move through ground.
@ TRACKDIR_END
Used for iterations.
RoadType
The different roadtypes we support.
bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
Structure to return information about the closest depot location, and whether it could be found.
byte GetAirDragArea() const
Gets the area used for calculating air drag.
TrackBits
Allow incrementing of Track variables.
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
uint16_t GetPower() const
Allows to know the power value that this vehicle will use.
@ RVSB_WORMHOLE
The vehicle is in a tunnel and/or bridge.
ClosestDepot FindClosestDepot() override
Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should...
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.
@ TRANSPORT_ROAD
Transport by road vehicle.
CargoID cargo_type
type of cargo this vehicle is carrying
uint32_t GetRollingFriction() const
Returns the rolling friction coefficient of this vehicle.
uint16_t crashed_ctr
Animation counter when the vehicle has crashed.
@ RVS_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
@ TRACK_BIT_Y
Y-axis track.
VehicleSettings vehicle
options for vehicles
uint16_t EngineID
Unique identification number of an engine.
Trackdir
Enumeration for tracks and directions.
@ PROP_ROADVEH_POWER
Power in 10 HP.
virtual TileIndex GetOrderStationLocation([[maybe_unused]] StationID station)
Determine the location for the station where the vehicle goes to next.
uint16_t GetMaxTrackSpeed() const
Gets the maximum speed allowed by the track for this vehicle.
bool IsPrimaryVehicle() const override
Whether this is the primary vehicle in the chain.
RoadVehicle * First() const
Get the first vehicle in the chain.
@ AS_BRAKE
We want to stop.
ExpensesType
Types of expenses.
@ RVSB_IN_DEPOT
The vehicle is in a depot.
uint8_t roadveh_slope_steepness
Steepness of hills for road vehicles when using realistic acceleration.
@ EXPENSES_ROADVEH_REVENUE
Revenue from road vehicles.
uint16_t GetCurrentSpeed() const
Calculates the current speed of this vehicle.
AccelStatus
What is the status of our acceleration?
@ 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.