author | maedhros |
Mon, 11 Jun 2007 14:00:16 +0000 | |
changeset 6857 | 60130753e595 |
parent 6773 | bc98b0b16ec4 |
child 7134 | 5b2d47128d05 |
permissions | -rw-r--r-- |
3959 | 1 |
/* $Id$ */ |
2 |
||
6417 | 3 |
/** @file src/roadveh.h Road vehicle states */ |
6393
e1e4939d19b5
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
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:
4653
diff
changeset
|
5 |
#ifndef ROADVEH_H |
172a0cdf28a6
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4653
diff
changeset
|
6 |
#define ROADVEH_H |
172a0cdf28a6
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4653
diff
changeset
|
7 |
|
3959 | 8 |
#include "vehicle.h" |
9 |
||
10 |
||
6857
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
11 |
enum RoadVehicleSubType { |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
12 |
RVST_FRONT, |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
13 |
RVST_ARTIC_PART, |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
14 |
}; |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
15 |
|
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
16 |
static inline bool IsRoadVehFront(const Vehicle *v) |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
17 |
{ |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
18 |
assert(v->type == VEH_ROAD); |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
19 |
return v->subtype == RVST_FRONT; |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
20 |
} |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
21 |
|
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
22 |
static inline void SetRoadVehFront(Vehicle *v) |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
23 |
{ |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
24 |
assert(v->type == VEH_ROAD); |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
25 |
v->subtype = RVST_FRONT; |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
26 |
} |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
27 |
|
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
28 |
static inline bool IsRoadVehArticPart(const Vehicle *v) |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
29 |
{ |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
30 |
assert(v->type == VEH_ROAD); |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
31 |
return v->subtype == RVST_ARTIC_PART; |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
32 |
} |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
33 |
|
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
34 |
static inline void SetRoadVehArticPart(Vehicle *v) |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
35 |
{ |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
36 |
assert(v->type == VEH_ROAD); |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
37 |
v->subtype = RVST_ARTIC_PART; |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
38 |
} |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
39 |
|
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
40 |
static inline bool RoadVehHasArticPart(const Vehicle *v) |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
41 |
{ |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
42 |
assert(v->type == VEH_ROAD); |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
43 |
return v->next != NULL && IsRoadVehArticPart(v->next); |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
44 |
} |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
45 |
|
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
46 |
|
3959 | 47 |
static inline bool IsRoadVehInDepot(const Vehicle* v) |
48 |
{ |
|
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
5786
diff
changeset
|
49 |
assert(v->type == VEH_ROAD); |
3959 | 50 |
return v->u.road.state == 254; |
51 |
} |
|
52 |
||
53 |
static inline bool IsRoadVehInDepotStopped(const Vehicle* v) |
|
54 |
{ |
|
55 |
return IsRoadVehInDepot(v) && v->vehstatus & VS_STOPPED; |
|
56 |
} |
|
4653
9f72ab9dc4a7
(svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents:
3959
diff
changeset
|
57 |
|
5786
9bbd2d7f2a30
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5475
diff
changeset
|
58 |
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2); |
4653
9f72ab9dc4a7
(svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents:
3959
diff
changeset
|
59 |
void CcCloneRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2); |
4666
172a0cdf28a6
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4653
diff
changeset
|
60 |
|
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:
6417
diff
changeset
|
61 |
|
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:
6417
diff
changeset
|
62 |
/** |
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:
6417
diff
changeset
|
63 |
* 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:
6417
diff
changeset
|
64 |
* 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:
6417
diff
changeset
|
65 |
* 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:
6417
diff
changeset
|
66 |
* v = new (v) RoadVehicle(); |
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:
6417
diff
changeset
|
67 |
* |
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:
6417
diff
changeset
|
68 |
* 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:
6417
diff
changeset
|
69 |
*/ |
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:
6417
diff
changeset
|
70 |
struct RoadVehicle : 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:
6417
diff
changeset
|
71 |
/** Initializes the Vehicle to a road 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:
6417
diff
changeset
|
72 |
RoadVehicle() { this->type = VEH_ROAD; } |
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:
6417
diff
changeset
|
73 |
|
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:
6417
diff
changeset
|
74 |
/** 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:
6417
diff
changeset
|
75 |
virtual ~RoadVehicle() {} |
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:
6417
diff
changeset
|
76 |
|
6563
fed2a162046b
(svn r9765) -Codechange: constify some class functions.
rubidium
parents:
6562
diff
changeset
|
77 |
const char *GetTypeString() const { return "road vehicle"; } |
6553
976a684212ad
(svn r9755) -Codechange: refactor some more of the begin loading stuff.
rubidium
parents:
6552
diff
changeset
|
78 |
void MarkDirty(); |
6558
c88e142f896e
(svn r9760) -Codechange: remove the need for saving some vehicle variables.
rubidium
parents:
6553
diff
changeset
|
79 |
void UpdateDeltaXY(Direction direction); |
6563
fed2a162046b
(svn r9765) -Codechange: constify some class functions.
rubidium
parents:
6562
diff
changeset
|
80 |
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; } |
fed2a162046b
(svn r9765) -Codechange: constify some class functions.
rubidium
parents:
6562
diff
changeset
|
81 |
WindowClass GetVehicleListWindowClass() const { return WC_ROADVEH_LIST; } |
6857
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
82 |
bool IsPrimaryVehicle() const { return IsRoadVehFront(this); } |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
83 |
bool HasFront() const { return true; } |
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:
6417
diff
changeset
|
84 |
}; |
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:
6417
diff
changeset
|
85 |
|
6857
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
86 |
byte GetRoadVehLength(const Vehicle *v); |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
87 |
|
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
88 |
void RoadVehUpdateCache(Vehicle *v); |
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6773
diff
changeset
|
89 |
|
4666
172a0cdf28a6
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4653
diff
changeset
|
90 |
#endif /* ROADVEH_H */ |