src/ship.h
author richk
Tue, 17 Jun 2008 13:41:57 +0000
branchNewGRF_ports
changeset 10995 311b38c7f9a7
parent 10724 68a692eacf22
permissions -rw-r--r--
(svn r13549) [NewGRF_ports] -Change: Make recolouring of groundtile (0x0f80) specific to NewGRF_ports only.
Also base groundsprite on airport_tile of station. This prevents mixed colour groundtiles in an airport.
3962
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
     1
/* $Id$ */
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
     2
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10200
diff changeset
     3
/** @file ship.h Base for ships. */
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
     4
4666
850b5b6e4bac (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 4638
diff changeset
     5
#ifndef SHIP_H
850b5b6e4bac (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 4638
diff changeset
     6
#define SHIP_H
850b5b6e4bac (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 4638
diff changeset
     7
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6868
diff changeset
     8
#include "vehicle_base.h"
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6877
diff changeset
     9
#include "engine_func.h"
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10200
diff changeset
    10
#include "engine_base.h"
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6868
diff changeset
    11
#include "economy_func.h"
3962
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    12
6034
89a7d10fa75b (svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents: 5726
diff changeset
    13
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
4725
f7284b86833f (svn r6637) -Codechange: merged all (vehicle type)EnterDepot into VehicleEnterDepot()
bjarni
parents: 4666
diff changeset
    14
void RecalcShipStuff(Vehicle *v);
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6034
diff changeset
    15
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
3962
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    16
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    17
/**
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    18
 * This class 'wraps' Vehicle; you do not actually instantiate this class.
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    19
 * You create a Vehicle using AllocateVehicle, so it is added to the pool
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    20
 * and you reinitialize that to a Train using:
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    21
 *   v = new (v) Ship();
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    22
 *
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    23
 * As side-effect the vehicle type is set correctly.
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    24
 */
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    25
struct Ship: public Vehicle {
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    26
	/** Initializes the Vehicle to a ship */
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    27
	Ship() { this->type = VEH_SHIP; }
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    28
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    29
	/** We want to 'destruct' the right class. */
6800
6c09e1e86fcb (svn r10872) [NewGRF_ports] -Sync: with trunk r10765:10871.
rubidium
parents: 6743
diff changeset
    30
	virtual ~Ship() { this->PreDestructor(); }
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    31
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    32
	const char *GetTypeString() const { return "ship"; }
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    33
	void MarkDirty();
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    34
	void UpdateDeltaXY(Direction direction);
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    35
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    36
	void PlayLeaveStationSound() const;
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    37
	bool IsPrimaryVehicle() const { return true; }
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10200
diff changeset
    38
	SpriteID GetImage(Direction direction) const;
6868
7eb395287b3d (svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents: 6800
diff changeset
    39
	int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
7eb395287b3d (svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents: 6800
diff changeset
    40
	int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
7eb395287b3d (svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents: 6800
diff changeset
    41
	Money GetRunningCost() const { return ShipVehInfo(this->engine_type)->running_cost * _price.ship_running; }
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10200
diff changeset
    42
	bool IsInDepot() const { return this->u.ship.state == TRACK_BIT_DEPOT; }
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
    43
	void Tick();
6877
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
    44
	void OnNewDay();
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6877
diff changeset
    45
	TileIndex GetOrderStationLocation(StationID station);
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10184
diff changeset
    46
	bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    47
};
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6585
diff changeset
    48
4666
850b5b6e4bac (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 4638
diff changeset
    49
#endif /* SHIP_H */