Functions | Variables

ship_cmd.cpp File Reference

Handling of ships. More...

#include "stdafx.h"
#include "ship.h"
#include "landscape.h"
#include "timetable.h"
#include "news_func.h"
#include "company_func.h"
#include "pathfinder/npf/npf_func.h"
#include "depot_base.h"
#include "station_base.h"
#include "newgrf_engine.h"
#include "pathfinder/yapf/yapf.h"
#include "newgrf_sound.h"
#include "spritecache.h"
#include "strings_func.h"
#include "window_func.h"
#include "date_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
#include "ai/ai.hpp"
#include "pathfinder/opf/opf_ship.h"
#include "engine_base.h"
#include "company_base.h"
#include "tunnelbridge_map.h"
#include "zoom_func.h"
#include "table/strings.h"

Go to the source code of this file.

Functions

WaterClass GetEffectiveWaterClass (TileIndex tile)
 Determine the effective WaterClass for a ship travelling on a tile.
template<>
bool IsValidImageIndex< VEH_SHIP > (uint8 image_index)
static TrackBits GetTileShipTrackStatus (TileIndex tile)
static SpriteID GetShipIcon (EngineID engine, EngineImageType image_type)
void DrawShipEngine (int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
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).
static const DepotFindClosestShipDepot (const Vehicle *v, uint max_distance)
static void CheckIfShipNeedsService (Vehicle *v)
static void PlayShipSound (const Vehicle *v)
static bool CheckShipLeaveDepot (Ship *v)
static bool ShipAccelerate (Vehicle *v)
static void ShipArrivesAt (const Vehicle *v, Station *st)
 Ship arrives at a dock.
static Track ChooseShipTrack (Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 Runs the pathfinder to choose a track to continue along.
static Direction ShipGetNewDirectionFromTiles (TileIndex new_tile, TileIndex old_tile)
static Direction ShipGetNewDirection (Vehicle *v, int x, int y)
static TrackBits GetAvailShipTracks (TileIndex tile, DiagDirection dir)
static void ShipController (Ship *v)
CommandCost CmdBuildShip (TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **ret)
 Build a ship.

Variables

static const uint16 _ship_sprites [] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D}
static const TileIndexDiffC _ship_leave_depot_offs []
static const Direction _new_vehicle_direction_table []
static const byte _ship_subcoord [4][6][3]

Detailed Description

Handling of ships.

Definition in file ship_cmd.cpp.


Function Documentation

static Track ChooseShipTrack ( Ship v,
TileIndex  tile,
DiagDirection  enterdir,
TrackBits  tracks 
) [static]

Runs the pathfinder to choose a track to continue along.

Parameters:
v Ship to navigate
tile Tile, the ship is about to enter
enterdir Direction of entering
tracks Available track choices on tile
Returns:
Track to choose, or INVALID_TRACK when to reverse.

Definition at line 430 of file ship_cmd.cpp.

References _settings_game, Vehicle::HandlePathfindingResult(), IsValidDiagDirection(), NPFShipChooseTrack(), OPFShipChooseTrack(), PathfinderSettings::pathfinder_for_ships, GameSettings::pf, VPF_NPF, VPF_OPF, VPF_YAPF, and YapfShipChooseTrack().

CommandCost CmdBuildShip ( TileIndex  tile,
DoCommandFlag  flags,
const Engine e,
uint16  data,
Vehicle **  ret 
)
WaterClass GetEffectiveWaterClass ( TileIndex  tile  ) 

Determine the effective WaterClass for a ship travelling on a tile.

Parameters:
tile Tile of interest
Returns:
the waterclass to be used by the ship.

Definition at line 44 of file ship_cmd.cpp.

References GetTunnelBridgeTransportType(), GetWaterClass(), HasTileWaterClass(), IsTileType(), MP_RAILWAY, MP_TUNNELBRIDGE, RAIL_GROUND_WATER, and TRANSPORT_WATER.

Referenced by CYapfCostShipT< Types >::PfCalcCost(), and Ship::UpdateCache().

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).

Parameters:
engine The engine to get the sprite from.
[out] width The width of the sprite.
[out] height The height of the sprite.
[out] xoffs Number of pixels to shift the sprite to the right.
[out] yoffs Number of pixels to shift the sprite downwards.
image_type Context the sprite is used in.

Definition at line 104 of file ship_cmd.cpp.

References Sprite::height, ST_NORMAL, UnScaleByZoom(), Sprite::width, Sprite::x_offs, Sprite::y_offs, and ZOOM_LVL_GUI.

static void ShipArrivesAt ( const Vehicle v,
Station st 
) [static]

Ship arrives at a dock.

If it is the first time, send out a news item.

Parameters:
v Ship that arrived.
st Station being visited.

Definition at line 403 of file ship_cmd.cpp.

References _local_company, AddVehicleNewsItem(), HVOT_SHIP, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, AI::NewEvent(), NT_ARRIVAL_COMPANY, NT_ARRIVAL_OTHER, Vehicle::owner, and SetDParam().


Variable Documentation

const Direction _new_vehicle_direction_table[] [static]
Initial value:
 {
  DIR_N , DIR_NW, DIR_W , INVALID_DIR,
  DIR_NE, DIR_N , DIR_SW, INVALID_DIR,
  DIR_E , DIR_SE, DIR_S
}

Definition at line 447 of file ship_cmd.cpp.

const TileIndexDiffC _ship_leave_depot_offs[] [static]
Initial value:
 {
  {-1,  0},
  { 0, -1}
}

Definition at line 308 of file ship_cmd.cpp.