2006-06-05 13:28:31 +02:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 17:11:33 +02:00
|
|
|
/** @file ship.h Base for ships. */
|
2007-04-04 03:35:16 +02:00
|
|
|
|
2006-09-28 20:42:35 +02:00
|
|
|
#ifndef SHIP_H
|
|
|
|
#define SHIP_H
|
|
|
|
|
2007-12-27 14:35:39 +01:00
|
|
|
#include "vehicle_base.h"
|
2008-03-31 02:17:39 +02:00
|
|
|
#include "engine_func.h"
|
2008-04-29 23:31:29 +02:00
|
|
|
#include "engine_base.h"
|
2007-12-21 22:50:46 +01:00
|
|
|
#include "economy_func.h"
|
2006-06-05 13:28:31 +02:00
|
|
|
|
2007-01-22 01:26:46 +01:00
|
|
|
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
2006-10-04 14:01:59 +02:00
|
|
|
void RecalcShipStuff(Vehicle *v);
|
2007-02-10 14:37:32 +01:00
|
|
|
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
|
2006-06-05 13:28:31 +02:00
|
|
|
|
2007-04-29 23:24:08 +02:00
|
|
|
/**
|
|
|
|
* This class 'wraps' Vehicle; you do not actually instantiate this class.
|
|
|
|
* You create a Vehicle using AllocateVehicle, so it is added to the pool
|
|
|
|
* and you reinitialize that to a Train using:
|
|
|
|
* v = new (v) Ship();
|
|
|
|
*
|
|
|
|
* As side-effect the vehicle type is set correctly.
|
|
|
|
*/
|
|
|
|
struct Ship: public Vehicle {
|
|
|
|
/** Initializes the Vehicle to a ship */
|
|
|
|
Ship() { this->type = VEH_SHIP; }
|
|
|
|
|
|
|
|
/** We want to 'destruct' the right class. */
|
2007-08-05 19:43:04 +02:00
|
|
|
virtual ~Ship() { this->PreDestructor(); }
|
2007-04-29 23:24:08 +02:00
|
|
|
|
2007-05-02 11:39:11 +02:00
|
|
|
const char *GetTypeString() const { return "ship"; }
|
2007-04-30 00:33:51 +02:00
|
|
|
void MarkDirty();
|
2007-05-01 18:35:14 +02:00
|
|
|
void UpdateDeltaXY(Direction direction);
|
2007-05-02 11:39:11 +02:00
|
|
|
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
|
2007-05-07 17:58:05 +02:00
|
|
|
void PlayLeaveStationSound() const;
|
2007-06-01 14:03:10 +02:00
|
|
|
bool IsPrimaryVehicle() const { return true; }
|
2008-04-21 22:50:58 +02:00
|
|
|
SpriteID GetImage(Direction direction) const;
|
2007-08-26 22:43:22 +02:00
|
|
|
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
|
2007-08-28 08:46:33 +02:00
|
|
|
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
|
2007-08-29 23:27:16 +02:00
|
|
|
Money GetRunningCost() const { return ShipVehInfo(this->engine_type)->running_cost * _price.ship_running; }
|
2008-04-24 15:05:51 +02:00
|
|
|
bool IsInDepot() const { return this->u.ship.state == TRACK_BIT_DEPOT; }
|
2007-07-01 21:24:54 +02:00
|
|
|
void Tick();
|
2008-02-01 23:02:14 +01:00
|
|
|
void OnNewDay();
|
2008-04-05 12:55:50 +02:00
|
|
|
TileIndex GetOrderStationLocation(StationID station);
|
2008-04-11 10:14:43 +02:00
|
|
|
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
|
2007-04-29 23:24:08 +02:00
|
|
|
};
|
|
|
|
|
2006-09-28 20:42:35 +02:00
|
|
|
#endif /* SHIP_H */
|