src/ship.h
branchnoai
changeset 9701 d1ac22c62f64
parent 9694 e72987579514
child 9723 eee46cb39750
equal deleted inserted replaced
9700:e442ce398e83 9701:d1ac22c62f64
     4 
     4 
     5 #ifndef SHIP_H
     5 #ifndef SHIP_H
     6 #define SHIP_H
     6 #define SHIP_H
     7 
     7 
     8 #include "vehicle.h"
     8 #include "vehicle.h"
       
     9 #include "engine.h"
       
    10 #include "variables.h"
     9 
    11 
    10 void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
    12 void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
    11 void CcCloneShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
       
    12 void RecalcShipStuff(Vehicle *v);
    13 void RecalcShipStuff(Vehicle *v);
    13 void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
    14 void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
    14 
       
    15 static inline bool IsShipInDepot(const Vehicle *v)
       
    16 {
       
    17 	assert(v->type == VEH_SHIP);
       
    18 	return v->u.ship.state == 0x80;
       
    19 }
       
    20 
       
    21 static inline bool IsShipInDepotStopped(const Vehicle *v)
       
    22 {
       
    23 	return IsShipInDepot(v) && v->vehstatus & VS_STOPPED;
       
    24 }
       
    25 
       
    26 
    15 
    27 /**
    16 /**
    28  * This class 'wraps' Vehicle; you do not actually instantiate this class.
    17  * This class 'wraps' Vehicle; you do not actually instantiate this class.
    29  * You create a Vehicle using AllocateVehicle, so it is added to the pool
    18  * You create a Vehicle using AllocateVehicle, so it is added to the pool
    30  * and you reinitialize that to a Train using:
    19  * and you reinitialize that to a Train using:
    35 struct Ship: public Vehicle {
    24 struct Ship: public Vehicle {
    36 	/** Initializes the Vehicle to a ship */
    25 	/** Initializes the Vehicle to a ship */
    37 	Ship() { this->type = VEH_SHIP; }
    26 	Ship() { this->type = VEH_SHIP; }
    38 
    27 
    39 	/** We want to 'destruct' the right class. */
    28 	/** We want to 'destruct' the right class. */
    40 	virtual ~Ship() {}
    29 	virtual ~Ship() { this->PreDestructor(); }
    41 
    30 
    42 	const char *GetTypeString() const { return "ship"; }
    31 	const char *GetTypeString() const { return "ship"; }
    43 	void MarkDirty();
    32 	void MarkDirty();
    44 	void UpdateDeltaXY(Direction direction);
    33 	void UpdateDeltaXY(Direction direction);
    45 	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
    34 	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
    46 	WindowClass GetVehicleListWindowClass() const { return WC_SHIPS_LIST; }
    35 	WindowClass GetVehicleListWindowClass() const { return WC_SHIPS_LIST; }
    47 	void PlayLeaveStationSound() const;
    36 	void PlayLeaveStationSound() const;
    48 	bool IsPrimaryVehicle() const { return true; }
    37 	bool IsPrimaryVehicle() const { return true; }
    49 	int GetImage(Direction direction) const;
    38 	int GetImage(Direction direction) const;
       
    39 	int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
       
    40 	int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
       
    41 	Money GetRunningCost() const { return ShipVehInfo(this->engine_type)->running_cost * _price.ship_running; }
       
    42 	bool IsInDepot() const { return this->u.ship.state == 0x80; }
    50 	void Tick();
    43 	void Tick();
    51 };
    44 };
    52 
    45 
    53 #endif /* SHIP_H */
    46 #endif /* SHIP_H */