OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
38 #include "table/strings.h"
61 static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D};
64 bool IsValidImageIndex<VEH_SHIP>(uint8 image_index)
66 return image_index <
lengthof(_ship_sprites);
77 uint8 spritenum = e->u.ship.image_index;
79 if (is_custom_sprite(spritenum)) {
80 GetCustomVehicleIcon(engine,
DIR_W, image_type, result);
86 assert(IsValidImageIndex<VEH_SHIP>(spritenum));
87 result->
Set(
DIR_W + _ship_sprites[spritenum]);
93 GetShipIcon(engine, image_type, &seq);
97 preferred_x =
Clamp(preferred_x,
116 GetShipIcon(engine, image_type, &seq);
121 width =
UnScaleGUI(rect.right - rect.left + 1);
122 height =
UnScaleGUI(rect.bottom - rect.top + 1);
134 GetCustomVehicleSprite(
this,
direction, image_type, result);
140 assert(IsValidImageIndex<VEH_SHIP>(
spritenum));
144 static const Depot *FindClosestShipDepot(
const Vehicle *v, uint max_distance)
147 const Depot *best_depot =
nullptr;
153 uint best_dist = max_distance == 0 ? UINT_MAX : max_distance + 1;
159 if (dist < best_dist) {
169 static void CheckIfShipNeedsService(
Vehicle *v)
181 default: NOT_REACHED();
184 const Depot *depot = FindClosestShipDepot(v, max_distance);
186 if (depot ==
nullptr) {
195 v->SetDestTile(depot->xy);
230 CheckVehicleBreakdown(
this);
232 CheckIfShipNeedsService(
this);
274 static void PlayShipSound(
const Vehicle *v)
277 SndPlayVehicleFx(ShipVehInfo(v->
engine_type)->sfx, v);
301 static const int8 _delta_xy_table[8][4] = {
313 const int8 *bb = _delta_xy_table[this->
rotation];
338 static bool CheckShipLeaveDepot(
Ship *v)
366 if (north_tracks && south_tracks) {
368 bool reverse =
false;
372 default: NOT_REACHED();
380 }
else if (south_tracks) {
403 static bool ShipAccelerate(
Vehicle *v)
420 if (spd == 0)
return false;
421 if ((
byte)++spd == 0)
return true;
425 return (t < v->progress);
436 if (!(st->had_vehicle_of_type &
HVOT_SHIP)) {
441 STR_NEWS_FIRST_SHIP_ARRIVAL,
465 bool path_found =
true;
476 if (!v->
path.empty()) {
479 if (
HasBit(tracks, track)) {
492 default: NOT_REACHED();
513 static const byte _ship_subcoord[4][6][3] = {
559 if ((v->
x_pos & 0xF) != 8 || (v->
y_pos & 0xF) != 8)
return 0;
582 if (dz == 0)
return false;
621 static void ShipController(
Ship *v)
640 if (CheckShipLeaveDepot(v))
return;
658 if (!ShipAccelerate(v))
return;
694 if ((gp.x & 0xF) == 8 && (gp.
y & 0xF) == 8) {
727 b = _ship_subcoord[diagdir][track];
729 gp.x = (gp.x & ~0xF) | b[0];
730 gp.
y = (gp.
y & ~0xF) | b[1];
778 if (!v->
path.empty()) v->
path.pop_front();
806 ShipController(
this);
845 v->
z_pos = GetSlopePixelZ(x, y);
862 _new_vehicle_id = v->
index;
891 const Depot *depot = FindClosestShipDepot(
this, 0);
893 if (depot ==
nullptr)
return false;
895 if (location !=
nullptr) *location = depot->xy;
896 if (destination !=
nullptr) *destination = depot->
index;
@ VSE_START
Vehicle starting, i.e. leaving, the station.
static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
Runs the pathfinder to choose a track to continue along.
static DiagDirection VehicleExitDir(Direction direction, TrackBits track)
Determine the side in which the vehicle will leave the tile.
virtual bool IsChainInDepot() const
Check whether the whole vehicle chain is in the depot.
StationFacility facilities
The facilities that this station has.
@ TRACK_BIT_WORMHOLE
Bitflag for a wormhole (used for tunnels)
bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event)
Checks whether a NewGRF wants to play a different vehicle sound effect.
uint32 TileIndex
The index/ID of a Tile.
NPFSettings npf
pathfinder settings for the new pathfinder
static int ShipTestUpDownOnLock(const Ship *v)
Test if a ship is in the centre of a lock and should move up or down.
#define TILE_ADD(x, y)
Adds to tiles together.
TileArea docking_station
Tile area the docking tiles cover.
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
void MakeDummy()
Makes this order a Dummy order.
Direction last_direction
Last direction we obtained sprites for.
@ TRACK_BIT_NONE
No track.
@ DIRDIFF_REVERSE
One direction is the opposite of the other one.
bool IsType(OrderType type) const
Check whether this order is of the given type.
static Titem * Get(size_t index)
Returns Titem with given index.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Direction
Defines the 8 directions on the map.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
VehicleSpriteSeq sprite_seq
Vehicle appearance.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
bool Tick()
Calls the tick handler of the vehicle.
Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift)
Determine a certain price.
@ NT_ARRIVAL_OTHER
First vehicle arrived for competitor.
@ DIRDIFF_45LEFT
Angle of 45 degrees left.
static Direction ChangeDir(Direction d, DirDiff delta)
Change a direction by a given difference.
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
@ ODTFB_SERVICE
This depot order is because of the servicing limit.
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...
static Vehicle * EnsureNoMovingShipProc(Vehicle *v, void *data)
Test-procedure for HasVehicleOnPos to check for any ships which are visible and not stopped by the pl...
bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Checks whether a vehicle is on a specific location.
void CheckOrders(const Vehicle *v)
Check the orders of a vehicle, to see if there are invalid orders and stuff.
uint16 reliability_spd_dec
Speed of reliability decay between services (per day).
void MakeLeaveStation()
Makes this order a Leave Station order.
Year _cur_year
Current year, starting at 0.
@ DIRDIFF_SAME
Both directions faces to the same direction.
byte y_extent
y-extent of vehicle bounding box
DestinationID GetDestination() const
Gets the destination of this order.
bool NeedsAutomaticServicing() const
Checks if the current order should be interrupted for a service-in-depot order.
void Set(SpriteID sprite)
Assign a single sprite to the sequence.
ShipPathCache path
Cached path.
byte random_bits
Bits used for determining which randomized variational spritegroups to use when drawing.
@ DIAGDIR_END
Used for iterations.
@ VPF_YAPF
Yet Another PathFinder.
@ VS_DEFPAL
Use default vehicle palette.
void PlayLeaveStationSound() const
Play the sound associated with leaving the station.
Tindex index
Index of this pool item.
static TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
void Free()
'Free' the order
bool YapfShipCheckReverse(const Ship *v)
Returns true if it is better to reverse the ship before leaving depot using YAPF.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
static int UnScaleGUI(int value)
Short-hand to apply GUI zoom level.
Direction rotation
Visible direction.
static Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
static bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
static const uint TILE_SIZE
Tile size in world coordinates.
static void AddVehicleNewsItem(StringID string, NewsType type, VehicleID vehicle, StationID station=INVALID_STATION)
Adds a newsitem referencing a vehicle.
byte running_ticks
Number of ticks this vehicle was not stopped this day.
static Station * Get(size_t index)
Gets station with given index.
static DirDiff DirDifference(Direction d0, Direction d1)
Calculate the difference between two directions.
void VehicleEnterDepot(Vehicle *v)
Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it,...
bool IsInDepot() const
Check whether the vehicle is in the depot.
@ MP_INDUSTRY
Part of an industry.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Date GetLifeLengthInDays() const
Returns the vehicle's (not model's!) life length in days.
EngineImageType
Visualisation contexts of vehicles and engines.
uint16 cur_speed
current speed
Defines the internal data of a functional industry.
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
void Draw(int x, int y, PaletteID default_pal, bool force_pal) const
Draw the sprite sequence.
Owner owner
Which company owns the vehicle?
uint16 cached_cargo_age_period
Number of ticks before carried cargo is aged.
@ DC_EXEC
execute the given command
static TrackBits GetAvailShipTracks(TileIndex tile, DiagDirection dir)
Get the available water tracks on a tile for a ship entering a tile.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
static DiagDirection GetShipDepotDirection(TileIndex t)
Get the direction of the ship depot.
DoCommandFlag
List of flags for a command.
void VehicleServiceInDepot(Vehicle *v)
Service a vehicle and all subsequent vehicles in the consist.
Station * neutral_station
Associated neutral station.
static TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
static uint TileX(TileIndex tile)
Get the X component of a tile.
static byte GetLockPart(TileIndex t)
Get the part of a lock.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type=ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action=ODATF_SERVICE_ONLY, CargoID cargo=CT_NO_REFIT)
Makes this order a Go To Depot order.
uint16 GetMaxSpeed() const
Get the maxmimum speed in km-ish/h a vehicle is allowed to reach on the way to the destination.
void UpdateCache()
Update the caches of this ship.
static TileIndex GetShipDepotNorthTile(TileIndex t)
Get the most northern tile of a ship depot.
const GRFFile * GetGRF() const
Retrieve the NewGRF the engine is tied to.
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting)
@ ENGINE_EXCLUSIVE_PREVIEW
This vehicle is in the exclusive preview stage, either being used or being offered to a company.
int16 rotation_y_pos
NOSAVE: Y Position before rotation.
void BeginLoading()
Prepare everything to begin the loading when arriving at a station.
PathfinderSettings pf
settings for all pathfinders
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
@ VS_HIDDEN
Vehicle is not visible.
uint16 EngineID
Unique identification number of an engine.
void UpdateVisualEffect(bool allow_power_change=true)
Update the cached visual effect.
bool IsValid() const
Check whether the sequence contains any sprites.
TileIndex dest_tile
Heading for this tile.
static DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
void HandlePathfindingResult(bool path_found)
Handle the pathfinding result, especially the lost status.
static Track TrackBitsToTrack(TrackBits tracks)
Converts TrackBits to Track.
static void NewEvent(CompanyID company, ScriptEvent *event)
Queue a new event for an AI.
Common return value for all commands.
Date _date
Current date in days (day counter)
@ WC_VEHICLE_VIEW
Vehicle view; Window numbers:
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
Track YapfShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, ShipPathCache &path_cache)
Finds the best path for given ship using YAPF.
static const int YAPF_TILE_LENGTH
Length (penalty) of one tile with YAPF.
void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cst)
Subtract money from a company, including the money fraction.
TileIndex tile
Current tile index.
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
void MarkDirty()
Marks the vehicles to be redrawn and updates cached variables.
@ EIT_ON_MAP
Vehicle drawn in viewport.
EngineID engine_type
The type of engine used for this vehicle.
@ VS_CRASHED
Vehicle is crashed.
static bool IsDiagonalTrack(Track track)
Checks if a given Track is diagonal.
@ VETS_CANNOT_ENTER
The vehicle cannot enter the tile.
Sprite sequence for a vehicle part.
StationID last_station_visited
The last station we stopped at.
@ PFE_GL_SHIPS
Time spent processing ships.
uint32 maximum_go_to_depot_penalty
What is the maximum penalty that may be endured for going to a depot.
static Track TrackToOppositeTrack(Track t)
Find the opposite track to a given track.
void OnNewDay()
Calls the new day handler of the vehicle.
uint GetOldAdvanceSpeed(uint speed)
Determines the effective direction-specific vehicle movement speed.
Order current_order
The current order (+ status, like: loading)
@ LOCK_PART_MIDDLE
Middle part of a lock.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ HVOT_SHIP
Station has seen a ship.
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.
@ WC_VEHICLE_DETAILS
Vehicle details; Window numbers:
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
@ VS_STOPPED
Vehicle is stopped by the player.
void ShowVisualEffect() const
Draw visual effects (smoke and/or sparks) for a vehicle chain.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
@ PROP_SHIP_CARGO_AGE_PERIOD
Number of ticks before carried cargo is aged.
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
VehicleEnterTileStatus VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y)
Call the tile callback function for a vehicle entering a tile.
static TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
TileIndex new_tile
Tile of the vehicle after moving.
uint16 reliability_spd_dec
Reliability decrease speed.
StationID last_loading_station
Last station the vehicle has stopped at and could possibly leave from with any cargo loaded.
static Direction DiagDirToDir(DiagDirection dir)
Convert a DiagDirection to a Direction.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
Money GetCost() const
The costs as made up to this moment.
static TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
@ WC_SHIPS_LIST
Ships list; Window numbers:
Money profit_this_year
Profit this year << 8, low 8 bits are fract.
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
fluid_settings_t * settings
FluidSynth settings handle.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
void UpdateDeltaXY()
Updates the x and y offsets and the size of the sprite used for this vehicle.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
DirDiff
Enumeration for the difference between two directions.
DiagDirection
Enumeration for diagonal directions.
void HandleLoading(bool mode=false)
Handle the loading of the vehicle; when not it skips through dummy orders and does nothing in all oth...
@ FACIL_DOCK
Station with a dock.
void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a ship sprite heading west (used for lists).
@ WATER_CLASS_CANAL
Canal.
uint16 vehicle_flags
Used for gradual loading and other miscellaneous things (.
MutableSpriteCache sprite_cache
Cache of sprites and values related to recalculating them, see MutableSpriteCache.
bool IsValidDockingDirectionForDock(TileIndex t, DiagDirection d)
Check if a dock tile can be docked from the given direction.
int8 y_offs
y offset for vehicle sprite
SpriteID colourmap
NOSAVE: cached colour mapping.
static DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
@ PROP_SHIP_RUNNING_COST_FACTOR
Yearly runningcost.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
void IncrementRealOrderIndex()
Advanced cur_real_order_index to the next real order, keeps care of the wrap-around and invalidates t...
@ VF_BUILT_AS_PROTOTYPE
Vehicle is a prototype (accepted as exclusive preview).
Trackdir GetVehicleTrackdir() const
Returns the Trackdir on which the vehicle is currently located.
@ RAIL_GROUND_WATER
Grass with a fence and shore or water on the free halftile.
Direction direction
facing
@ TRACK_BIT_DEPOT
Bitflag for a depot.
bool ProcessOrders(Vehicle *v)
Handle the orders of a vehicle and determine the next place to go to if needed.
static Direction ReverseDir(Direction d)
Return the reverse of a direction.
byte x_extent
x-extent of vehicle bounding box
static bool IsDockTile(TileIndex t)
Is tile t a dock tile?
VehicleCache vcache
Cache of often used vehicle values.
All ships have this type.
CompanyID _current_company
Company currently doing an action.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
bool IsShipDestinationTile(TileIndex tile, StationID station)
Test if a tile is a docking tile for the given station.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
byte tick_counter
Increased by one for each tick.
uint16 cargo_cap
total capacity
int8 x_offs
x offset for vehicle sprite
static DiagDirection DiagdirBetweenTiles(TileIndex tile_from, TileIndex tile_to)
Determines the DiagDirection to get from one tile to another.
@ DIRDIFF_45RIGHT
Angle of 45 degrees right.
byte z_extent
z-extent of vehicle bounding box
byte VehicleRandomBits()
Get a value for a vehicle's random_bits.
void InvalidateNewGRFCacheOfChain()
Invalidates cached NewGRF variables of all vehicles in the chain (after the current vehicle)
TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
uint32 PaletteID
The number of the palette.
bool NPFShipCheckReverse(const Ship *v)
Returns true if it is better to reverse the ship before leaving depot using NPF.
uint8 pathfinder_for_ships
the pathfinder to use for ships
uint32 current_order_time
How many ticks have passed since this order started.
@ TRANSPORT_WATER
Transport over water.
TrackBits state
The "track" the ship is following.
Position information of a vehicle after it moved.
@ WC_VEHICLE_DEPOT
Depot view; Window numbers:
CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **ret)
Build a ship.
@ MP_STATION
A tile of a station.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Year build_year
Year the vehicle has been built.
static const int NPF_TILE_LENGTH
Length (penalty) of one tile with NPF.
static bool IsLock(TileIndex t)
Is there a lock on a given water tile?
Information about a ship vehicle.
@ DIAGDIR_BEGIN
Used for iterations.
static const int DAYS_IN_YEAR
days per year
static Trackdir TrackDirectionToTrackdir(Track track, Direction dir)
Maps a track and a full (8-way) direction to the trackdir that represents the track running in the gi...
static Axis GetShipDepotAxis(TileIndex t)
Get the axis of the ship depot.
TileIndex xy
Base tile of the station.
uint16 cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
static Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
Track NPFShipChooseTrack(const Ship *v, bool &path_found)
Finds the best path for given ship using NPF.
static void ShipArrivesAt(const Vehicle *v, Station *st)
Ship arrives at a dock.
@ NT_ARRIVAL_COMPANY
First vehicle arrived for company.
uint8 original_image_index
Original vehicle image index, thus the image index of the overridden vehicle.
TileIndex old_tile
Current tile of the vehicle.
TrackBits
Bitfield corresponding to Track.
static bool IsDockingTile(TileIndex t)
Checks whether the tile is marked as a dockling tile.
byte day_counter
Increased by one for each day.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
#define lengthof(x)
Return the length of an fixed size array.
static bool ShipMoveUpDownOnLock(Ship *v)
Test and move a ship up or down in a lock.
YAPFSettings yapf
pathfinder settings for the yet another pathfinder
void AgeVehicle(Vehicle *v)
Update age of a vehicle.
byte progress
The percentage (if divided by 256) this vehicle already crossed the tile unit.
int16 rotation_x_pos
NOSAVE: X Position before rotation.
uint DetermineCapacity(const Vehicle *v, uint16 *mail_capacity=nullptr) const
Determines capacity of a given vehicle from scratch.
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
static bool IsOilRig(TileIndex t)
Is tile t part of an oilrig?
Axis
Allow incrementing of DiagDirDiff variables.
Money GetRunningCost() const
Gets the running cost of a vehicle.
CargoID cargo_type
type of cargo this vehicle is carrying
byte spritenum
currently displayed sprite index 0xfd == custom sprite, 0xfe == custom second head sprite 0xff == res...
uint16 max_speed
Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
Trackdir
Enumeration for tracks and directions.
@ PROP_SHIP_SPEED
Max. speed: 1 unit = 1/3.2 mph = 0.5 km-ish/h.
uint32 maximum_go_to_depot_penalty
What is the maximum penalty that may be endured for going to a depot.
VehicleType type
Type of vehicle.
uint16 reliability
Reliability.
void UpdatePosition()
Update the position of the vehicle.
byte flags
Flags of the engine.
@ INVALID_DIR
Flag for an invalid direction.
Track
These are used to specify a single track.
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
Can this station be used by the given engine type?
bool HandleBreakdown()
Handle all of the aspects of a vehicle breakdown This includes adding smoke and sounds,...
void DecreaseVehicleValue(Vehicle *v)
Decrease the value of a vehicle.
int y
x and y position of the vehicle after moving
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
@ VEH_SHIP
Ship vehicle type.
static bool IsShipDepotTile(TileIndex t)
Is it a ship depot tile?
Specification of a rectangle with absolute coordinates of all edges.
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
void GetBounds(Rect *bounds) const
Determine shared bounds of all sprites.
uint ApplyWaterClassSpeedFrac(uint raw_speed, bool is_ocean) const
Apply ocean/canal speed fraction to a velocity.
void UpdateViewport(bool force_update, bool update_delta)
Update vehicle sprite- and position caches.
WaterClass GetEffectiveWaterClass(TileIndex tile)
Determine the effective WaterClass for a ship travelling on a tile.
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
@ EXPENSES_SHIP_RUN
Running costs ships.
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
static Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
uint16 reliability
Current reliability of the engine.
bool Contains(TileIndex tile) const
Does this tile area contain a tile?
uint16 refit_cap
Capacity left over from before last refit.
static DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
Date date_of_last_service
Last date the vehicle had a service at a depot.
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v)
Get position information of a vehicle when moving one pixel in the direction it is facing.
@ VETS_ENTERED_WORMHOLE
The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/...
@ INVALID_TRACK
Flag for an invalid track.