src/ship.h
author rubidium
Wed, 02 May 2007 09:29:41 +0000
changeset 7058 b541279ca705
parent 7054 edbb4d7765f2
child 7059 3d5c57a7e729
permissions -rw-r--r--
(svn r9764) -Codechange: replace some lookup tables by functions.
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
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
     3
/** @file ship.h */
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
3962
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
     8
#include "vehicle.h"
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
     9
6034
89a7d10fa75b (svn r8335) -Feature: the build ship window is now also resizable horizontally and contains sorting options
bjarni
parents: 5726
diff changeset
    10
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
4638
8abe4f10b94b (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
f7284b86833f (svn r6637) -Codechange: merged all (vehicle type)EnterDepot into VehicleEnterDepot()
bjarni
parents: 4666
diff changeset
    12
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
    13
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
3962
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    14
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    15
static inline bool IsShipInDepot(const Vehicle* v)
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    16
{
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6223
diff changeset
    17
	assert(v->type == VEH_SHIP);
3962
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    18
	return v->u.ship.state == 0x80;
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    19
}
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    20
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    21
static inline bool IsShipInDepotStopped(const Vehicle* v)
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    22
{
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    23
	return IsShipInDepot(v) && v->vehstatus & VS_STOPPED;
c8e21d1c5a6c (svn r5121) Add forgotten file in r5120
tron
parents:
diff changeset
    24
}
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
    25
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
    26
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
/**
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
 * 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
    29
 * 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
    30
 * 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
    31
 *   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
    32
 *
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
    33
 * 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
    34
 */
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
    35
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
    36
	/** 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
    37
	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
    38
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
    39
	/** We want to 'destruct' the right 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
    40
	virtual ~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
    41
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
    42
	const char *GetTypeString() { return "ship"; }
7049
01825af2ce90 (svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents: 7048
diff changeset
    43
	void MarkDirty();
7054
edbb4d7765f2 (svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents: 7049
diff changeset
    44
	void UpdateDeltaXY(Direction direction);
7058
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
    45
	ExpensesType GetExpenseType(bool income) { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
b541279ca705 (svn r9764) -Codechange: replace some lookup tables by functions.
rubidium
parents: 7054
diff changeset
    46
	WindowClass GetVehicleListWindowClass() { return WC_SHIPS_LIST; }
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 */