2006-06-05 12:28:31 +01:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 16:11:33 +01:00
|
|
|
/** @file ship.h Base for ships. */
|
2007-04-04 02:35:16 +01:00
|
|
|
|
2006-09-28 19:42:35 +01:00
|
|
|
#ifndef SHIP_H
|
|
|
|
#define SHIP_H
|
|
|
|
|
2007-12-27 13:35:39 +00:00
|
|
|
#include "vehicle_base.h"
|
2008-03-31 01:17:39 +01:00
|
|
|
#include "engine_func.h"
|
2008-04-29 22:31:29 +01:00
|
|
|
#include "engine_base.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "economy_func.h"
|
2006-06-05 12:28:31 +01:00
|
|
|
|
2007-01-22 00:26:46 +00:00
|
|
|
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
2006-10-04 13:01:59 +01:00
|
|
|
void RecalcShipStuff(Vehicle *v);
|
2007-02-10 13:37:32 +00:00
|
|
|
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
|
2006-06-05 12:28:31 +01:00
|
|
|
|
2007-04-29 22:24:08 +01:00
|
|
|
/**
|
2009-05-27 00:24:34 +01:00
|
|
|
* All ships have this type.
|
2007-04-29 22:24:08 +01:00
|
|
|
*/
|
2009-05-26 23:10:13 +01:00
|
|
|
struct Ship: public SpecializedVehicle<Ship, VEH_SHIP> {
|
2009-05-22 19:17:20 +01:00
|
|
|
TrackBitsByte state;
|
|
|
|
|
2009-06-02 20:12:28 +01:00
|
|
|
/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
|
|
|
|
Ship() : SpecializedVehicle<Ship, VEH_SHIP>() {}
|
2007-04-29 22:24:08 +01:00
|
|
|
/** We want to 'destruct' the right class. */
|
2007-08-05 18:43:04 +01:00
|
|
|
virtual ~Ship() { this->PreDestructor(); }
|
2007-04-29 22:24:08 +01:00
|
|
|
|
2007-05-02 10:39:11 +01:00
|
|
|
const char *GetTypeString() const { return "ship"; }
|
2007-04-29 23:33:51 +01:00
|
|
|
void MarkDirty();
|
2007-05-01 17:35:14 +01:00
|
|
|
void UpdateDeltaXY(Direction direction);
|
2007-05-02 10:39:11 +01:00
|
|
|
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
|
2007-05-07 16:58:05 +01:00
|
|
|
void PlayLeaveStationSound() const;
|
2007-06-01 13:03:10 +01:00
|
|
|
bool IsPrimaryVehicle() const { return true; }
|
2008-04-21 21:50:58 +01:00
|
|
|
SpriteID GetImage(Direction direction) const;
|
2009-02-01 17:14:39 +00:00
|
|
|
int GetDisplaySpeed() const { return this->cur_speed / 2; }
|
|
|
|
int GetDisplayMaxSpeed() const { return this->max_speed / 2; }
|
2009-01-22 21:33:08 +00:00
|
|
|
Money GetRunningCost() const;
|
2009-05-22 19:17:20 +01:00
|
|
|
bool IsInDepot() const { return this->state == TRACK_BIT_DEPOT; }
|
2009-05-22 14:53:14 +01:00
|
|
|
bool Tick();
|
2008-02-01 22:02:14 +00:00
|
|
|
void OnNewDay();
|
2009-05-22 19:17:20 +01:00
|
|
|
Trackdir GetVehicleTrackdir() const;
|
2008-04-05 11:55:50 +01:00
|
|
|
TileIndex GetOrderStationLocation(StationID station);
|
2008-04-11 09:14:43 +01:00
|
|
|
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
|
2007-04-29 22:24:08 +01:00
|
|
|
};
|
|
|
|
|
2009-05-26 23:45:48 +01:00
|
|
|
#define FOR_ALL_SHIPS(var) FOR_ALL_VEHICLES_OF_TYPE(Ship, var)
|
|
|
|
|
2006-09-28 19:42:35 +01:00
|
|
|
#endif /* SHIP_H */
|