author | bjarni |
Wed, 28 Feb 2007 00:33:40 +0000 | |
branch | cpp_gui |
changeset 6268 | 4b5241e5dd10 |
parent 6030 | 70686dbed756 |
child 6298 | c30fe89622df |
child 6573 | 7624f942237f |
permissions | -rw-r--r-- |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
1 |
/* $Id$ */ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
2 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
3 |
#ifndef TRAIN_H |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
4 |
#define TRAIN_H |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
5 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
6 |
#include "stdafx.h" |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
7 |
#include "vehicle.h" |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
8 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
9 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
10 |
/* |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
11 |
* enum to handle train subtypes |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
12 |
* Do not access it directly unless you have to. Use the access functions below |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
13 |
* This is an enum to tell what bit to access as it is a bitmask |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
14 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
15 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
16 |
typedef enum TrainSubtypes { |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
17 |
Train_Front = 0, // Leading engine of a train |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
18 |
Train_Articulated_Part = 1, // Articulated part of an engine |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
19 |
Train_Wagon = 2, // Wagon |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
20 |
Train_Engine = 3, // Engine, that can be front engines, but might be placed behind another engine |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
21 |
Train_Free_Wagon = 4, // First in a wagon chain (in depot) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
22 |
Train_Multiheaded = 5, // Engine is a multiheaded |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
23 |
} TrainSubtype; |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
24 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
25 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
26 |
/** Check if a vehicle is front engine |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
27 |
* @param v vehicle to check |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
28 |
* @return Returns true if vehicle is a front engine |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
29 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
30 |
static inline bool IsFrontEngine(const Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
31 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
32 |
return HASBIT(v->subtype, Train_Front); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
33 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
34 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
35 |
/** Set front engine state |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
36 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
37 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
38 |
static inline void SetFrontEngine(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
39 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
40 |
SETBIT(v->subtype, Train_Front); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
41 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
42 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
43 |
/** Remove the front engine state |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
44 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
45 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
46 |
static inline void ClearFrontEngine(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
47 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
48 |
CLRBIT(v->subtype, Train_Front); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
49 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
50 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
51 |
/** Check if a vehicle is an articulated part of an engine |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
52 |
* @param v vehicle to check |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
53 |
* @return Returns true if vehicle is an articulated part |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
54 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
55 |
static inline bool IsArticulatedPart(const Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
56 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
57 |
return HASBIT(v->subtype, Train_Articulated_Part); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
58 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
59 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
60 |
/** Set a vehicle to be an articulated part |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
61 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
62 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
63 |
static inline void SetArticulatedPart(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
64 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
65 |
SETBIT(v->subtype, Train_Articulated_Part); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
66 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
67 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
68 |
/** Clear a vehicle from being an articulated part |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
69 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
70 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
71 |
static inline void ClearArticulatedPart(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
72 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
73 |
CLRBIT(v->subtype, Train_Articulated_Part); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
74 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
75 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
76 |
/** Check if a vehicle is a wagon |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
77 |
* @param v vehicle to check |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
78 |
* @return Returns true if vehicle is a wagon |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
79 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
80 |
static inline bool IsTrainWagon(const Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
81 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
82 |
return HASBIT(v->subtype, Train_Wagon); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
83 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
84 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
85 |
/** Set a vehicle to be a wagon |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
86 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
87 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
88 |
static inline void SetTrainWagon(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
89 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
90 |
SETBIT(v->subtype, Train_Wagon); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
91 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
92 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
93 |
/** Clear wagon property |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
94 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
95 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
96 |
static inline void ClearTrainWagon(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
97 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
98 |
CLRBIT(v->subtype, Train_Wagon); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
99 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
100 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
101 |
/** Check if a vehicle is an engine (can be first in a train) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
102 |
* @param v vehicle to check |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
103 |
* @return Returns true if vehicle is an engine |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
104 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
105 |
static inline bool IsTrainEngine(const Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
106 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
107 |
return HASBIT(v->subtype, Train_Engine); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
108 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
109 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
110 |
/** Set engine status |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
111 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
112 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
113 |
static inline void SetTrainEngine(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
114 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
115 |
SETBIT(v->subtype, Train_Engine); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
116 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
117 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
118 |
/** Clear engine status |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
119 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
120 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
121 |
static inline void ClearTrainEngine(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
122 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
123 |
CLRBIT(v->subtype, Train_Engine); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
124 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
125 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
126 |
/** Check if a vehicle is a free wagon (got no engine in front of it) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
127 |
* @param v vehicle to check |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
128 |
* @return Returns true if vehicle is a free wagon |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
129 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
130 |
static inline bool IsFreeWagon(const Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
131 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
132 |
return HASBIT(v->subtype, Train_Free_Wagon); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
133 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
134 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
135 |
/** Set if a vehicle is a free wagon |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
136 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
137 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
138 |
static inline void SetFreeWagon(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
139 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
140 |
SETBIT(v->subtype, Train_Free_Wagon); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
141 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
142 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
143 |
/** Clear a vehicle from being a free wagon |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
144 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
145 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
146 |
static inline void ClearFreeWagon(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
147 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
148 |
CLRBIT(v->subtype, Train_Free_Wagon); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
149 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
150 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
151 |
/** Check if a vehicle is a multiheaded engine |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
152 |
* @param v vehicle to check |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
153 |
* @return Returns true if vehicle is a multiheaded engine |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
154 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
155 |
static inline bool IsMultiheaded(const Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
156 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
157 |
return HASBIT(v->subtype, Train_Multiheaded); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
158 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
159 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
160 |
/** Set if a vehicle is a multiheaded engine |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
161 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
162 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
163 |
static inline void SetMultiheaded(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
164 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
165 |
SETBIT(v->subtype, Train_Multiheaded); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
166 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
167 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
168 |
/** Clear multiheaded engine property |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
169 |
* @param v vehicle to change |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
170 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
171 |
static inline void ClearMultiheaded(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
172 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
173 |
CLRBIT(v->subtype, Train_Multiheaded); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
174 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
175 |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
176 |
/** Check if an engine has an articulated part. |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
177 |
* @param v Vehicle. |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
178 |
* @return True if the engine has an articulated part. |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
179 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
180 |
static inline bool EngineHasArticPart(const Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
181 |
{ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
182 |
return (v->next != NULL && IsArticulatedPart(v->next)); |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
183 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
184 |
|
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
185 |
/** |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
186 |
* Get the next part of a multi-part engine. |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
187 |
* Will only work on a multi-part engine (EngineHasArticPart(v) == true), |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
188 |
* Result is undefined for normal engine. |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
189 |
*/ |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
190 |
static inline Vehicle *GetNextArticPart(const Vehicle *v) |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
191 |
{ |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
192 |
assert(EngineHasArticPart(v)); |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
193 |
return v->next; |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
194 |
} |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
195 |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
196 |
/** Get the last part of a multi-part engine. |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
197 |
* @param v Vehicle. |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
198 |
* @return Last part of the engine. |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
199 |
*/ |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
200 |
static inline Vehicle *GetLastEnginePart(Vehicle *v) |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
201 |
{ |
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
202 |
while (EngineHasArticPart(v)) v = GetNextArticPart(v); |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
203 |
return v; |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
204 |
} |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
205 |
|
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
206 |
/** Get the next real (non-articulated part) vehicle in the consist. |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
207 |
* @param v Vehicle. |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
208 |
* @return Next vehicle in the consist. |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
209 |
*/ |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
210 |
static inline Vehicle *GetNextVehicle(const Vehicle *v) |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
211 |
{ |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
212 |
while (EngineHasArticPart(v)) v = GetNextArticPart(v); |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
213 |
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
214 |
/* v now contains the last artic part in the engine */ |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
215 |
return v->next; |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
216 |
} |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
217 |
|
2855
950b5a56f9d5
(svn r3403) -Codechange: [multiheaded engines] the references between the front and rear engines are no longer saved
bjarni
parents:
2676
diff
changeset
|
218 |
void ConvertOldMultiheadToNew(void); |
950b5a56f9d5
(svn r3403) -Codechange: [multiheaded engines] the references between the front and rear engines are no longer saved
bjarni
parents:
2676
diff
changeset
|
219 |
void ConnectMultiheadedTrains(void); |
4737
e38af7736681
(svn r6649) - Codechange: Show more correct capacity of articulated wagons in the train purchase list.
peter1138
parents:
4653
diff
changeset
|
220 |
uint CountArticulatedParts(EngineID engine_type); |
2855
950b5a56f9d5
(svn r3403) -Codechange: [multiheaded engines] the references between the front and rear engines are no longer saved
bjarni
parents:
2676
diff
changeset
|
221 |
|
4648
ab94e3a447a8
(svn r6524) -Code cleanup r6515: cleaned up the command to start/stop all vehicles in a depot.
bjarni
parents:
4640
diff
changeset
|
222 |
int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped); |
6030
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5726
diff
changeset
|
223 |
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2); |
70686dbed756
(svn r8331) -Feature: the train and aircraft build windows are now resizable in horizontal direction as well
bjarni
parents:
5726
diff
changeset
|
224 |
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2); |
4653
091f530bae28
(svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents:
4648
diff
changeset
|
225 |
void CcCloneTrain(bool success, TileIndex tile, uint32 p1, uint32 p2); |
4640
cabffc571e55
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4384
diff
changeset
|
226 |
|
5316
b04421921eae
(svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents:
5163
diff
changeset
|
227 |
byte FreightWagonMult(CargoID cargo); |
5163
83acad83bbdd
(svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents:
4737
diff
changeset
|
228 |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
229 |
#endif /* TRAIN_H */ |