Buses, trucks and trams belong to this class. More...
#include <roadveh.h>
Public Member Functions | |
RoadVehicle () | |
We don't want GCC to zero our struct! It already is zeroed and has an index! | |
virtual | ~RoadVehicle () |
We want to 'destruct' the right class. | |
const char * | GetTypeString () const |
Get a string 'representation' of the vehicle type. | |
void | MarkDirty () |
Marks the vehicles to be redrawn and updates cached variables. | |
void | UpdateDeltaXY (Direction direction) |
Updates the x and y offsets and the size of the sprite used for 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. | |
SpriteID | GetImage (Direction direction) const |
Gets the sprite to show for the given direction. | |
int | GetDisplaySpeed () const |
Gets the speed in km-ish/h that can be sent into SetDParam for string processing. | |
int | GetDisplayMaxSpeed () const |
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing. | |
Money | GetRunningCost () const |
Gets the running cost of a vehicle. | |
int | GetDisplayImageWidth (Point *offset=NULL) const |
Get the width of a road vehicle image in the GUI. | |
bool | IsInDepot () const |
Check whether the vehicle is in the depot. | |
bool | IsStoppedInDepot () const |
Check whether the vehicle is in the depot *and* stopped. | |
bool | Tick () |
Calls the tick handler of the vehicle. | |
void | OnNewDay () |
Calls the new day handler of the vehicle. | |
uint | Crash (bool flooded=false) |
Crash the (whole) vehicle chain. | |
Trackdir | GetVehicleTrackdir () const |
Returns the Trackdir on which the vehicle is currently located. | |
TileIndex | GetOrderStationLocation (StationID station) |
Determine the location for the station where the vehicle goes to next. | |
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 reverse. | |
bool | IsBus () const |
Check whether a roadvehicle is a bus. | |
int | GetCurrentMaxSpeed () const |
Calculates the maximum speed of the vehicle under its current conditions. | |
Data Fields | |
byte | state |
byte | frame |
uint16 | blocked_ctr |
byte | overtaking |
byte | overtaking_ctr |
uint16 | crashed_ctr |
byte | reverse_ctr |
RoadType | roadtype |
RoadTypes | compatible_roadtypes |
Protected Member Functions | |
FORCEINLINE uint16 | GetPower () const |
Allows to know the power value that this vehicle will use. | |
FORCEINLINE uint16 | GetPoweredPartPower (const RoadVehicle *head) const |
Returns a value if this articulated part is powered. | |
FORCEINLINE uint16 | GetWeight () const |
Allows to know the weight value that this vehicle will use. | |
FORCEINLINE byte | GetTractiveEffort () const |
Allows to know the tractive effort value that this vehicle will use. | |
FORCEINLINE byte | GetAirDragArea () const |
Gets the area used for calculating air drag. | |
FORCEINLINE byte | GetAirDrag () const |
Gets the air drag coefficient of this vehicle. | |
FORCEINLINE AccelStatus | GetAccelerationStatus () const |
Checks the current acceleration status of this vehicle. | |
FORCEINLINE uint16 | GetCurrentSpeed () const |
Calculates the current speed of this vehicle. | |
FORCEINLINE uint32 | GetRollingFriction () const |
Returns the rolling friction coefficient of this vehicle. | |
FORCEINLINE int | GetAccelerationType () const |
Allows to know the acceleration type of a vehicle. | |
FORCEINLINE uint32 | GetSlopeSteepness () const |
Returns the slope steepness used by this vehicle. | |
FORCEINLINE uint16 | GetMaxTrackSpeed () const |
Gets the maximum speed allowed by the track for this vehicle. | |
FORCEINLINE bool | TileMayHaveSlopedTrack () const |
Checks if the vehicle is at a tile that can be sloped. | |
Friends | |
struct | GroundVehicle< RoadVehicle, VEH_ROAD > |
Buses, trucks and trams belong to this class.
Definition at line 83 of file roadveh.h.
virtual RoadVehicle::~RoadVehicle | ( | ) | [inline, virtual] |
We want to 'destruct' the right class.
Definition at line 98 of file roadveh.h.
References Vehicle::PreDestructor().
uint RoadVehicle::Crash | ( | bool | flooded = false |
) | [virtual] |
Crash the (whole) vehicle chain.
flooded | whether the cause of the crash is flooding or not. |
Reimplemented from Vehicle.
Definition at line 461 of file roadveh_cmd.cpp.
References RoadStop::GetByTile(), GetRoadStopType(), GroundVehicle< RoadVehicle, VEH_ROAD >::IsFrontEngine(), IsInsideMM(), RoadStop::Leave(), RVSB_IN_DT_ROAD_STOP, state, and Vehicle::tile.
Referenced by DisasterTick_Ufo().
bool RoadVehicle::FindClosestDepot | ( | TileIndex * | location, | |
DestinationID * | destination, | |||
bool * | reverse | |||
) | [virtual] |
Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should reverse.
location | where do we go to? | |
destination | what hangar do we go to? | |
reverse | should the vehicle be reversed? |
Reimplemented from Vehicle.
Definition at line 307 of file roadveh_cmd.cpp.
References FindDepotData::best_length, GetDepotIndex(), and FindDepotData::tile.
FORCEINLINE AccelStatus RoadVehicle::GetAccelerationStatus | ( | ) | const [inline, protected] |
Checks the current acceleration status of this vehicle.
Definition at line 199 of file roadveh.h.
References AS_ACCEL, AS_BRAKE, Vehicle::vehstatus, and VS_STOPPED.
FORCEINLINE int RoadVehicle::GetAccelerationType | ( | ) | const [inline, protected] |
FORCEINLINE byte RoadVehicle::GetAirDrag | ( | ) | const [inline, protected] |
FORCEINLINE byte RoadVehicle::GetAirDragArea | ( | ) | const [inline, protected] |
FORCEINLINE int RoadVehicle::GetCurrentMaxSpeed | ( | ) | const |
Calculates the maximum speed of the vehicle under its current conditions.
Definition at line 390 of file roadveh_cmd.cpp.
References _settings_game, VehicleCache::cached_max_speed, IsReversingRoadTrackdir(), VehicleSettings::roadveh_acceleration_model, RVSB_TRACKDIR_MASK, state, Vehicle::vcache, and GameSettings::vehicle.
Referenced by RoadVehAccelerate().
FORCEINLINE uint16 RoadVehicle::GetCurrentSpeed | ( | ) | const [inline, protected] |
Calculates the current speed of this vehicle.
Definition at line 208 of file roadveh.h.
References Vehicle::cur_speed.
Referenced by GetRollingFriction().
int RoadVehicle::GetDisplayImageWidth | ( | Point * | offset = NULL |
) | const |
Get the width of a road vehicle image in the GUI.
offset | Additional offset for positioning the sprite; set to NULL if not needed |
Definition at line 97 of file roadveh_cmd.cpp.
References GroundVehicleCache::cached_veh_length, and GroundVehicle< RoadVehicle, VEH_ROAD >::gcache.
int RoadVehicle::GetDisplayMaxSpeed | ( | ) | const [inline, virtual] |
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
Reimplemented from Vehicle.
Definition at line 109 of file roadveh.h.
References VehicleCache::cached_max_speed, and Vehicle::vcache.
Referenced by CYapfCostRoadT< Types >::PfCalcCost().
int RoadVehicle::GetDisplaySpeed | ( | ) | const [inline, virtual] |
Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
Reimplemented from Vehicle.
Definition at line 108 of file roadveh.h.
References Vehicle::cur_speed.
ExpensesType RoadVehicle::GetExpenseType | ( | bool | income | ) | const [inline, virtual] |
Sets the expense type associated to this vehicle type.
income | whether this is income or (running) expenses of the vehicle |
Reimplemented from Vehicle.
Definition at line 105 of file roadveh.h.
References EXPENSES_ROADVEH_INC, and EXPENSES_ROADVEH_RUN.
Gets the sprite to show for the given direction.
direction | the direction the vehicle is facing |
Reimplemented from Vehicle.
Definition at line 123 of file roadveh_cmd.cpp.
References Vehicle::cargo, Vehicle::cargo_cap, CargoList< Tinst >::Count(), and SpecializedVehicle< RoadVehicle, Type >::Get().
FORCEINLINE uint16 RoadVehicle::GetMaxTrackSpeed | ( | ) | const [inline, protected] |
Determine the location for the station where the vehicle goes to next.
Things done for example are allocating slots in a road stop or exact location of the platform is determined for ships.
station | the station to make the next location of the vehicle. |
Reimplemented from Vehicle.
Definition at line 512 of file roadveh_cmd.cpp.
References CanVehicleUseStation(), SpecializedVehicle< RoadVehicle, Type >::Get(), Vehicle::IncrementOrderIndex(), and BaseStation::xy.
Referenced by RemoveRoadStop().
FORCEINLINE uint16 RoadVehicle::GetPower | ( | ) | const [inline, protected] |
Allows to know the power value that this vehicle will use.
Definition at line 131 of file roadveh.h.
References GroundVehicle< RoadVehicle, VEH_ROAD >::IsArticulatedPart(), and PROP_ROADVEH_POWER.
FORCEINLINE uint16 RoadVehicle::GetPoweredPartPower | ( | const RoadVehicle * | head | ) | const [inline, protected] |
FORCEINLINE uint32 RoadVehicle::GetRollingFriction | ( | ) | const [inline, protected] |
Returns the rolling friction coefficient of this vehicle.
Definition at line 217 of file roadveh.h.
References GetCurrentSpeed(), and ROADTYPE_TRAM.
Money RoadVehicle::GetRunningCost | ( | ) | const [virtual] |
Gets the running cost of a vehicle.
Reimplemented from Vehicle.
Definition at line 1515 of file roadveh_cmd.cpp.
References SpecializedVehicle< RoadVehicle, Type >::Get(), GetPrice(), Engine::grf_prop, GRFFilePropsBase< Tcnt >::grffile, and PROP_ROADVEH_RUNNING_COST_FACTOR.
Referenced by OnNewDay().
FORCEINLINE uint32 RoadVehicle::GetSlopeSteepness | ( | ) | const [inline, protected] |
Returns the slope steepness used by this vehicle.
Definition at line 240 of file roadveh.h.
References _settings_game, VehicleSettings::roadveh_slope_steepness, and GameSettings::vehicle.
FORCEINLINE byte RoadVehicle::GetTractiveEffort | ( | ) | const [inline, protected] |
Allows to know the tractive effort value that this vehicle will use.
Definition at line 171 of file roadveh.h.
References PROP_ROADVEH_TRACTIVE_EFFORT.
const char* RoadVehicle::GetTypeString | ( | ) | const [inline, virtual] |
Trackdir RoadVehicle::GetVehicleTrackdir | ( | ) | const [virtual] |
Returns the Trackdir on which the vehicle is currently located.
Works for trains and ships. Currently works only sortof for road vehicles, since they have a fuzzy concept of being "on" a trackdir. Dunno really what it returns for a road vehicle that is halfway a tile, never really understood that part. For road vehicles that are at the beginning or end of the tile, should just return the diagonal trackdir on which they are driving. I _think_. For other vehicles types, or vehicles with no clear trackdir (such as those in depots), returns 0xFF.
Reimplemented from Vehicle.
Definition at line 1603 of file roadveh_cmd.cpp.
References DiagDirToDiagTrackdir(), Vehicle::direction, DirToDiagDir(), GetRoadDepotDirection(), GetRoadStopDir(), INVALID_TRACKDIR, IsInDepot(), IsReversingRoadTrackdir(), IsStandardRoadStopTile(), RVSB_TRACKDIR_MASK, state, Vehicle::vehstatus, and VS_CRASHED.
Referenced by NPFRoadVehicleFindNearestDepot(), CYapfFollowRoadT< Types >::SetOriginFromVehiclePos(), and YapfRoadVehicleFindNearestDepot().
FORCEINLINE uint16 RoadVehicle::GetWeight | ( | ) | const [inline, protected] |
Allows to know the weight value that this vehicle will use.
Definition at line 154 of file roadveh.h.
References Vehicle::cargo, Vehicle::cargo_type, CargoList< Tinst >::Count(), SpecializedVehicle< RoadVehicle, Type >::Get(), GroundVehicle< RoadVehicle, VEH_ROAD >::IsArticulatedPart(), and PROP_ROADVEH_WEIGHT.
bool RoadVehicle::IsBus | ( | ) | const |
Check whether a roadvehicle is a bus.
Definition at line 86 of file roadveh_cmd.cpp.
References Vehicle::cargo_type, CC_PASSENGERS, IsCargoInClass(), and GroundVehicle< RoadVehicle, VEH_ROAD >::IsFrontEngine().
Referenced by CmdCloneOrder(), NetworkPopulateCompanyStats(), RoadFindPathToDest(), and RoadVehArrivesAt().
bool RoadVehicle::IsInDepot | ( | ) | const [inline, virtual] |
Check whether the vehicle is in the depot.
Reimplemented from Vehicle.
Definition at line 112 of file roadveh.h.
References RVSB_IN_DEPOT, and state.
Referenced by CmdTurnRoadVeh(), and GetVehicleTrackdir().
bool RoadVehicle::IsStoppedInDepot | ( | ) | const [virtual] |
Check whether the vehicle is in the depot *and* stopped.
Reimplemented from Vehicle.
Definition at line 282 of file roadveh_cmd.cpp.
References GroundVehicle< RoadVehicle, VEH_ROAD >::IsFrontEngine(), IsRoadDepotTile(), SpecializedVehicle< T, Type >::Next(), RVSB_IN_DEPOT, state, Vehicle::tile, Vehicle::vehstatus, and VS_STOPPED.
void RoadVehicle::MarkDirty | ( | ) | [virtual] |
Marks the vehicles to be redrawn and updates cached variables.
This method marks the area of the vehicle on the screen as dirty. It can be use to repaint the vehicle.
Reimplemented from Vehicle.
Definition at line 355 of file roadveh_cmd.cpp.
References GroundVehicle< RoadVehicle, VEH_ROAD >::CargoChanged(), SpecializedVehicle< T, Type >::Next(), and SpecializedVehicle< T, Type >::UpdateViewport().
bool RoadVehicle::Tick | ( | ) | [virtual] |
Calls the tick handler of the vehicle.
Reimplemented from Vehicle.
Definition at line 1526 of file roadveh_cmd.cpp.
References GroundVehicle< RoadVehicle, VEH_ROAD >::IsFrontEngine(), Vehicle::running_ticks, Vehicle::vehstatus, and VS_STOPPED.
FORCEINLINE bool RoadVehicle::TileMayHaveSlopedTrack | ( | ) | const [inline, protected] |
Checks if the vehicle is at a tile that can be sloped.
Definition at line 258 of file roadveh.h.
References GetTileTrackStatus(), Vehicle::tile, TRACK_BIT_X, TRACK_BIT_Y, TrackStatusToTrackBits(), and TRANSPORT_ROAD.
void RoadVehicle::UpdateDeltaXY | ( | Direction | direction | ) | [virtual] |
Updates the x and y offsets and the size of the sprite used for this vehicle.
direction | the direction the vehicle is facing |
Reimplemented from Vehicle.
Definition at line 363 of file roadveh_cmd.cpp.
References GB(), Vehicle::x_extent, Vehicle::x_offs, Vehicle::y_extent, Vehicle::y_offs, and Vehicle::z_extent.
byte RoadVehicle::state |
Definition at line 84 of file roadveh.h.
Referenced by CmdBuildRoadVehicle(), CmdTurnRoadVeh(), Crash(), RoadStop::Enter(), FindVehiclesInRoadStop(), GetCurrentMaxSpeed(), GetVehicleTrackdir(), IsInDepot(), IsStoppedInDepot(), RoadStop::Leave(), Vehicle::PreDestructor(), and RoadVehAccelerate().