Handling of ships. More...
#include "stdafx.h"
#include "ship.h"
#include "landscape.h"
#include "timetable.h"
#include "command_func.h"
#include "news_func.h"
#include "company_func.h"
#include "pathfinder/npf/npf_func.h"
#include "depot_base.h"
#include "station_base.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "pathfinder/yapf/yapf.h"
#include "newgrf_sound.h"
#include "spritecache.h"
#include "strings_func.h"
#include "functions.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 "landscape_type.h"
#include "engine_base.h"
#include "company_base.h"
#include "table/strings.h"
Go to the source code of this file.
Defines | |
#define | MKIT(a, b, c, d) ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | ((d & 0xFF) << 0) |
Functions | |
static TrackBits | GetTileShipTrackStatus (TileIndex tile) |
static SpriteID | GetShipIcon (EngineID engine) |
void | DrawShipEngine (int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal) |
void | GetShipSpriteSize (EngineID engine, uint &width, uint &height) |
Get the size of the sprite of a ship sprite heading west (used for lists). | |
static const Depot * | FindClosestShipDepot (const Vehicle *v, uint max_distance) |
static void | CheckIfShipNeedsService (Vehicle *v) |
static void | PlayShipSound (const Vehicle *v) |
static void | 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) |
returns the track to choose on the next tile, or -1 when it's better to reverse. | |
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] |
Handling of ships.
Definition in file ship_cmd.cpp.
static Track ChooseShipTrack | ( | Ship * | v, | |
TileIndex | tile, | |||
DiagDirection | enterdir, | |||
TrackBits | tracks | |||
) | [static] |
returns the track to choose on the next tile, or -1 when it's better to reverse.
The tile given is the tile we are about to enter, enterdir is the direction in which we are entering the tile
Definition at line 356 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 | |||
) |
Build a ship.
tile | tile of the depot where ship is built. | |
flags | type of operation. | |
e | the engine to build. | |
data | unused. | |
ret[out] | the vehicle that has been built. |
Definition at line 589 of file ship_cmd.cpp.
References _cur_year, _current_company, _date, Vehicle::cargo_cap, Vehicle::cargo_type, Vehicle::cur_image, DC_EXEC, Vehicle::direction, ENGINE_EXCLUSIVE_PREVIEW, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Engine::GetDefaultCargoType(), Engine::GetLifeLengthInDays(), GetShipDepotNorthTile(), GetVehicleCapacity(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::InvalidateNewGRFCacheOfChain(), Vehicle::max_age, Vehicle::owner, Vehicle::reliability, Vehicle::reliability_spd_dec, SetBit(), Vehicle::spritenum, Vehicle::tile, TILE_SIZE, TileX(), TileY(), TRACK_BIT_DEPOT, Ship::UpdateDeltaXY(), Vehicle::vehicle_flags, VehicleMove(), VehicleRandomBits(), Vehicle::vehstatus, VF_BUILT_AS_PROTOTYPE, VS_DEFPAL, VS_HIDDEN, VS_STOPPED, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by CmdBuildVehicle().
void GetShipSpriteSize | ( | EngineID | engine, | |
uint & | width, | |||
uint & | height | |||
) |
Get the size of the sprite of a ship sprite heading west (used for lists).
engine | The engine to get the sprite from | |
width | The width of the sprite | |
height | The height of the sprite |
Definition at line 77 of file ship_cmd.cpp.
References Sprite::height, ST_NORMAL, and Sprite::width.
Ship arrives at a dock.
If it is the first time, send out a news item.
Definition at line 333 of file ship_cmd.cpp.
References _local_company, AddVehicleNewsItem(), HVOT_SHIP, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, AI::NewEvent(), NS_ARRIVAL_COMPANY, NS_ARRIVAL_OTHER, Vehicle::owner, and SetDParam().
const Direction _new_vehicle_direction_table[] [static] |
const TileIndexDiffC _ship_leave_depot_offs[] [static] |
{ {-1, 0}, { 0, -1} }
Definition at line 267 of file ship_cmd.cpp.