src/ship.h
author rubidium
Thu, 31 May 2007 15:15:00 +0000
changeset 6764 d09d8d618a07
parent 6593 102aa05c5ca4
child 6773 bc98b0b16ec4
permissions -rw-r--r--
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
3962
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
     1
/* $Id$ */
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
     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
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
     8
#include "vehicle.h"
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
     9
5783
e207986ffe71 (svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents: 5475
diff changeset
    10
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
4638
05955c6cb536 (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents: 3962
diff changeset
    11
void CcCloneShip(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
    12
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
    13
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
3962
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    14
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    15
static inline bool IsShipInDepot(const Vehicle* v)
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    16
{
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 5972
diff changeset
    17
	assert(v->type == VEH_SHIP);
3962
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    18
	return v->u.ship.state == 0x80;
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    19
}
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    20
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    21
static inline bool IsShipInDepotStopped(const Vehicle* v)
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    22
{
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    23
	return IsShipInDepot(v) && v->vehstatus & VS_STOPPED;
b53bf74fbcef (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    24
}
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
    25
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
    26
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
 * 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
    29
 * 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
    30
 * 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
    31
 *   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
    32
 *
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
    33
 * 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
    34
 */
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
    35
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
    36
	/** 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
    37
	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
    38
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
    39
	/** We want to 'destruct' the right 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
    40
	virtual ~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
    41
6563
fed2a162046b (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 6562
diff changeset
    42
	const char *GetTypeString() const { return "ship"; }
6553
976a684212ad (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 6552
diff changeset
    43
	void MarkDirty();
6558
c88e142f896e (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 6553
diff changeset
    44
	void UpdateDeltaXY(Direction direction);
6563
fed2a162046b (svn r9765) -Codechange: constify some class functions.
rubidium
parents: 6562
diff changeset
    45
	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
    46
	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
    47
	void PlayLeaveStationSound() const;
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
    48
};
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
    49
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
    50
#endif /* SHIP_H */