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