| author | truebrain |
| Mon, 31 Mar 2008 16:11:00 +0000 | |
| branch | noai |
| changeset 9849 | edf90dda4ec4 |
| parent 9826 | 9707ad4c9b60 |
| child 9869 | 6404afe43575 |
| 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 |
|
| 9574 | 3 |
/** @file train.h */ |
4 |
||
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
5 |
#ifndef TRAIN_H |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
6 |
#define TRAIN_H |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
7 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
8 |
#include "stdafx.h" |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
9 |
#include "core/bitmath_func.hpp" |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
10 |
#include "vehicle_base.h" |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
11 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
12 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
13 |
/* |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
14 |
* enum to handle train subtypes |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
15 |
* 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
|
16 |
* 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
|
17 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
18 |
|
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
19 |
enum TrainSubtype {
|
| 9732 | 20 |
TS_FRONT = 0, ///< Leading engine of a train |
21 |
TS_ARTICULATED_PART = 1, ///< Articulated part of an engine |
|
22 |
TS_WAGON = 2, ///< Wagon |
|
23 |
TS_ENGINE = 3, ///< Engine, that can be front engines, but might be placed behind another engine |
|
24 |
TS_FREE_WAGON = 4, ///< First in a wagon chain (in depot) |
|
25 |
TS_MULTIHEADED = 5, ///< Engine is a multiheaded |
|
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
26 |
}; |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
27 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
28 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
29 |
/** 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
|
30 |
* @param v vehicle to check |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
31 |
* @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
|
32 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
33 |
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
|
34 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
35 |
assert(v->type == VEH_TRAIN); |
| 9732 | 36 |
return HasBit(v->subtype, TS_FRONT); |
|
2676
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 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
39 |
/** Set front engine state |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
40 |
* @param v vehicle to change |
|
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 |
static inline void SetFrontEngine(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
43 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
44 |
assert(v->type == VEH_TRAIN); |
| 9732 | 45 |
SetBit(v->subtype, TS_FRONT); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
46 |
} |
|
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 |
/** Remove the front engine state |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
49 |
* @param v vehicle to change |
|
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 |
static inline void ClearFrontEngine(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
52 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
53 |
assert(v->type == VEH_TRAIN); |
| 9732 | 54 |
ClrBit(v->subtype, TS_FRONT); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
55 |
} |
|
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 |
/** 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
|
58 |
* @param v vehicle to check |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
59 |
* @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
|
60 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
61 |
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
|
62 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
63 |
assert(v->type == VEH_TRAIN); |
| 9732 | 64 |
return HasBit(v->subtype, TS_ARTICULATED_PART); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
65 |
} |
|
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 |
/** 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
|
68 |
* @param v vehicle to change |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
69 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
70 |
static inline void SetArticulatedPart(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
71 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
72 |
assert(v->type == VEH_TRAIN); |
| 9732 | 73 |
SetBit(v->subtype, TS_ARTICULATED_PART); |
|
2676
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 |
/** 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
|
77 |
* @param v vehicle to change |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
78 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
79 |
static inline void ClearArticulatedPart(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
80 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
81 |
assert(v->type == VEH_TRAIN); |
| 9732 | 82 |
ClrBit(v->subtype, TS_ARTICULATED_PART); |
|
2676
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 |
/** 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
|
86 |
* @param v vehicle to check |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
87 |
* @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
|
88 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
89 |
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
|
90 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
91 |
assert(v->type == VEH_TRAIN); |
| 9732 | 92 |
return HasBit(v->subtype, TS_WAGON); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
93 |
} |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
94 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
95 |
/** 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
|
96 |
* @param v vehicle to change |
|
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 |
static inline void SetTrainWagon(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
99 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
100 |
assert(v->type == VEH_TRAIN); |
| 9732 | 101 |
SetBit(v->subtype, TS_WAGON); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
102 |
} |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
103 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
104 |
/** Clear wagon property |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
105 |
* @param v vehicle to change |
|
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 |
static inline void ClearTrainWagon(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
108 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
109 |
assert(v->type == VEH_TRAIN); |
| 9732 | 110 |
ClrBit(v->subtype, TS_WAGON); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
111 |
} |
|
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 |
/** 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
|
114 |
* @param v vehicle to check |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
115 |
* @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
|
116 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
117 |
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
|
118 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
119 |
assert(v->type == VEH_TRAIN); |
| 9732 | 120 |
return HasBit(v->subtype, TS_ENGINE); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
121 |
} |
|
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 |
/** Set engine status |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
124 |
* @param v vehicle to change |
|
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 |
static inline void SetTrainEngine(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
127 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
128 |
assert(v->type == VEH_TRAIN); |
| 9732 | 129 |
SetBit(v->subtype, TS_ENGINE); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
130 |
} |
|
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 |
/** Clear engine status |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
133 |
* @param v vehicle to change |
|
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 |
static inline void ClearTrainEngine(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
136 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
137 |
assert(v->type == VEH_TRAIN); |
| 9732 | 138 |
ClrBit(v->subtype, TS_ENGINE); |
|
2676
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 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
141 |
/** 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
|
142 |
* @param v vehicle to check |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
143 |
* @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
|
144 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
145 |
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
|
146 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
147 |
assert(v->type == VEH_TRAIN); |
| 9732 | 148 |
return HasBit(v->subtype, TS_FREE_WAGON); |
|
2676
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 |
/** 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
|
152 |
* @param v vehicle to change |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
153 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
154 |
static inline void SetFreeWagon(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
155 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
156 |
assert(v->type == VEH_TRAIN); |
| 9732 | 157 |
SetBit(v->subtype, TS_FREE_WAGON); |
|
2676
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 |
/** 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
|
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 ClearFreeWagon(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
164 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
165 |
assert(v->type == VEH_TRAIN); |
| 9732 | 166 |
ClrBit(v->subtype, TS_FREE_WAGON); |
|
2676
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 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
169 |
/** 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
|
170 |
* @param v vehicle to check |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
171 |
* @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
|
172 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
173 |
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
|
174 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
175 |
assert(v->type == VEH_TRAIN); |
| 9732 | 176 |
return HasBit(v->subtype, TS_MULTIHEADED); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
177 |
} |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
178 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
179 |
/** 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
|
180 |
* @param v vehicle to change |
|
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 |
static inline void SetMultiheaded(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
183 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
184 |
assert(v->type == VEH_TRAIN); |
| 9732 | 185 |
SetBit(v->subtype, TS_MULTIHEADED); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
186 |
} |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
187 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
188 |
/** Clear multiheaded engine property |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
189 |
* @param v vehicle to change |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
190 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
191 |
static inline void ClearMultiheaded(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
192 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
193 |
assert(v->type == VEH_TRAIN); |
| 9732 | 194 |
ClrBit(v->subtype, TS_MULTIHEADED); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
195 |
} |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
196 |
|
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
197 |
/** 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
|
198 |
* @param v Vehicle. |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
199 |
* @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
|
200 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
201 |
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
|
202 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
203 |
assert(v->type == VEH_TRAIN); |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
204 |
return (v->Next() != NULL && IsArticulatedPart(v->Next())); |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
205 |
} |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
206 |
|
|
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
207 |
/** |
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
208 |
* Get the next part of a multi-part engine. |
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
209 |
* Will only work on a multi-part engine (EngineHasArticPart(v) == true), |
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
210 |
* Result is undefined for normal engine. |
|
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 |
static inline Vehicle *GetNextArticPart(const Vehicle *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 |
assert(EngineHasArticPart(v)); |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
215 |
return v->Next(); |
|
4384
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 |
|
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
218 |
/** 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
|
219 |
* @param v Vehicle. |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
220 |
* @return Last part of the engine. |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
221 |
*/ |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
222 |
static inline Vehicle *GetLastEnginePart(Vehicle *v) |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
223 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
224 |
assert(v->type == VEH_TRAIN); |
|
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
225 |
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
|
226 |
return v; |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
227 |
} |
|
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
228 |
|
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
229 |
/** Tell if we are dealing with the rear end of a multiheaded engine. |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
230 |
* @param v Vehicle. |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
231 |
* @return True if the engine is the rear part of a dualheaded engine. |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
232 |
*/ |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
233 |
static inline bool IsRearDualheaded(const Vehicle *v) |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
234 |
{
|
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
235 |
assert(v->type == VEH_TRAIN); |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
236 |
return (IsMultiheaded(v) && !IsTrainEngine(v)); |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
237 |
} |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
238 |
|
|
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
239 |
/** Get the next real (non-articulated part) vehicle in the consist. |
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
240 |
* @param v Vehicle. |
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
241 |
* @return Next vehicle in the consist. |
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
242 |
*/ |
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
243 |
static inline Vehicle *GetNextVehicle(const Vehicle *v) |
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
244 |
{
|
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
245 |
assert(v->type == VEH_TRAIN); |
|
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
246 |
while (EngineHasArticPart(v)) v = GetNextArticPart(v); |
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
247 |
|
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
248 |
/* v now contains the last artic part in the engine */ |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
249 |
return v->Next(); |
|
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
250 |
} |
|
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
2855
diff
changeset
|
251 |
|
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
252 |
/** Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist. |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
253 |
* @param v Vehicle. |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
254 |
* @return Next vehicle in the consist. |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
255 |
*/ |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
256 |
static inline Vehicle *GetNextUnit(Vehicle *v) |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
257 |
{
|
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
258 |
assert(v->type == VEH_TRAIN); |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
259 |
v = GetNextVehicle(v); |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
260 |
if (v != NULL && IsRearDualheaded(v)) v = v->Next(); |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
261 |
|
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
262 |
return v; |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
263 |
} |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
264 |
|
| 6573 | 265 |
void ConvertOldMultiheadToNew(); |
266 |
void ConnectMultiheadedTrains(); |
|
|
4737
e38af7736681
(svn r6649) - Codechange: Show more correct capacity of articulated wagons in the train purchase list.
peter1138
parents:
4653
diff
changeset
|
267 |
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
|
268 |
|
|
4648
ab94e3a447a8
(svn r6524) -Code cleanup r6515: cleaned up the command to start/stop all vehicles in a depot.
bjarni
parents:
4640
diff
changeset
|
269 |
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
|
270 |
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
|
271 |
void CcBuildWagon(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
|
272 |
|
|
5316
b04421921eae
(svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents:
5163
diff
changeset
|
273 |
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
|
274 |
|
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
275 |
int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped); |
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
276 |
int CheckTrainStoppedInDepot(const Vehicle *v); |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
277 |
void UpdateTrainAcceleration(Vehicle* v); |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
278 |
|
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
279 |
/** |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
280 |
* This class 'wraps' Vehicle; you do not actually instantiate this class. |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
281 |
* You create a Vehicle using AllocateVehicle, so it is added to the pool |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
282 |
* and you reinitialize that to a Train using: |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
283 |
* v = new (v) Train(); |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
284 |
* |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
285 |
* As side-effect the vehicle type is set correctly. |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
286 |
*/ |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
287 |
struct Train : public Vehicle {
|
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
288 |
/** Initializes the Vehicle to a train */ |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
289 |
Train() { this->type = VEH_TRAIN; }
|
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
290 |
|
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
291 |
/** We want to 'destruct' the right class. */ |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
292 |
virtual ~Train() { this->PreDestructor(); }
|
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
293 |
|
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
294 |
const char *GetTypeString() const { return "train"; }
|
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
295 |
void MarkDirty(); |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
296 |
void UpdateDeltaXY(Direction direction); |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
297 |
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; }
|
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
298 |
WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; }
|
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
299 |
void PlayLeaveStationSound() const; |
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
300 |
bool IsPrimaryVehicle() const { return IsFrontEngine(this); }
|
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9625
diff
changeset
|
301 |
int GetImage(Direction direction) const; |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
302 |
int GetDisplaySpeed() const { return this->u.rail.last_speed * 10 / 16; }
|
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
303 |
int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed * 10 / 16; }
|
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
304 |
Money GetRunningCost() const; |
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
305 |
bool IsInDepot() const { return CheckTrainInDepot(this, false) != -1; }
|
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
306 |
bool IsStoppedInDepot() const { return CheckTrainStoppedInDepot(this) >= 0; }
|
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9625
diff
changeset
|
307 |
void Tick(); |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
308 |
void OnNewDay(); |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
309 |
}; |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
310 |
|
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
diff
changeset
|
311 |
#endif /* TRAIN_H */ |