All ships have this type. More...
#include <ship.h>
Public Member Functions | |
Ship () | |
We don't want GCC to zero our struct! It already is zeroed and has an index! | |
virtual | ~Ship () |
We want to 'destruct' the right class. | |
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. | |
void | PlayLeaveStationSound () const |
Play the sound associated with leaving the station. | |
bool | IsPrimaryVehicle () const |
Whether this is the primary vehicle in the chain. | |
SpriteID | GetImage (Direction direction, EngineImageType image_type) 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. | |
int | GetCurrentMaxSpeed () const |
Calculates the maximum speed of the vehicle under its current conditions. | |
Money | GetRunningCost () const |
Gets the running cost of a vehicle. | |
bool | IsInDepot () const |
Check whether the vehicle is in the depot. | |
bool | Tick () |
Calls the tick handler of the vehicle. | |
void | OnNewDay () |
Calls the new day handler of the vehicle. | |
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. | |
void | UpdateCache () |
Update the caches of this ship. | |
Data Fields | |
TrackBitsByte | state |
The "track" the ship is following. |
All ships have this type.
Definition at line 24 of file ship.h.
virtual Ship::~Ship | ( | ) | [inline, virtual] |
We want to 'destruct' the right class.
Definition at line 30 of file ship.h.
References Vehicle::PreDestructor().
bool Ship::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 729 of file ship_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index.
int Ship::GetCurrentMaxSpeed | ( | ) | const [inline, virtual] |
Calculates the maximum speed of the vehicle under its current conditions.
Reimplemented from Vehicle.
Definition at line 40 of file ship.h.
References VehicleCache::cached_max_speed, min(), and Vehicle::vcache.
int Ship::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 39 of file ship.h.
References VehicleCache::cached_max_speed, and Vehicle::vcache.
int Ship::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 38 of file ship.h.
References Vehicle::cur_speed.
ExpensesType Ship::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 34 of file ship.h.
References EXPENSES_SHIP_INC.
SpriteID Ship::GetImage | ( | Direction | direction, | |
EngineImageType | image_type | |||
) | const [virtual] |
Gets the sprite to show for the given direction.
direction | the direction the vehicle is facing |
Reimplemented from Vehicle.
Definition at line 114 of file ship_cmd.cpp.
References Vehicle::GetEngine(), and Engine::original_image_index.
TileIndex Ship::GetOrderStationLocation | ( | StationID | station | ) | [virtual] |
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 273 of file ship_cmd.cpp.
References Station::dock_tile, SpecializedVehicle< Ship, VEH_SHIP >::Get(), GetDockOffset(), Vehicle::IncrementRealOrderIndex(), INVALID_TILE, Vehicle::last_station_visited, TILE_ADD, and ToTileIndexDiff().
Money Ship::GetRunningCost | ( | ) | const [virtual] |
Gets the running cost of a vehicle.
Reimplemented from Vehicle.
Definition at line 204 of file ship_cmd.cpp.
References Vehicle::GetEngine(), Engine::GetGRF(), GetPrice(), and PROP_SHIP_RUNNING_COST_FACTOR.
Referenced by OnNewDay().
Trackdir Ship::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 237 of file ship_cmd.cpp.
References DiagDirToDiagTrackdir(), Vehicle::direction, DirToDiagDir(), FindFirstTrack(), GetShipDepotDirection(), IsInDepot(), state, TRACK_BIT_WORMHOLE, TrackDirectionToTrackdir(), Vehicle::vehstatus, and VS_CRASHED.
Referenced by NPFShipCheckReverse(), NPFShipChooseTrack(), OPFShipChooseTrack(), and YapfShipCheckReverse().
bool Ship::IsInDepot | ( | ) | const [inline, virtual] |
Check whether the vehicle is in the depot.
Reimplemented from Vehicle.
Definition at line 42 of file ship.h.
References state.
Referenced by GetVehicleTrackdir().
void Ship::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 254 of file ship_cmd.cpp.
References Vehicle::colourmap, UpdateCache(), and SpecializedVehicle< Ship, VEH_SHIP >::UpdateViewport().
bool Ship::Tick | ( | ) | [virtual] |
Calls the tick handler of the vehicle.
Reimplemented from Vehicle.
Definition at line 649 of file ship_cmd.cpp.
References Vehicle::running_ticks, Vehicle::vehstatus, and VS_STOPPED.
void Ship::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 286 of file ship_cmd.cpp.
References Vehicle::x_extent, Vehicle::x_offs, Vehicle::y_extent, Vehicle::y_offs, and Vehicle::z_extent.
Referenced by CmdBuildShip().