author | glx |
Mon, 24 Sep 2007 19:55:50 +0000 | |
changeset 7625 | 36b37d05937f |
parent 7490 | bb27d92565d3 |
child 8116 | 8da76dcb3287 |
permissions | -rw-r--r-- |
3962 | 1 |
/* $Id$ */ |
2 |
||
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
|
3 |
/** @file ship.h */ |
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 |
|
3962 | 8 |
#include "vehicle.h" |
7488
6f51ddf4c225
(svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents:
7484
diff
changeset
|
9 |
#include "engine.h" |
6f51ddf4c225
(svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents:
7484
diff
changeset
|
10 |
#include "variables.h" |
3962 | 11 |
|
5783
e207986ffe71
(svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents:
5475
diff
changeset
|
12 |
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
|
13 |
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
|
14 |
void GetShipSpriteSize(EngineID engine, uint &width, uint &height); |
3962 | 15 |
|
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
|
16 |
/** |
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 |
* 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
|
18 |
* 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
|
19 |
* 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
|
20 |
* 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
|
21 |
* |
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 |
* 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
|
23 |
*/ |
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 |
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
|
25 |
/** 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
|
26 |
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
|
27 |
|
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 |
/** 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
|
29 |
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
|
30 |
|
6563
fed2a162046b
(svn r9765) -Codechange: constify some class functions.
rubidium
parents:
6562
diff
changeset
|
31 |
const char *GetTypeString() const { return "ship"; } |
6553
976a684212ad
(svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents:
6552
diff
changeset
|
32 |
void MarkDirty(); |
6558
c88e142f896e
(svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents:
6553
diff
changeset
|
33 |
void UpdateDeltaXY(Direction direction); |
6563
fed2a162046b
(svn r9765) -Codechange: constify some class functions.
rubidium
parents:
6562
diff
changeset
|
34 |
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; } |
fed2a162046b
(svn r9765) -Codechange: constify some class functions.
rubidium
parents:
6562
diff
changeset
|
35 |
WindowClass GetVehicleListWindowClass() const { return WC_SHIPS_LIST; } |
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; } |
7134
5b2d47128d05
(svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents:
6773
diff
changeset
|
38 |
int 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; } |
7490
bb27d92565d3
(svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents:
7488
diff
changeset
|
42 |
bool IsInDepot() const { return this->u.ship.state == 0x80; } |
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(); |
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
|
44 |
}; |
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
|
45 |
|
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
|
46 |
#endif /* SHIP_H */ |