author | smatz |
Sat, 13 Dec 2008 15:59:25 +0000 | |
changeset 10416 | b35c0a4c73c5 |
parent 9111 | 48ce04029fe4 |
permissions | -rw-r--r-- |
3962 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
9070
diff
changeset
|
3 |
/** @file ship.h Base for ships. */ |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6259
diff
changeset
|
4 |
|
4666
172a0cdf28a6
(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 |
172a0cdf28a6
(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 |
172a0cdf28a6
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4638
diff
changeset
|
7 |
|
8144
65cec0877b78
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8116
diff
changeset
|
8 |
#include "vehicle_base.h" |
8786
1823ff88a054
(svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium
parents:
8467
diff
changeset
|
9 |
#include "engine_func.h" |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9045
diff
changeset
|
10 |
#include "engine_base.h" |
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
7490
diff
changeset
|
11 |
#include "economy_func.h" |
3962 | 12 |
|
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5475
diff
changeset
|
13 |
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2); |
4725
40cccaaa042c
(svn r6637) -Codechange: merged all (vehicle type)EnterDepot into VehicleEnterDepot()
bjarni
parents:
4666
diff
changeset
|
14 |
void RecalcShipStuff(Vehicle *v); |
5972
59953719a3ff
(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:
5783
diff
changeset
|
15 |
void GetShipSpriteSize(EngineID engine, uint &width, uint &height); |
3962 | 16 |
|
6552
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
17 |
/** |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
18 |
* This class 'wraps' Vehicle; you do not actually instantiate this class. |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
19 |
* You create a Vehicle using AllocateVehicle, so it is added to the pool |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
20 |
* and you reinitialize that to a Train using: |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
21 |
* v = new (v) Ship(); |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
22 |
* |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
23 |
* As side-effect the vehicle type is set correctly. |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
24 |
*/ |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
25 |
struct Ship: public Vehicle { |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
26 |
/** Initializes the Vehicle to a ship */ |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
27 |
Ship() { this->type = VEH_SHIP; } |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
28 |
|
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
29 |
/** We want to 'destruct' the right class. */ |
7412
51db351a3313
(svn r10798) -Fix [FS#1105]: virtual functions do not work in destructors :(.
rubidium
parents:
7318
diff
changeset
|
30 |
virtual ~Ship() { this->PreDestructor(); } |
6552
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
31 |
|
6563
fed2a162046b
(svn r9765) -Codechange: constify some class functions.
rubidium
parents:
6562
diff
changeset
|
32 |
const char *GetTypeString() const { return "ship"; } |
6553
976a684212ad
(svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents:
6552
diff
changeset
|
33 |
void MarkDirty(); |
6558
c88e142f896e
(svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents:
6553
diff
changeset
|
34 |
void UpdateDeltaXY(Direction direction); |
6563
fed2a162046b
(svn r9765) -Codechange: constify some class functions.
rubidium
parents:
6562
diff
changeset
|
35 |
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; } |
6593
102aa05c5ca4
(svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents:
6563
diff
changeset
|
36 |
void PlayLeaveStationSound() const; |
6773
bc98b0b16ec4
(svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents:
6593
diff
changeset
|
37 |
bool IsPrimaryVehicle() const { return true; } |
9022
8fa9e902b06e
(svn r12824) -Codechange: Standardise routines for drawing vehicle images, using correct types and less duplication.
peter1138
parents:
8890
diff
changeset
|
38 |
SpriteID GetImage(Direction direction) const; |
7477
ee28f55ab5e8
(svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents:
7412
diff
changeset
|
39 |
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; } |
7484
7734e4119e70
(svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents:
7478
diff
changeset
|
40 |
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; } |
7488
6f51ddf4c225
(svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents:
7484
diff
changeset
|
41 |
Money GetRunningCost() const { return ShipVehInfo(this->engine_type)->running_cost * _price.ship_running; } |
9045
2e2f3fc16905
(svn r12870) -Codechange: remove some magic numbers from u.ship.state handling
smatz
parents:
9043
diff
changeset
|
42 |
bool IsInDepot() const { return this->u.ship.state == TRACK_BIT_DEPOT; } |
7135
3c1bcca0d6bb
(svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents:
7134
diff
changeset
|
43 |
void Tick(); |
8467
605661f3a91c
(svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx
parents:
8211
diff
changeset
|
44 |
void OnNewDay(); |
8827
730524764a69
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium
parents:
8786
diff
changeset
|
45 |
TileIndex GetOrderStationLocation(StationID station); |
8890
8a0fa7ff70a0
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents:
8827
diff
changeset
|
46 |
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse); |
6552
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
47 |
}; |
d87268e08799
(svn r9754) -Codechange: make classes for all vehicle types, so we can make nicer/better maintainable code, i.e. virtual methods instead of switches.
rubidium
parents:
6420
diff
changeset
|
48 |
|
4666
172a0cdf28a6
(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 */ |