author | Tero Marttila <terom@fixme.fi> |
Fri, 18 Jul 2008 21:28:42 +0300 | |
changeset 11175 | 020c61e39c94 |
parent 10429 | 1b99254f9607 |
permissions | -rw-r--r-- |
3962 | 1 |
/* $Id$ */ |
2 |
||
10429
1b99254f9607
(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:
10382
diff
changeset
|
3 |
/** @file ship.h Base for ships. */ |
6916
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
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 |
|
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8612
diff
changeset
|
8 |
#include "vehicle_base.h" |
9282
2bb9703aeb39
(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:
8963
diff
changeset
|
9 |
#include "engine_func.h" |
10382
d1d4452acbfc
(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:
10329
diff
changeset
|
10 |
#include "engine_base.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
7986
diff
changeset
|
11 |
#include "economy_func.h" |
3962 | 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 | 16 |
|
7048
06b931095b26
(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:
6916
diff
changeset
|
17 |
/** |
06b931095b26
(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:
6916
diff
changeset
|
18 |
* This class 'wraps' Vehicle; you do not actually instantiate this class. |
06b931095b26
(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:
6916
diff
changeset
|
19 |
* You create a Vehicle using AllocateVehicle, so it is added to the pool |
06b931095b26
(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:
6916
diff
changeset
|
20 |
* and you reinitialize that to a Train using: |
06b931095b26
(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:
6916
diff
changeset
|
21 |
* v = new (v) Ship(); |
06b931095b26
(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:
6916
diff
changeset
|
22 |
* |
06b931095b26
(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:
6916
diff
changeset
|
23 |
* As side-effect the vehicle type is set correctly. |
06b931095b26
(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:
6916
diff
changeset
|
24 |
*/ |
06b931095b26
(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:
6916
diff
changeset
|
25 |
struct Ship: public Vehicle { |
06b931095b26
(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:
6916
diff
changeset
|
26 |
/** Initializes the Vehicle to a ship */ |
06b931095b26
(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:
6916
diff
changeset
|
27 |
Ship() { this->type = VEH_SHIP; } |
06b931095b26
(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:
6916
diff
changeset
|
28 |
|
06b931095b26
(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:
6916
diff
changeset
|
29 |
/** We want to 'destruct' the right class. */ |
7908
403a9694c42d
(svn r10798) -Fix [FS#1105]: virtual functions do not work in destructors :(.
rubidium
parents:
7814
diff
changeset
|
30 |
virtual ~Ship() { this->PreDestructor(); } |
7048
06b931095b26
(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:
6916
diff
changeset
|
31 |
|
7059
3d5c57a7e729
(svn r9765) -Codechange: constify some class functions.
rubidium
parents:
7058
diff
changeset
|
32 |
const char *GetTypeString() const { return "ship"; } |
7049
01825af2ce90
(svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents:
7048
diff
changeset
|
33 |
void MarkDirty(); |
7054
edbb4d7765f2
(svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents:
7049
diff
changeset
|
34 |
void UpdateDeltaXY(Direction direction); |
7059
3d5c57a7e729
(svn r9765) -Codechange: constify some class functions.
rubidium
parents:
7058
diff
changeset
|
35 |
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; } |
7089
7230d3e22a5f
(svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
rubidium
parents:
7059
diff
changeset
|
36 |
void PlayLeaveStationSound() const; |
7269
c7f39d91255e
(svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents:
7089
diff
changeset
|
37 |
bool IsPrimaryVehicle() const { return true; } |
10293
b3ca071d6716
(svn r12824) -Codechange: Standardise routines for drawing vehicle images, using correct types and less duplication.
peter1138
parents:
10126
diff
changeset
|
38 |
SpriteID GetImage(Direction direction) const; |
7973
ce69b7781d4a
(svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents:
7908
diff
changeset
|
39 |
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; } |
7980
9b12784cc39c
(svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents:
7974
diff
changeset
|
40 |
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; } |
7984
c539c9368e3c
(svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents:
7980
diff
changeset
|
41 |
Money GetRunningCost() const { return ShipVehInfo(this->engine_type)->running_cost * _price.ship_running; } |
10329
69e49f381f7f
(svn r12870) -Codechange: remove some magic numbers from u.ship.state handling
smatz
parents:
10321
diff
changeset
|
42 |
bool IsInDepot() const { return this->u.ship.state == TRACK_BIT_DEPOT; } |
7631
e810ef25497e
(svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents:
7630
diff
changeset
|
43 |
void Tick(); |
8963
4b41ed1df7e5
(svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx
parents:
8707
diff
changeset
|
44 |
void OnNewDay(); |
9323
9bc423363f6a
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium
parents:
9282
diff
changeset
|
45 |
TileIndex GetOrderStationLocation(StationID station); |
10126
bed2d9d38577
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium
parents:
9323
diff
changeset
|
46 |
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse); |
7048
06b931095b26
(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:
6916
diff
changeset
|
47 |
}; |
06b931095b26
(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:
6916
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 */ |