author | Tero Marttila <terom@fixme.fi> |
Tue, 22 Jul 2008 23:20:33 +0300 | |
changeset 11184 | 88c967f1422b |
parent 11161 | 7d0fac8f14cd |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10429
1b99254f9607
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
10382
diff
changeset
|
3 |
/** @file newgrf_engine.cpp NewGRF handling of engines. */ |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1883
diff
changeset
|
6 |
#include "openttd.h" |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
7 |
#include "variables.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1197
diff
changeset
|
8 |
#include "debug.h" |
9282
2bb9703aeb39
(svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium
parents:
9281
diff
changeset
|
9 |
#include "engine_func.h" |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
10 |
#include "engine_base.h" |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
11 |
#include "train.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8732
diff
changeset
|
12 |
#include "player_func.h" |
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8732
diff
changeset
|
13 |
#include "player_base.h" |
9281
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9254
diff
changeset
|
14 |
#include "station_base.h" |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
15 |
#include "airport.h" |
3924
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
16 |
#include "newgrf.h" |
2982
286f69caaf05
(svn r3557) - NewGRF: move callback enums to a new file as more than just engines will use them
peter1138
parents:
2971
diff
changeset
|
17 |
#include "newgrf_callbacks.h" |
2962
dbd168a4703a
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2951
diff
changeset
|
18 |
#include "newgrf_engine.h" |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
19 |
#include "newgrf_station.h" |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
20 |
#include "newgrf_spritegroup.h" |
3866
113de2b20059
(svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
3862
diff
changeset
|
21 |
#include "newgrf_cargo.h" |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6358
diff
changeset
|
22 |
#include "cargotype.h" |
8636
2b158acb649c
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8627
diff
changeset
|
23 |
#include "date_func.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8636
diff
changeset
|
24 |
#include "vehicle_func.h" |
8709
4187ad809fe7
(svn r11776) -Codechange: more header splittings to reduce the dependencies.
rubidium
parents:
8694
diff
changeset
|
25 |
#include "core/random_func.hpp" |
8732
b18f578f7c16
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8731
diff
changeset
|
26 |
#include "direction_func.h" |
9161
f88d089fa608
(svn r12330) -Feature: [NewGRF] vehicle variable FE bit 5 and 6
glx
parents:
9150
diff
changeset
|
27 |
#include "rail_map.h" |
f88d089fa608
(svn r12330) -Feature: [NewGRF] vehicle variable FE bit 5 and 6
glx
parents:
9150
diff
changeset
|
28 |
#include "rail.h" |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
29 |
#include "settings_type.h" |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
30 |
#include <map> |
3843
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
31 |
|
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
32 |
|
3785
1becd6b333fe
(svn r4781) - NewGRF: give _traininfo_vehicle_pitch a proper declaration
peter1138
parents:
3739
diff
changeset
|
33 |
int _traininfo_vehicle_pitch = 0; |
3845
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3843
diff
changeset
|
34 |
int _traininfo_vehicle_width = 29; |
3785
1becd6b333fe
(svn r4781) - NewGRF: give _traininfo_vehicle_pitch a proper declaration
peter1138
parents:
3739
diff
changeset
|
35 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
36 |
struct WagonOverride { |
8694
8b6828a78860
(svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there.
peter1138
parents:
8689
diff
changeset
|
37 |
EngineID *train_id; |
8b6828a78860
(svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there.
peter1138
parents:
8689
diff
changeset
|
38 |
uint trains; |
4869
cded5f3a83c9
(svn r6795) - NewGRF: Add support for cargo-specific wagon overrides.
peter1138
parents:
4832
diff
changeset
|
39 |
CargoID cargo; |
3693
af2ee9b328e6
(svn r4629) - NewGRF: constify more code that deals with sprite groups, now that ref counting is gone.
peter1138
parents:
3686
diff
changeset
|
40 |
const SpriteGroup *group; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
41 |
}; |
0 | 42 |
|
8694
8b6828a78860
(svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there.
peter1138
parents:
8689
diff
changeset
|
43 |
void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const SpriteGroup *group, EngineID *train_id, uint trains) |
0 | 44 |
{ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
45 |
Engine *e = GetEngine(engine); |
1477 | 46 |
WagonOverride *wo; |
0 | 47 |
|
6483
5d2df05c88dd
(svn r8903) -Regression (r8891): CT_PURCHASE does apply to aircraft overrides...
peter1138
parents:
6474
diff
changeset
|
48 |
assert(cargo < NUM_CARGO + 2); // Include CT_DEFAULT and CT_PURCHASE pseudo cargos. |
5338
5b48218d8bd2
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5175
diff
changeset
|
49 |
|
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
50 |
e->overrides_count++; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
51 |
e->overrides = ReallocT(e->overrides, e->overrides_count); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
114
diff
changeset
|
52 |
|
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
53 |
wo = &e->overrides[e->overrides_count - 1]; |
2488
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2477
diff
changeset
|
54 |
wo->group = group; |
4869
cded5f3a83c9
(svn r6795) - NewGRF: Add support for cargo-specific wagon overrides.
peter1138
parents:
4832
diff
changeset
|
55 |
wo->cargo = cargo; |
0 | 56 |
wo->trains = trains; |
8694
8b6828a78860
(svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there.
peter1138
parents:
8689
diff
changeset
|
57 |
wo->train_id = MallocT<EngineID>(trains); |
8b6828a78860
(svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there.
peter1138
parents:
8689
diff
changeset
|
58 |
memcpy(wo->train_id, train_id, trains * sizeof *train_id); |
0 | 59 |
} |
60 |
||
8694
8b6828a78860
(svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there.
peter1138
parents:
8689
diff
changeset
|
61 |
const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, EngineID overriding_engine) |
0 | 62 |
{ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
63 |
const Engine *e = GetEngine(engine); |
0 | 64 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
65 |
/* XXX: This could turn out to be a timesink on profiles. We could |
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
66 |
* always just dedicate 65535 bytes for an [engine][train] trampoline |
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
67 |
* for O(1). Or O(logMlogN) and searching binary tree or smt. like |
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
68 |
* that. --pasky */ |
0 | 69 |
|
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
70 |
for (uint i = 0; i < e->overrides_count; i++) { |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
71 |
const WagonOverride *wo = &e->overrides[i]; |
0 | 72 |
|
7099
1528b11097af
(svn r9818) -Codechange: Cache wagon override sprite set whenever consist is changed, instead of 'recalculating' it every time it is used or just tested.
peter1138
parents:
7085
diff
changeset
|
73 |
if (wo->cargo != cargo && wo->cargo != CT_DEFAULT) continue; |
1528b11097af
(svn r9818) -Codechange: Cache wagon override sprite set whenever consist is changed, instead of 'recalculating' it every time it is used or just tested.
peter1138
parents:
7085
diff
changeset
|
74 |
|
8694
8b6828a78860
(svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there.
peter1138
parents:
8689
diff
changeset
|
75 |
for (uint j = 0; j < wo->trains; j++) { |
7099
1528b11097af
(svn r9818) -Codechange: Cache wagon override sprite set whenever consist is changed, instead of 'recalculating' it every time it is used or just tested.
peter1138
parents:
7085
diff
changeset
|
76 |
if (wo->train_id[j] == overriding_engine) return wo->group; |
0 | 77 |
} |
78 |
} |
|
79 |
return NULL; |
|
80 |
} |
|
81 |
||
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
82 |
/** |
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
83 |
* Unload all wagon override sprite groups. |
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
84 |
*/ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
85 |
void UnloadWagonOverrides(Engine *e) |
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
86 |
{ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
87 |
for (uint i = 0; i < e->overrides_count; i++) { |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
88 |
WagonOverride *wo = &e->overrides[i]; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
89 |
free(wo->train_id); |
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
90 |
} |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
91 |
free(e->overrides); |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
92 |
e->overrides_count = 0; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
93 |
e->overrides = NULL; |
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
94 |
} |
0 | 95 |
|
96 |
||
3693
af2ee9b328e6
(svn r4629) - NewGRF: constify more code that deals with sprite groups, now that ref counting is gone.
peter1138
parents:
3686
diff
changeset
|
97 |
void SetCustomEngineSprites(EngineID engine, byte cargo, const SpriteGroup *group) |
0 | 98 |
{ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
99 |
Engine *e = GetEngine(engine); |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
100 |
assert(cargo < lengthof(e->group)); |
5338
5b48218d8bd2
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5175
diff
changeset
|
101 |
|
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
102 |
if (e->group[cargo] != NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5338
diff
changeset
|
103 |
grfmsg(6, "SetCustomEngineSprites: engine %d cargo %d already has group -- replacing", engine, cargo); |
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
104 |
} |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
105 |
e->group[cargo] = group; |
0 | 106 |
} |
107 |
||
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
108 |
|
3924
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
109 |
/** |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
110 |
* Tie a GRFFile entry to an engine, to allow us to retrieve GRF parameters |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
111 |
* etc during a game. |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
112 |
* @param engine Engine ID to tie the GRFFile to. |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
113 |
* @param file Pointer of GRFFile to tie. |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
114 |
*/ |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
115 |
void SetEngineGRF(EngineID engine, const GRFFile *file) |
3648
1574c89384cb
(svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
peter1138
parents:
3630
diff
changeset
|
116 |
{ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
117 |
Engine *e = GetEngine(engine); |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
118 |
e->grffile = file; |
3648
1574c89384cb
(svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
peter1138
parents:
3630
diff
changeset
|
119 |
} |
1574c89384cb
(svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
peter1138
parents:
3630
diff
changeset
|
120 |
|
3924
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
121 |
|
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
122 |
/** |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
123 |
* Retrieve the GRFFile tied to an engine |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
124 |
* @param engine Engine ID to retrieve. |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
125 |
* @return Pointer to GRFFile. |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
126 |
*/ |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
127 |
const GRFFile *GetEngineGRF(EngineID engine) |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
128 |
{ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
129 |
return GetEngine(engine)->grffile; |
3924
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
130 |
} |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
131 |
|
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
132 |
|
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
133 |
/** |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
134 |
* Retrieve the GRF ID of the GRFFile tied to an engine |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
135 |
* @param engine Engine ID to retrieve. |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
136 |
* @return 32 bit GRFID value. |
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3920
diff
changeset
|
137 |
*/ |
3648
1574c89384cb
(svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
peter1138
parents:
3630
diff
changeset
|
138 |
uint32 GetEngineGRFID(EngineID engine) |
1574c89384cb
(svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
peter1138
parents:
3630
diff
changeset
|
139 |
{ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
140 |
return GetEngineGRF(engine)->grfid; |
3648
1574c89384cb
(svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
peter1138
parents:
3630
diff
changeset
|
141 |
} |
1574c89384cb
(svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
peter1138
parents:
3630
diff
changeset
|
142 |
|
1574c89384cb
(svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
peter1138
parents:
3630
diff
changeset
|
143 |
|
2708
9d1a8d5dc3ea
(svn r3252) - NewGRF: Map new train subtypes to old types for rail vehicles.
peter1138
parents:
2639
diff
changeset
|
144 |
static int MapOldSubType(const Vehicle *v) |
9d1a8d5dc3ea
(svn r3252) - NewGRF: Map new train subtypes to old types for rail vehicles.
peter1138
parents:
2639
diff
changeset
|
145 |
{ |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
146 |
if (v->type != VEH_TRAIN) return v->subtype; |
2708
9d1a8d5dc3ea
(svn r3252) - NewGRF: Map new train subtypes to old types for rail vehicles.
peter1138
parents:
2639
diff
changeset
|
147 |
if (IsTrainEngine(v)) return 0; |
9d1a8d5dc3ea
(svn r3252) - NewGRF: Map new train subtypes to old types for rail vehicles.
peter1138
parents:
2639
diff
changeset
|
148 |
if (IsFreeWagon(v)) return 4; |
9d1a8d5dc3ea
(svn r3252) - NewGRF: Map new train subtypes to old types for rail vehicles.
peter1138
parents:
2639
diff
changeset
|
149 |
return 2; |
9d1a8d5dc3ea
(svn r3252) - NewGRF: Map new train subtypes to old types for rail vehicles.
peter1138
parents:
2639
diff
changeset
|
150 |
} |
9d1a8d5dc3ea
(svn r3252) - NewGRF: Map new train subtypes to old types for rail vehicles.
peter1138
parents:
2639
diff
changeset
|
151 |
|
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
152 |
|
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
153 |
/* TTDP style aircraft movement states for GRF Action 2 Var 0xE2 */ |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
154 |
enum { |
4055
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
155 |
AMS_TTDP_HANGAR, |
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
156 |
AMS_TTDP_TO_HANGAR, |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
157 |
AMS_TTDP_TO_PAD1, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
158 |
AMS_TTDP_TO_PAD2, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
159 |
AMS_TTDP_TO_PAD3, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
160 |
AMS_TTDP_TO_ENTRY_2_AND_3, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
161 |
AMS_TTDP_TO_ENTRY_2_AND_3_AND_H, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
162 |
AMS_TTDP_TO_JUNCTION, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
163 |
AMS_TTDP_LEAVE_RUNWAY, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
164 |
AMS_TTDP_TO_INWAY, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
165 |
AMS_TTDP_TO_RUNWAY, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
166 |
AMS_TTDP_TO_OUTWAY, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
167 |
AMS_TTDP_WAITING, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
168 |
AMS_TTDP_TAKEOFF, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
169 |
AMS_TTDP_TO_TAKEOFF, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
170 |
AMS_TTDP_CLIMBING, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
171 |
AMS_TTDP_FLIGHT_APPROACH, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
172 |
AMS_TTDP_UNUSED_0x11, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
173 |
AMS_TTDP_FLIGHT_TO_TOWER, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
174 |
AMS_TTDP_UNUSED_0x13, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
175 |
AMS_TTDP_FLIGHT_FINAL, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
176 |
AMS_TTDP_FLIGHT_DESCENT, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
177 |
AMS_TTDP_BRAKING, |
3920
771542d40c45
(svn r5047) - NewGRF: fix typo of AIRPORT in enum
peter1138
parents:
3893
diff
changeset
|
178 |
AMS_TTDP_HELI_TAKEOFF_AIRPORT, |
771542d40c45
(svn r5047) - NewGRF: fix typo of AIRPORT in enum
peter1138
parents:
3893
diff
changeset
|
179 |
AMS_TTDP_HELI_TO_TAKEOFF_AIRPORT, |
771542d40c45
(svn r5047) - NewGRF: fix typo of AIRPORT in enum
peter1138
parents:
3893
diff
changeset
|
180 |
AMS_TTDP_HELI_LAND_AIRPORT, |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
181 |
AMS_TTDP_HELI_TAKEOFF_HELIPORT, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
182 |
AMS_TTDP_HELI_TO_TAKEOFF_HELIPORT, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
183 |
AMS_TTDP_HELI_LAND_HELIPORT, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
184 |
}; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
185 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
186 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
187 |
/** |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
188 |
* Map OTTD aircraft movement states to TTDPatch style movement states |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
189 |
* (VarAction 2 Variable 0xE2) |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
190 |
*/ |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
191 |
static byte MapAircraftMovementState(const Vehicle *v) |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
192 |
{ |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
193 |
const Station *st = GetStation(v->u.air.targetairport); |
7408
d5ba4fd845dd
(svn r10165) -Fix [FS#874]: crash when trying to get the aircraft movement state of an aircraft going to a just deleted airport.
rubidium
parents:
7353
diff
changeset
|
194 |
if (st->airport_tile == 0) return AMS_TTDP_FLIGHT_TO_TOWER; |
d5ba4fd845dd
(svn r10165) -Fix [FS#874]: crash when trying to get the aircraft movement state of an aircraft going to a just deleted airport.
rubidium
parents:
7353
diff
changeset
|
195 |
|
6358 | 196 |
const AirportFTAClass *afc = st->Airport(); |
7100
71b59286f5ec
(svn r9819) -Codechange: Take account of AMED_HOLD in OTTD/TTDP state translation (bulb)
peter1138
parents:
7099
diff
changeset
|
197 |
uint16 amdflag = afc->MovingData(v->u.air.pos)->flag; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
198 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
199 |
switch (v->u.air.state) { |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
200 |
case HANGAR: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
201 |
/* The international airport is a special case as helicopters can land in |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
202 |
* front of the hanger. Helicopters also change their air.state to |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
203 |
* AMED_HELI_LOWER some time before actually descending. */ |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
204 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
205 |
/* This condition only occurs for helicopters, during descent, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
206 |
* to a landing by the hanger of an international airport. */ |
3920
771542d40c45
(svn r5047) - NewGRF: fix typo of AIRPORT in enum
peter1138
parents:
3893
diff
changeset
|
207 |
if (amdflag & AMED_HELI_LOWER) return AMS_TTDP_HELI_LAND_AIRPORT; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
208 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
209 |
/* This condition only occurs for helicopters, before starting descent, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
210 |
* to a landing by the hanger of an international airport. */ |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
211 |
if (amdflag & AMED_SLOWTURN) return AMS_TTDP_FLIGHT_TO_TOWER; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
212 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
213 |
/* The final two conditions apply to helicopters or aircraft. |
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
214 |
* Has reached hanger? */ |
4055
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
215 |
if (amdflag & AMED_EXACTPOS) return AMS_TTDP_HANGAR; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
216 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
217 |
/* Still moving towards hanger. */ |
4055
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
218 |
return AMS_TTDP_TO_HANGAR; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
219 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
220 |
case TERM1: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
221 |
if (amdflag & AMED_EXACTPOS) return AMS_TTDP_TO_PAD1; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
222 |
return AMS_TTDP_TO_JUNCTION; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
223 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
224 |
case TERM2: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
225 |
if (amdflag & AMED_EXACTPOS) return AMS_TTDP_TO_PAD2; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
226 |
return AMS_TTDP_TO_ENTRY_2_AND_3_AND_H; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
227 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
228 |
case TERM3: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
229 |
case TERM4: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
230 |
case TERM5: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
231 |
case TERM6: |
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
232 |
case TERM7: |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
233 |
case TERM8: |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
234 |
/* TTDPatch only has 3 terminals, so treat these states the same */ |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
235 |
if (amdflag & AMED_EXACTPOS) return AMS_TTDP_TO_PAD3; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
236 |
return AMS_TTDP_TO_ENTRY_2_AND_3_AND_H; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
237 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
238 |
case HELIPAD1: |
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
239 |
case HELIPAD2: |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
240 |
case HELIPAD3: |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
241 |
case HELIPAD4: // Will only occur for helicopters. |
3920
771542d40c45
(svn r5047) - NewGRF: fix typo of AIRPORT in enum
peter1138
parents:
3893
diff
changeset
|
242 |
if (amdflag & AMED_HELI_LOWER) return AMS_TTDP_HELI_LAND_AIRPORT; // Descending. |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
243 |
if (amdflag & AMED_SLOWTURN) return AMS_TTDP_FLIGHT_TO_TOWER; // Still hasn't started descent. |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
244 |
return AMS_TTDP_TO_JUNCTION; // On the ground. |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
245 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
246 |
case TAKEOFF: // Moving to takeoff position. |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
247 |
return AMS_TTDP_TO_OUTWAY; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
248 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
249 |
case STARTTAKEOFF: // Accelerating down runway. |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
250 |
return AMS_TTDP_TAKEOFF; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
251 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
252 |
case ENDTAKEOFF: // Ascent |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
253 |
return AMS_TTDP_CLIMBING; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
254 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
255 |
case HELITAKEOFF: // Helicopter is moving to take off position. |
6346 | 256 |
if (afc->delta_z == 0) { |
257 |
return amdflag & AMED_HELI_RAISE ? |
|
258 |
AMS_TTDP_HELI_TAKEOFF_AIRPORT : AMS_TTDP_TO_JUNCTION; |
|
259 |
} else { |
|
260 |
return AMS_TTDP_HELI_TAKEOFF_HELIPORT; |
|
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
261 |
} |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
262 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
263 |
case FLYING: |
7100
71b59286f5ec
(svn r9819) -Codechange: Take account of AMED_HOLD in OTTD/TTDP state translation (bulb)
peter1138
parents:
7099
diff
changeset
|
264 |
return amdflag & AMED_HOLD ? AMS_TTDP_FLIGHT_APPROACH : AMS_TTDP_FLIGHT_TO_TOWER; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
265 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
266 |
case LANDING: // Descent |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
267 |
return AMS_TTDP_FLIGHT_DESCENT; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
268 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
269 |
case ENDLANDING: // On the runway braking |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
270 |
if (amdflag & AMED_BRAKE) return AMS_TTDP_BRAKING; |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
271 |
/* Landed - moving off runway */ |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
272 |
return AMS_TTDP_TO_INWAY; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
273 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
274 |
case HELILANDING: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
275 |
case HELIENDLANDING: // Helicoptor is decending. |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
276 |
if (amdflag & AMED_HELI_LOWER) { |
6346 | 277 |
return afc->delta_z == 0 ? |
278 |
AMS_TTDP_HELI_LAND_AIRPORT : AMS_TTDP_HELI_LAND_HELIPORT; |
|
279 |
} else { |
|
280 |
return AMS_TTDP_FLIGHT_TO_TOWER; |
|
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
281 |
} |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
282 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
283 |
default: |
4055
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
284 |
return AMS_TTDP_HANGAR; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
285 |
} |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
286 |
} |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
287 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
288 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
289 |
/* TTDP style aircraft movement action for GRF Action 2 Var 0xE6 */ |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
290 |
enum { |
4055
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
291 |
AMA_TTDP_IN_HANGAR, |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
292 |
AMA_TTDP_ON_PAD1, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
293 |
AMA_TTDP_ON_PAD2, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
294 |
AMA_TTDP_ON_PAD3, |
4055
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
295 |
AMA_TTDP_HANGAR_TO_PAD1, |
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
296 |
AMA_TTDP_HANGAR_TO_PAD2, |
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
297 |
AMA_TTDP_HANGAR_TO_PAD3, |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
298 |
AMA_TTDP_LANDING_TO_PAD1, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
299 |
AMA_TTDP_LANDING_TO_PAD2, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
300 |
AMA_TTDP_LANDING_TO_PAD3, |
4055
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
301 |
AMA_TTDP_PAD1_TO_HANGAR, |
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
302 |
AMA_TTDP_PAD2_TO_HANGAR, |
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
303 |
AMA_TTDP_PAD3_TO_HANGAR, |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
304 |
AMA_TTDP_PAD1_TO_TAKEOFF, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
305 |
AMA_TTDP_PAD2_TO_TAKEOFF, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
306 |
AMA_TTDP_PAD3_TO_TAKEOFF, |
4055
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
307 |
AMA_TTDP_HANGAR_TO_TAKOFF, |
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
308 |
AMA_TTDP_LANDING_TO_HANGAR, |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
309 |
AMA_TTDP_IN_FLIGHT, |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
310 |
}; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
311 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
312 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
313 |
/** |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
314 |
* Map OTTD aircraft movement states to TTDPatch style movement actions |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
315 |
* (VarAction 2 Variable 0xE6) |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
316 |
* This is not fully supported yet but it's enough for Planeset. |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
317 |
*/ |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
318 |
static byte MapAircraftMovementAction(const Vehicle *v) |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
319 |
{ |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
320 |
switch (v->u.air.state) { |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
321 |
case HANGAR: |
4055
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
322 |
return (v->cur_speed > 0) ? AMA_TTDP_LANDING_TO_HANGAR : AMA_TTDP_IN_HANGAR; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
323 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
324 |
case TERM1: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
325 |
case HELIPAD1: |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9282
diff
changeset
|
326 |
return (v->current_order.IsType(OT_LOADING)) ? AMA_TTDP_ON_PAD1 : AMA_TTDP_LANDING_TO_PAD1; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
327 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
328 |
case TERM2: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
329 |
case HELIPAD2: |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9282
diff
changeset
|
330 |
return (v->current_order.IsType(OT_LOADING)) ? AMA_TTDP_ON_PAD2 : AMA_TTDP_LANDING_TO_PAD2; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
331 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
332 |
case TERM3: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
333 |
case TERM4: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
334 |
case TERM5: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
335 |
case TERM6: |
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
336 |
case TERM7: |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
337 |
case TERM8: |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
338 |
case HELIPAD3: |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
339 |
case HELIPAD4: |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9282
diff
changeset
|
340 |
return (v->current_order.IsType(OT_LOADING)) ? AMA_TTDP_ON_PAD3 : AMA_TTDP_LANDING_TO_PAD3; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
341 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
342 |
case TAKEOFF: // Moving to takeoff position |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
343 |
case STARTTAKEOFF: // Accelerating down runway |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
344 |
case ENDTAKEOFF: // Ascent |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
345 |
case HELITAKEOFF: |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
346 |
/* @todo Need to find which terminal (or hanger) we've come from. How? */ |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
347 |
return AMA_TTDP_PAD1_TO_TAKEOFF; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
348 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
349 |
case FLYING: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
350 |
return AMA_TTDP_IN_FLIGHT; |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
351 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
352 |
case LANDING: // Descent |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
353 |
case ENDLANDING: // On the runway braking |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
354 |
case HELILANDING: |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
355 |
case HELIENDLANDING: |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
356 |
/* @todo Need to check terminal we're landing to. Is it known yet? */ |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9282
diff
changeset
|
357 |
return (v->current_order.IsType(OT_GOTO_DEPOT)) ? |
4055
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
358 |
AMA_TTDP_LANDING_TO_HANGAR : AMA_TTDP_LANDING_TO_PAD1; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
359 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
360 |
default: |
4055
2507869fbafe
(svn r5335) - Newgrf: correct spelling of hangar
peter1138
parents:
4050
diff
changeset
|
361 |
return AMA_TTDP_IN_HANGAR; |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
362 |
} |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
363 |
} |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
364 |
|
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
365 |
|
3703
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
366 |
/* TTDP airport types. Used to map our types to TTDPatch's */ |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
367 |
enum { |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
368 |
ATP_TTDP_SMALL, |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
369 |
ATP_TTDP_LARGE, |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
370 |
ATP_TTDP_HELIPORT, |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
371 |
ATP_TTDP_OILRIG, |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
372 |
}; |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
373 |
|
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
374 |
|
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
375 |
/* Vehicle Resolver Functions */ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
376 |
static inline const Vehicle *GRV(const ResolverObject *object) |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
377 |
{ |
9252
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
378 |
switch (object->scope) { |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
379 |
default: NOT_REACHED(); |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
380 |
case VSG_SCOPE_SELF: return object->u.vehicle.self; |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
381 |
case VSG_SCOPE_PARENT: return object->u.vehicle.parent; |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
382 |
case VSG_SCOPE_RELATIVE: { |
9254
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
383 |
const Vehicle *v = NULL; |
9252
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
384 |
switch (GB(object->count, 6, 2)) { |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
385 |
default: NOT_REACHED(); |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
386 |
case 0x00: // count back (away from the engine), starting at this vehicle |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
387 |
case 0x01: // count forward (toward the engine), starting at this vehicle |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
388 |
v = object->u.vehicle.self; |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
389 |
break; |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
390 |
case 0x02: // count back, starting at the engine |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
391 |
v = object->u.vehicle.parent; |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
392 |
break; |
9254
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
393 |
case 0x03: { // count back, starting at the first vehicle in this chain of vehicles with the same ID, as for vehicle variable 41 |
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
394 |
const Vehicle *self = object->u.vehicle.self; |
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
395 |
for (const Vehicle *u = self->First(); u != self; u = u->Next()) { |
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
396 |
if (u->engine_type != self->engine_type) { |
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
397 |
v = NULL; |
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
398 |
} else { |
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
399 |
if (v == NULL) v = u; |
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
400 |
} |
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
401 |
} |
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
402 |
if (v == NULL) v = self; |
7190535588ee
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
9252
diff
changeset
|
403 |
} break; |
9252
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
404 |
} |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
405 |
uint32 count = GB(object->count, 0, 4); |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
406 |
if (count == 0) count = GetRegister(0x100); |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
407 |
while (v != NULL && count-- != 0) v = (GB(object->count, 6, 2) == 0x01) ? v->Previous() : v->Next(); |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
408 |
return v; |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
409 |
} |
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
410 |
} |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
411 |
} |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
412 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
413 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
414 |
static uint32 VehicleGetRandomBits(const ResolverObject *object) |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
415 |
{ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
416 |
return GRV(object) == NULL ? 0 : GRV(object)->random_bits; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
417 |
} |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
418 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
419 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
420 |
static uint32 VehicleGetTriggers(const ResolverObject *object) |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
421 |
{ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
422 |
return GRV(object) == NULL ? 0 : GRV(object)->waiting_triggers; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
423 |
} |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
424 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
425 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
426 |
static void VehicleSetTriggers(const ResolverObject *object, int triggers) |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
427 |
{ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
428 |
/* Evil cast to get around const-ness. This used to be achieved by an |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
429 |
* innocent looking function pointer cast... Currently I cannot see a |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
430 |
* way of avoiding this without removing consts deep within gui code. |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
431 |
*/ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
432 |
Vehicle *v = (Vehicle*)GRV(object); |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
433 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
434 |
/* This function must only be called when processing triggers -- any |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
435 |
* other time is an error. */ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
436 |
assert(object->trigger != 0); |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
437 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
438 |
if (v != NULL) v->waiting_triggers = triggers; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
439 |
} |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
440 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
441 |
|
4057
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
442 |
static uint32 GetGRFParameter(EngineID engine_type, byte parameter) |
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
443 |
{ |
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
444 |
const GRFFile *file = GetEngineGRF(engine_type); |
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
445 |
|
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
446 |
if (file == NULL) return 0; |
4057
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
447 |
if (parameter >= file->param_end) return 0; |
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
448 |
return file->param[parameter]; |
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
449 |
} |
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
450 |
|
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
451 |
|
7012
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
452 |
static uint8 LiveryHelper(EngineID engine, const Vehicle *v) |
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
453 |
{ |
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
454 |
const Livery *l; |
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
455 |
|
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
456 |
if (v == NULL) { |
11161
7d0fac8f14cd
(svn r13719) -Codechange: rename IsValidPlayer to IsValidPlayerID in line with all other structs/classes that are in a pool.
rubidium
parents:
10846
diff
changeset
|
457 |
if (!IsValidPlayerID(_current_player)) return 0; |
7012
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
458 |
l = GetEngineLivery(engine, _current_player, INVALID_ENGINE, NULL); |
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
459 |
} else if (v->type == VEH_TRAIN) { |
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
460 |
l = GetEngineLivery((v->u.rail.first_engine != INVALID_ENGINE && (IsArticulatedPart(v) || UsesWagonOverride(v))) ? v->u.rail.first_engine : v->engine_type, v->owner, v->u.rail.first_engine, v); |
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
461 |
} else { |
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
462 |
l = GetEngineLivery(v->engine_type, v->owner, INVALID_ENGINE, v); |
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
463 |
} |
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
464 |
|
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
465 |
return l->colour1 + l->colour2 * 16; |
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
466 |
} |
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
467 |
|
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
468 |
|
3893
46169364701b
(svn r4960) - NewGRF: explicitly handle unsupported variables, instead of returning -1.
peter1138
parents:
3870
diff
changeset
|
469 |
static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
470 |
{ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
471 |
const Vehicle *v = GRV(object); |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
472 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
473 |
if (v == NULL) { |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
474 |
/* Vehicle does not exist, so we're in a purchase list */ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
475 |
switch (variable) { |
7012
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
476 |
case 0x43: return _current_player | (LiveryHelper(object->u.vehicle.self_type, NULL) << 24); // Owner information |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
477 |
case 0x46: return 0; // Motion counter |
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
478 |
case 0x48: return GetEngine(object->u.vehicle.self_type)->flags; // Vehicle Type Info |
10826
0c34789cf21b
(svn r13377) -Codechange: Let 'long format' build year work in vehicle purchase list.
peter1138
parents:
10825
diff
changeset
|
479 |
case 0x49: return _cur_year; // 'Long' format build year |
8418
b49fc6be1ab9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
8377
diff
changeset
|
480 |
case 0xC4: return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; // Build year |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
481 |
case 0xDA: return INVALID_VEHICLE; // Next vehicle |
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
482 |
case 0x7F: return GetGRFParameter(object->u.vehicle.self_type, parameter); // Read GRF parameter |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
483 |
} |
3893
46169364701b
(svn r4960) - NewGRF: explicitly handle unsupported variables, instead of returning -1.
peter1138
parents:
3870
diff
changeset
|
484 |
|
46169364701b
(svn r4960) - NewGRF: explicitly handle unsupported variables, instead of returning -1.
peter1138
parents:
3870
diff
changeset
|
485 |
*available = false; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
486 |
return UINT_MAX; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
487 |
} |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
488 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
489 |
/* Calculated vehicle parameters */ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
490 |
switch (variable) { |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
491 |
case 0x40: // Get length of consist |
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
492 |
case 0x41: // Get length of same consecutive wagons |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
493 |
{ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
494 |
const Vehicle* u; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
495 |
byte chain_before = 0; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
496 |
byte chain_after = 0; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
497 |
|
7993
76b0eb3e19c9
(svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents:
7988
diff
changeset
|
498 |
for (u = v->First(); u != v; u = u->Next()) { |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
499 |
chain_before++; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
500 |
if (variable == 0x41 && u->engine_type != v->engine_type) chain_before = 0; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
501 |
} |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
502 |
|
7988
6075538f6111
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7823
diff
changeset
|
503 |
while (u->Next() != NULL && (variable == 0x40 || u->Next()->engine_type == v->engine_type)) { |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
504 |
chain_after++; |
7988
6075538f6111
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7823
diff
changeset
|
505 |
u = u->Next(); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
506 |
} |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
507 |
|
5174
cc6593dedd42
(svn r7284) -Fix (r2361): off by one when calculating vehicle newgrf variable 41 result, partly blamed by vague documentation... (thanks lakie)
peter1138
parents:
5172
diff
changeset
|
508 |
return chain_before | chain_after << 8 | (chain_before + chain_after + (variable == 0x41)) << 16; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
509 |
} |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
510 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
511 |
case 0x42: { // Consist cargo information |
3843
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
512 |
const Vehicle *u; |
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
513 |
byte cargo_classes = 0; |
7318
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
514 |
uint8 common_cargo_best = 0; |
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
515 |
uint8 common_cargos[NUM_CARGO]; |
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
516 |
uint8 common_subtype_best = 0; |
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
517 |
uint8 common_subtypes[256]; |
3862
898c8212afa1
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
peter1138
parents:
3848
diff
changeset
|
518 |
byte user_def_data = 0; |
6439
99a5807852b1
(svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents:
6417
diff
changeset
|
519 |
CargoID common_cargo_type = CT_PASSENGERS; |
7318
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
520 |
uint8 common_subtype = 0; |
3843
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
521 |
|
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
522 |
/* Reset our arrays */ |
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
523 |
memset(common_cargos, 0, sizeof(common_cargos)); |
7318
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
524 |
memset(common_subtypes, 0, sizeof(common_subtypes)); |
3843
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
525 |
|
7988
6075538f6111
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7823
diff
changeset
|
526 |
for (u = v; u != NULL; u = u->Next()) { |
9150
f2d2e67ee543
(svn r12314) -Fix (r4896): Include prop 25 data for all train parts, not just those that carry cargo.
peter1138
parents:
9110
diff
changeset
|
527 |
if (v->type == VEH_TRAIN) user_def_data |= u->u.rail.user_def_data; |
f2d2e67ee543
(svn r12314) -Fix (r4896): Include prop 25 data for all train parts, not just those that carry cargo.
peter1138
parents:
9110
diff
changeset
|
528 |
|
3843
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
529 |
/* Skip empty engines */ |
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
530 |
if (u->cargo_cap == 0) continue; |
6439
99a5807852b1
(svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents:
6417
diff
changeset
|
531 |
|
99a5807852b1
(svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents:
6417
diff
changeset
|
532 |
cargo_classes |= GetCargo(u->cargo_type)->classes; |
99a5807852b1
(svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents:
6417
diff
changeset
|
533 |
common_cargos[u->cargo_type]++; |
7318
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
534 |
common_subtypes[u->cargo_subtype]++; |
3843
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
535 |
} |
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
536 |
|
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
537 |
/* Pick the most common cargo type */ |
6439
99a5807852b1
(svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents:
6417
diff
changeset
|
538 |
for (CargoID cargo = 0; cargo < NUM_CARGO; cargo++) { |
3843
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
539 |
if (common_cargos[cargo] > common_cargo_best) { |
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
540 |
common_cargo_best = common_cargos[cargo]; |
6439
99a5807852b1
(svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents:
6417
diff
changeset
|
541 |
common_cargo_type = GetCargo(cargo)->bitnum; |
3843
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
542 |
} |
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
543 |
} |
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
544 |
|
7318
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
545 |
for (uint i = 0; i < lengthof(common_subtypes); i++) { |
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
546 |
if (common_subtypes[i] > common_subtype_best) { |
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
547 |
common_subtype_best = common_subtypes[i]; |
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
548 |
common_subtype = i; |
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
549 |
} |
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
550 |
} |
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
551 |
|
9fa3dc1d39ca
(svn r10061) -Codechange: [NewGRF] Add common cargo subtype support to vehicle var 42
peter1138
parents:
7117
diff
changeset
|
552 |
return cargo_classes | (common_cargo_type << 8) | (common_subtype << 16) | (user_def_data << 24); |
3843
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
553 |
} |
931e6e89dfb2
(svn r4867) - NewGRF: implement partial support for engine variable 0x42
peter1138
parents:
3785
diff
changeset
|
554 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
555 |
case 0x43: // Player information |
7012
f20d04170833
(svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents:
6986
diff
changeset
|
556 |
return v->owner | (GetPlayer(v->owner)->is_ai ? 0x10000 : 0) | (LiveryHelper(v->engine_type, v) << 24); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
557 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
558 |
case 0x44: // Aircraft information |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
559 |
if (v->type != VEH_AIRCRAFT) return UINT_MAX; |
3703
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
560 |
|
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
561 |
{ |
7988
6075538f6111
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7823
diff
changeset
|
562 |
const Vehicle *w = v->Next(); |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
563 |
uint16 altitude = v->z_pos - w->z_pos; // Aircraft height - shadow height |
3703
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
564 |
byte airporttype; |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
565 |
|
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
566 |
switch (GetStation(v->u.air.targetairport)->airport_type) { |
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
567 |
/* Note, Helidepot and Helistation are treated as small airports |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
568 |
* as they are at ground level. */ |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
569 |
case AT_HELIDEPOT: |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
570 |
case AT_HELISTATION: |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
571 |
case AT_COMMUTER: |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
572 |
case AT_SMALL: airporttype = ATP_TTDP_SMALL; break; |
3703
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
573 |
case AT_METROPOLITAN: |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
574 |
case AT_INTERNATIONAL: |
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
575 |
case AT_INTERCON: |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
576 |
case AT_LARGE: airporttype = ATP_TTDP_LARGE; break; |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
577 |
case AT_HELIPORT: airporttype = ATP_TTDP_HELIPORT; break; |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
578 |
case AT_OILRIG: airporttype = ATP_TTDP_OILRIG; break; |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
4058
diff
changeset
|
579 |
default: airporttype = ATP_TTDP_LARGE; break; |
3703
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
580 |
} |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
581 |
|
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
582 |
return (altitude << 8) | airporttype; |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
583 |
} |
7a63c0e05948
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
peter1138
parents:
3702
diff
changeset
|
584 |
|
7085
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
585 |
case 0x45: { // Curvature info |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
586 |
/* Format: xxxTxBxF |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
587 |
* F - previous wagon to current wagon, 0 if vehicle is first |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
588 |
* B - current wagon to next wagon, 0 if wagon is last |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
589 |
* T - previous wagon to next wagon, 0 in an S-bend |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
590 |
*/ |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
591 |
if (v->type != VEH_TRAIN) return 0; |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
592 |
|
7993
76b0eb3e19c9
(svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents:
7988
diff
changeset
|
593 |
const Vehicle *u_p = v->Previous(); |
7988
6075538f6111
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7823
diff
changeset
|
594 |
const Vehicle *u_n = v->Next(); |
7085
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
595 |
DirDiff f = (u_p == NULL) ? DIRDIFF_SAME : DirDifference(u_p->direction, v->direction); |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
596 |
DirDiff b = (u_n == NULL) ? DIRDIFF_SAME : DirDifference(v->direction, u_n->direction); |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
597 |
DirDiff t = ChangeDirDiff(f, b); |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
598 |
|
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
599 |
return ((t > DIRDIFF_REVERSE ? t | 8 : t) << 16) | |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
600 |
((b > DIRDIFF_REVERSE ? b | 8 : b) << 8) | |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
601 |
( f > DIRDIFF_REVERSE ? f | 8 : f); |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
602 |
} |
bb5d226fc24a
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
rubidium
parents:
7013
diff
changeset
|
603 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
604 |
case 0x46: // Motion counter |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4331
diff
changeset
|
605 |
return v->motion_counter; |
3723
e999035b1172
(svn r4696) - NewGRF: add support for vehicle variable 0x60, count vehicle type occurance.
peter1138
parents:
3720
diff
changeset
|
606 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
607 |
case 0x47: { // Vehicle cargo info |
3848
8cc088ddcfce
(svn r4872) - NewGRF: add support for vehicle variable 0x47 (mart3p)
peter1138
parents:
3845
diff
changeset
|
608 |
/* Format: ccccwwtt |
8cc088ddcfce
(svn r4872) - NewGRF: add support for vehicle variable 0x47 (mart3p)
peter1138
parents:
3845
diff
changeset
|
609 |
* tt - the cargo type transported by the vehicle, |
8cc088ddcfce
(svn r4872) - NewGRF: add support for vehicle variable 0x47 (mart3p)
peter1138
parents:
3845
diff
changeset
|
610 |
* translated if a translation table has been installed. |
8cc088ddcfce
(svn r4872) - NewGRF: add support for vehicle variable 0x47 (mart3p)
peter1138
parents:
3845
diff
changeset
|
611 |
* ww - cargo unit weight in 1/16 tons, same as cargo prop. 0F. |
8cc088ddcfce
(svn r4872) - NewGRF: add support for vehicle variable 0x47 (mart3p)
peter1138
parents:
3845
diff
changeset
|
612 |
* cccc - the cargo class value of the cargo transported by the vehicle. |
8cc088ddcfce
(svn r4872) - NewGRF: add support for vehicle variable 0x47 (mart3p)
peter1138
parents:
3845
diff
changeset
|
613 |
*/ |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6358
diff
changeset
|
614 |
const CargoSpec *cs = GetCargo(v->cargo_type); |
3848
8cc088ddcfce
(svn r4872) - NewGRF: add support for vehicle variable 0x47 (mart3p)
peter1138
parents:
3845
diff
changeset
|
615 |
|
6473
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6452
diff
changeset
|
616 |
return (cs->classes << 16) | (cs->weight << 8) | GetEngineGRF(v->engine_type)->cargo_map[v->cargo_type]; |
3848
8cc088ddcfce
(svn r4872) - NewGRF: add support for vehicle variable 0x47 (mart3p)
peter1138
parents:
3845
diff
changeset
|
617 |
} |
8cc088ddcfce
(svn r4872) - NewGRF: add support for vehicle variable 0x47 (mart3p)
peter1138
parents:
3845
diff
changeset
|
618 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
619 |
case 0x48: return GetEngine(v->engine_type)->flags; // Vehicle Type Info |
10825
e9b5f2644bb8
(svn r13376) -Feature: Add access to current long year and date from Action 7/9/D and VarAction2 (23/24 or A3/A4)
belugas
parents:
10800
diff
changeset
|
620 |
case 0x49: return v->build_year; |
4058
019da48e79d3
(svn r5338) - NewGRF: add support for vehicle variable 48, vehicle type info (more mart3p)
peter1138
parents:
4057
diff
changeset
|
621 |
|
3723
e999035b1172
(svn r4696) - NewGRF: add support for vehicle variable 0x60, count vehicle type occurance.
peter1138
parents:
3720
diff
changeset
|
622 |
/* Variables which use the parameter */ |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
623 |
case 0x60: // Count consist's engine ID occurance |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
624 |
//EngineID engine = GetNewEngineID(GetEngineGRF(v->engine_type), v->type, parameter); |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
625 |
if (v->type != VEH_TRAIN) return GetEngine(v->engine_type)->internal_id == parameter; |
3723
e999035b1172
(svn r4696) - NewGRF: add support for vehicle variable 0x60, count vehicle type occurance.
peter1138
parents:
3720
diff
changeset
|
626 |
|
e999035b1172
(svn r4696) - NewGRF: add support for vehicle variable 0x60, count vehicle type occurance.
peter1138
parents:
3720
diff
changeset
|
627 |
{ |
e999035b1172
(svn r4696) - NewGRF: add support for vehicle variable 0x60, count vehicle type occurance.
peter1138
parents:
3720
diff
changeset
|
628 |
uint count = 0; |
7988
6075538f6111
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7823
diff
changeset
|
629 |
for (; v != NULL; v = v->Next()) { |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
630 |
if (GetEngine(v->engine_type)->internal_id == parameter) count++; |
3723
e999035b1172
(svn r4696) - NewGRF: add support for vehicle variable 0x60, count vehicle type occurance.
peter1138
parents:
3720
diff
changeset
|
631 |
} |
e999035b1172
(svn r4696) - NewGRF: add support for vehicle variable 0x60, count vehicle type occurance.
peter1138
parents:
3720
diff
changeset
|
632 |
return count; |
e999035b1172
(svn r4696) - NewGRF: add support for vehicle variable 0x60, count vehicle type occurance.
peter1138
parents:
3720
diff
changeset
|
633 |
} |
3925
0b0c1fc5535e
(svn r5060) - NewGRF: add support for variable 7F (retrieve GRF parameter) for vehicles
peter1138
parents:
3924
diff
changeset
|
634 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
635 |
case 0x7F: return GetGRFParameter(v->engine_type, parameter); // Read GRF parameter |
6502
7ca154aca2b7
(svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents:
6499
diff
changeset
|
636 |
|
7ca154aca2b7
(svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents:
6499
diff
changeset
|
637 |
case 0xFE: |
7ca154aca2b7
(svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents:
6499
diff
changeset
|
638 |
case 0xFF: { |
7ca154aca2b7
(svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents:
6499
diff
changeset
|
639 |
uint16 modflags = 0; |
7ca154aca2b7
(svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents:
6499
diff
changeset
|
640 |
|
9161
f88d089fa608
(svn r12330) -Feature: [NewGRF] vehicle variable FE bit 5 and 6
glx
parents:
9150
diff
changeset
|
641 |
if (v->type == VEH_TRAIN) { |
f88d089fa608
(svn r12330) -Feature: [NewGRF] vehicle variable FE bit 5 and 6
glx
parents:
9150
diff
changeset
|
642 |
const Vehicle *u = IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON) ? v->First() : v; |
f88d089fa608
(svn r12330) -Feature: [NewGRF] vehicle variable FE bit 5 and 6
glx
parents:
9150
diff
changeset
|
643 |
RailType railtype = GetRailType(v->tile); |
f88d089fa608
(svn r12330) -Feature: [NewGRF] vehicle variable FE bit 5 and 6
glx
parents:
9150
diff
changeset
|
644 |
bool powered = IsTrainEngine(v) || (IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON)); |
f88d089fa608
(svn r12330) -Feature: [NewGRF] vehicle variable FE bit 5 and 6
glx
parents:
9150
diff
changeset
|
645 |
bool has_power = powered && HasPowerOnRail(u->u.rail.railtype, railtype); |
f88d089fa608
(svn r12330) -Feature: [NewGRF] vehicle variable FE bit 5 and 6
glx
parents:
9150
diff
changeset
|
646 |
bool is_electric = powered && u->u.rail.railtype == RAILTYPE_ELECTRIC; |
9162
ec5f2f4eee15
(svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
glx
parents:
9161
diff
changeset
|
647 |
|
9161
f88d089fa608
(svn r12330) -Feature: [NewGRF] vehicle variable FE bit 5 and 6
glx
parents:
9150
diff
changeset
|
648 |
if (has_power) SetBit(modflags, 5); |
f88d089fa608
(svn r12330) -Feature: [NewGRF] vehicle variable FE bit 5 and 6
glx
parents:
9150
diff
changeset
|
649 |
if (is_electric && !has_power) SetBit(modflags, 6); |
9162
ec5f2f4eee15
(svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
glx
parents:
9161
diff
changeset
|
650 |
if (HasBit(v->u.rail.flags, VRF_TOGGLE_REVERSE)) SetBit(modflags, 8); |
9161
f88d089fa608
(svn r12330) -Feature: [NewGRF] vehicle variable FE bit 5 and 6
glx
parents:
9150
diff
changeset
|
651 |
} |
8427
143b0be22af1
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
652 |
if (HasBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE)) SetBit(modflags, 10); |
6502
7ca154aca2b7
(svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents:
6499
diff
changeset
|
653 |
|
7ca154aca2b7
(svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents:
6499
diff
changeset
|
654 |
return variable == 0xFE ? modflags : GB(modflags, 8, 8); |
7ca154aca2b7
(svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
maedhros
parents:
6499
diff
changeset
|
655 |
} |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
656 |
} |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
657 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
658 |
/* General vehicle properties */ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
659 |
switch (variable - 0x80) { |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
660 |
case 0x00: return v->type; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
661 |
case 0x01: return MapOldSubType(v); |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
662 |
case 0x04: return v->index; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
663 |
case 0x05: return GB(v->index, 8, 8); |
9335
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9332
diff
changeset
|
664 |
case 0x0A: return v->current_order.Pack(); |
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9332
diff
changeset
|
665 |
case 0x0B: return GB(v->current_order.Pack(), 8, 8); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
666 |
case 0x0C: return v->num_orders; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
667 |
case 0x0D: return v->cur_order_index; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
668 |
case 0x10: return v->load_unload_time_rem; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
669 |
case 0x11: return GB(v->load_unload_time_rem, 8, 8); |
4331
11de01553605
(svn r6013) -Fix: some newgrf properties returned the date in the new format where the newgrf's expect the original format. Thanks to michi_cc for finding these and providing the initial patch.
rubidium
parents:
4322
diff
changeset
|
670 |
case 0x12: return max(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR, 0); |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
671 |
case 0x13: return GB(max(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR, 0), 8, 8); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
672 |
case 0x14: return v->service_interval; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
673 |
case 0x15: return GB(v->service_interval, 8, 8); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
674 |
case 0x16: return v->last_station_visited; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
675 |
case 0x17: return v->tick_counter; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
676 |
case 0x18: return v->max_speed; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
677 |
case 0x19: return GB(v->max_speed, 8, 8); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
678 |
case 0x1A: return v->x_pos; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
679 |
case 0x1B: return GB(v->x_pos, 8, 8); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
680 |
case 0x1C: return v->y_pos; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
681 |
case 0x1D: return GB(v->y_pos, 8, 8); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
682 |
case 0x1E: return v->z_pos; |
4056
30ceffc75059
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents:
4055
diff
changeset
|
683 |
case 0x1F: return object->info_view ? DIR_W : v->direction; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
684 |
case 0x28: return v->cur_image; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
685 |
case 0x29: return GB(v->cur_image, 8, 8); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
686 |
case 0x32: return v->vehstatus; |
5175
509e0c13ed8a
(svn r7285) -Fix (r7282): Our vehstatus is a byte, not a word.
peter1138
parents:
5174
diff
changeset
|
687 |
case 0x33: return 0; // non-existent high byte of vehstatus |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
688 |
case 0x34: return v->cur_speed; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
689 |
case 0x35: return GB(v->cur_speed, 8, 8); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
690 |
case 0x36: return v->subspeed; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
691 |
case 0x37: return v->acceleration; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
692 |
case 0x39: return v->cargo_type; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
693 |
case 0x3A: return v->cargo_cap; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
694 |
case 0x3B: return GB(v->cargo_cap, 8, 8); |
7506
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7486
diff
changeset
|
695 |
case 0x3C: return v->cargo.Count(); |
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7486
diff
changeset
|
696 |
case 0x3D: return GB(v->cargo.Count(), 8, 8); |
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7486
diff
changeset
|
697 |
case 0x3E: return v->cargo.Source(); |
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7486
diff
changeset
|
698 |
case 0x3F: return v->cargo.DaysInTransit(); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
699 |
case 0x40: return v->age; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
700 |
case 0x41: return GB(v->age, 8, 8); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
701 |
case 0x42: return v->max_age; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
702 |
case 0x43: return GB(v->max_age, 8, 8); |
8418
b49fc6be1ab9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
8377
diff
changeset
|
703 |
case 0x44: return Clamp(v->build_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
704 |
case 0x45: return v->unitnumber; |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
705 |
case 0x46: return GetEngine(v->engine_type)->internal_id; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
706 |
case 0x47: return GB(GetEngine(v->engine_type)->internal_id, 8, 8); |
10368
0d80bb08272e
(svn r12910) -Fix: Report reverse sprite status (FD/FE) to NewGRF for manually toggled vehicles.
peter1138
parents:
10331
diff
changeset
|
707 |
case 0x48: |
0d80bb08272e
(svn r12910) -Fix: Report reverse sprite status (FD/FE) to NewGRF for manually toggled vehicles.
peter1138
parents:
10331
diff
changeset
|
708 |
if (v->type != VEH_TRAIN || v->spritenum != 0xFD) return v->spritenum; |
0d80bb08272e
(svn r12910) -Fix: Report reverse sprite status (FD/FE) to NewGRF for manually toggled vehicles.
peter1138
parents:
10331
diff
changeset
|
709 |
return HasBit(v->u.rail.flags, VRF_REVERSE_DIRECTION) ? 0xFE : 0xFD; |
0d80bb08272e
(svn r12910) -Fix: Report reverse sprite status (FD/FE) to NewGRF for manually toggled vehicles.
peter1138
parents:
10331
diff
changeset
|
710 |
|
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
711 |
case 0x49: return v->day_counter; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
712 |
case 0x4A: return v->breakdowns_since_last_service; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
713 |
case 0x4B: return v->breakdown_ctr; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
714 |
case 0x4C: return v->breakdown_delay; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
715 |
case 0x4D: return v->breakdown_chance; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
716 |
case 0x4E: return v->reliability; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
717 |
case 0x4F: return GB(v->reliability, 8, 8); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
718 |
case 0x50: return v->reliability_spd_dec; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
719 |
case 0x51: return GB(v->reliability_spd_dec, 8, 8); |
9110
55864e1fc263
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents:
9095
diff
changeset
|
720 |
case 0x52: return ClampToI32(v->GetDisplayProfitThisYear()); |
55864e1fc263
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents:
9095
diff
changeset
|
721 |
case 0x53: return GB(ClampToI32(v->GetDisplayProfitThisYear()), 8, 24); |
55864e1fc263
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents:
9095
diff
changeset
|
722 |
case 0x54: return GB(ClampToI32(v->GetDisplayProfitThisYear()), 16, 16); |
55864e1fc263
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents:
9095
diff
changeset
|
723 |
case 0x55: return GB(ClampToI32(v->GetDisplayProfitThisYear()), 24, 8); |
55864e1fc263
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents:
9095
diff
changeset
|
724 |
case 0x56: return ClampToI32(v->GetDisplayProfitLastYear()); |
55864e1fc263
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents:
9095
diff
changeset
|
725 |
case 0x57: return GB(ClampToI32(v->GetDisplayProfitLastYear()), 8, 24); |
55864e1fc263
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents:
9095
diff
changeset
|
726 |
case 0x58: return GB(ClampToI32(v->GetDisplayProfitLastYear()), 16, 16); |
55864e1fc263
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz
parents:
9095
diff
changeset
|
727 |
case 0x59: return GB(ClampToI32(v->GetDisplayProfitLastYear()), 24, 8); |
7988
6075538f6111
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7823
diff
changeset
|
728 |
case 0x5A: return v->Next() == NULL ? INVALID_VEHICLE : v->Next()->index; |
7486
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7408
diff
changeset
|
729 |
case 0x5C: return ClampToI32(v->value); |
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7408
diff
changeset
|
730 |
case 0x5D: return GB(ClampToI32(v->value), 8, 24); |
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7408
diff
changeset
|
731 |
case 0x5E: return GB(ClampToI32(v->value), 16, 16); |
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7408
diff
changeset
|
732 |
case 0x5F: return GB(ClampToI32(v->value), 24, 8); |
3870
766d7bd6c299
(svn r4910) - NewGRF: add and initialize cargo subtype for vehicle visual variations
peter1138
parents:
3866
diff
changeset
|
733 |
case 0x72: return v->cargo_subtype; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
734 |
case 0x7A: return v->random_bits; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
735 |
case 0x7B: return v->waiting_triggers; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
736 |
} |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
737 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
738 |
/* Vehicle specific properties */ |
3014
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
739 |
switch (v->type) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
740 |
case VEH_TRAIN: |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
741 |
switch (variable - 0x80) { |
3014
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
742 |
case 0x62: return v->u.rail.track; |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
743 |
case 0x66: return v->u.rail.railtype; |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
744 |
case 0x73: return v->u.rail.cached_veh_length; |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
745 |
case 0x74: return v->u.rail.cached_power; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
746 |
case 0x75: return GB(v->u.rail.cached_power, 8, 24); |
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
747 |
case 0x76: return GB(v->u.rail.cached_power, 16, 16); |
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
748 |
case 0x77: return GB(v->u.rail.cached_power, 24, 8); |
7993
76b0eb3e19c9
(svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents:
7988
diff
changeset
|
749 |
case 0x7C: return v->First()->index; |
76b0eb3e19c9
(svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents:
7988
diff
changeset
|
750 |
case 0x7D: return GB(v->First()->index, 8, 8); |
4050
b03689c406ff
(svn r5320) - NewGRF: make sets using TTDPatch's train reversing hack/feature happier (and consistent) by returning 0 for the flag it uses.
peter1138
parents:
4023
diff
changeset
|
751 |
case 0x7F: return 0; // Used for vehicle reversing hack in TTDP |
3014
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
752 |
} |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
753 |
break; |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
754 |
|
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
755 |
case VEH_ROAD: |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
756 |
switch (variable - 0x80) { |
3014
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
757 |
case 0x62: return v->u.road.state; |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
758 |
case 0x64: return v->u.road.blocked_ctr; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
759 |
case 0x65: return GB(v->u.road.blocked_ctr, 8, 8); |
3014
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
760 |
case 0x66: return v->u.road.overtaking; |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
761 |
case 0x67: return v->u.road.overtaking_ctr; |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
762 |
case 0x68: return v->u.road.crashed_ctr; |
5172
7e64b65d3c54
(svn r7282) -Fix (r625): ttdpatch vars are little endian
peter1138
parents:
4901
diff
changeset
|
763 |
case 0x69: return GB(v->u.road.crashed_ctr, 8, 8); |
3014
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
764 |
} |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
765 |
break; |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
766 |
|
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
767 |
case VEH_AIRCRAFT: |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
768 |
switch (variable - 0x80) { |
3702
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
769 |
case 0x62: return MapAircraftMovementState(v); // Current movement state |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
770 |
case 0x63: return v->u.air.targetairport; // Airport to which the action refers |
b4ba84e5beef
(svn r4643) - NewGRF: Add support for ttdp aircraft states. This involves mapping from our own state. (heavily based on mart3p's code)
peter1138
parents:
3696
diff
changeset
|
771 |
case 0x66: return MapAircraftMovementAction(v); // Current movement action |
3014
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
772 |
} |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
773 |
break; |
7117
866a75f1ac5e
(svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents:
7100
diff
changeset
|
774 |
|
866a75f1ac5e
(svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents:
7100
diff
changeset
|
775 |
default: break; |
3014
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
776 |
} |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
777 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5338
diff
changeset
|
778 |
DEBUG(grf, 1, "Unhandled vehicle property 0x%X, type 0x%X", variable, v->type); |
3014
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
779 |
|
3893
46169364701b
(svn r4960) - NewGRF: explicitly handle unsupported variables, instead of returning -1.
peter1138
parents:
3870
diff
changeset
|
780 |
*available = false; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
781 |
return UINT_MAX; |
3014
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
782 |
} |
fbbc1ea2a1c9
(svn r3594) - NewGRF: Add support for some vehicle specific properties and a give a debug message for unknown variables.
peter1138
parents:
2982
diff
changeset
|
783 |
|
426
bd6f3c2cad9f
(svn r625) Almost complete support for deterministic variational vehicle spritegroups. (pasky)
tron
parents:
414
diff
changeset
|
784 |
|
3734
f929883c5ae0
(svn r4714) - NewGRF: simplify evaluation of 'real' sprite groups.
peter1138
parents:
3731
diff
changeset
|
785 |
static const SpriteGroup *VehicleResolveReal(const ResolverObject *object, const SpriteGroup *group) |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
786 |
{ |
3720
755978f398d9
(svn r4691) - Codechange: don't use unnamed unions as GCC 2.95.ancient won't compile it. Needed for our MorphOS user ;)
peter1138
parents:
3706
diff
changeset
|
787 |
const Vehicle *v = object->u.vehicle.self; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
788 |
uint totalsets; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
789 |
uint set; |
426
bd6f3c2cad9f
(svn r625) Almost complete support for deterministic variational vehicle spritegroups. (pasky)
tron
parents:
414
diff
changeset
|
790 |
|
9095
b5b66a0bbd2c
(svn r12180) -Fix: Test purchase list loading/loaded sprites instead of unconditionally returning a possibly non-existant sprite.
peter1138
parents:
9052
diff
changeset
|
791 |
if (v == NULL) { |
b5b66a0bbd2c
(svn r12180) -Fix: Test purchase list loading/loaded sprites instead of unconditionally returning a possibly non-existant sprite.
peter1138
parents:
9052
diff
changeset
|
792 |
if (group->g.real.num_loading > 0) return group->g.real.loading[0]; |
b5b66a0bbd2c
(svn r12180) -Fix: Test purchase list loading/loaded sprites instead of unconditionally returning a possibly non-existant sprite.
peter1138
parents:
9052
diff
changeset
|
793 |
if (group->g.real.num_loaded > 0) return group->g.real.loaded[0]; |
b5b66a0bbd2c
(svn r12180) -Fix: Test purchase list loading/loaded sprites instead of unconditionally returning a possibly non-existant sprite.
peter1138
parents:
9052
diff
changeset
|
794 |
return NULL; |
b5b66a0bbd2c
(svn r12180) -Fix: Test purchase list loading/loaded sprites instead of unconditionally returning a possibly non-existant sprite.
peter1138
parents:
9052
diff
changeset
|
795 |
} |
3734
f929883c5ae0
(svn r4714) - NewGRF: simplify evaluation of 'real' sprite groups.
peter1138
parents:
3731
diff
changeset
|
796 |
|
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9282
diff
changeset
|
797 |
bool in_motion = !v->First()->current_order.IsType(OT_LOADING); |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
798 |
|
3734
f929883c5ae0
(svn r4714) - NewGRF: simplify evaluation of 'real' sprite groups.
peter1138
parents:
3731
diff
changeset
|
799 |
totalsets = in_motion ? group->g.real.num_loaded : group->g.real.num_loading; |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
800 |
|
8689
ef053e1c6940
(svn r11756) -Fix: Out of bounds access caused if a vehicle's cargo amount was higher than its capacity when resolving sprite groups.
peter1138
parents:
8640
diff
changeset
|
801 |
if (v->cargo.Count() >= v->cargo_cap || totalsets == 1) { |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
802 |
set = totalsets - 1; |
7506
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7486
diff
changeset
|
803 |
} else if (v->cargo.Empty() || totalsets == 2) { |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
804 |
set = 0; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
805 |
} else { |
7506
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7486
diff
changeset
|
806 |
set = v->cargo.Count() * (totalsets - 2) / max((uint16)1, v->cargo_cap) + 1; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
807 |
} |
426
bd6f3c2cad9f
(svn r625) Almost complete support for deterministic variational vehicle spritegroups. (pasky)
tron
parents:
414
diff
changeset
|
808 |
|
3734
f929883c5ae0
(svn r4714) - NewGRF: simplify evaluation of 'real' sprite groups.
peter1138
parents:
3731
diff
changeset
|
809 |
return in_motion ? group->g.real.loaded[set] : group->g.real.loading[set]; |
426
bd6f3c2cad9f
(svn r625) Almost complete support for deterministic variational vehicle spritegroups. (pasky)
tron
parents:
414
diff
changeset
|
810 |
} |
bd6f3c2cad9f
(svn r625) Almost complete support for deterministic variational vehicle spritegroups. (pasky)
tron
parents:
414
diff
changeset
|
811 |
|
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
812 |
|
4057
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
813 |
static inline void NewVehicleResolver(ResolverObject *res, EngineID engine_type, const Vehicle *v) |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
814 |
{ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
815 |
res->GetRandomBits = &VehicleGetRandomBits; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
816 |
res->GetTriggers = &VehicleGetTriggers; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
817 |
res->SetTriggers = &VehicleSetTriggers; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
818 |
res->GetVariable = &VehicleGetVariable; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
819 |
res->ResolveReal = &VehicleResolveReal; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
820 |
|
3720
755978f398d9
(svn r4691) - Codechange: don't use unnamed unions as GCC 2.95.ancient won't compile it. Needed for our MorphOS user ;)
peter1138
parents:
3706
diff
changeset
|
821 |
res->u.vehicle.self = v; |
8044
72c3e2bc6429
(svn r11068) -Codechange: remove Vehicle::HasFront as all vehicles have the Vehicle::first pointer correctly set.
rubidium
parents:
7993
diff
changeset
|
822 |
res->u.vehicle.parent = (v != NULL) ? v->First() : v; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
823 |
|
4057
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
824 |
res->u.vehicle.self_type = engine_type; |
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
825 |
|
4056
30ceffc75059
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents:
4055
diff
changeset
|
826 |
res->info_view = false; |
30ceffc75059
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents:
4055
diff
changeset
|
827 |
|
7823
cad4dec2b899
(svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.
rubidium
parents:
7665
diff
changeset
|
828 |
res->callback = CBID_NO_CALLBACK; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
829 |
res->callback_param1 = 0; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
830 |
res->callback_param2 = 0; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
831 |
res->last_value = 0; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
832 |
res->trigger = 0; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
833 |
res->reseed = 0; |
9252
92e05c28a994
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
9162
diff
changeset
|
834 |
res->count = 0; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
835 |
} |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
836 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
837 |
|
4901
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
838 |
/** Retrieve the SpriteGroup for the specified vehicle. |
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
839 |
* If the vehicle is not specified, the purchase list group for the engine is |
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
840 |
* chosen. For trains, an additional engine override lookup is performed. |
8359
82c8bb4890db
(svn r11413) -Fix [FS#1405]: don't use cached override spriteset for callbacks
glx
parents:
8357
diff
changeset
|
841 |
* @param engine Engine type of the vehicle. |
82c8bb4890db
(svn r11413) -Fix [FS#1405]: don't use cached override spriteset for callbacks
glx
parents:
8357
diff
changeset
|
842 |
* @param v The vehicle itself. |
82c8bb4890db
(svn r11413) -Fix [FS#1405]: don't use cached override spriteset for callbacks
glx
parents:
8357
diff
changeset
|
843 |
* @param use_cache Use cached override |
82c8bb4890db
(svn r11413) -Fix [FS#1405]: don't use cached override spriteset for callbacks
glx
parents:
8357
diff
changeset
|
844 |
* @returns The selected SpriteGroup for the vehicle. |
4901
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
845 |
*/ |
8359
82c8bb4890db
(svn r11413) -Fix [FS#1405]: don't use cached override spriteset for callbacks
glx
parents:
8357
diff
changeset
|
846 |
static const SpriteGroup *GetVehicleSpriteGroup(EngineID engine, const Vehicle *v, bool use_cache = true) |
4901
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
847 |
{ |
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
848 |
const SpriteGroup *group; |
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
849 |
CargoID cargo; |
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
850 |
|
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
851 |
if (v == NULL) { |
6474
24e7ceeb25f5
(svn r8891) -Codechange: Remove remains of global cargo scheme. All cargo mapping is now dealt with only in NewGRF code, on load where possible.
peter1138
parents:
6473
diff
changeset
|
852 |
cargo = CT_PURCHASE; |
4901
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
853 |
} else { |
6474
24e7ceeb25f5
(svn r8891) -Codechange: Remove remains of global cargo scheme. All cargo mapping is now dealt with only in NewGRF code, on load where possible.
peter1138
parents:
6473
diff
changeset
|
854 |
cargo = v->cargo_type; |
4901
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
855 |
|
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
856 |
if (v->type == VEH_TRAIN) { |
8359
82c8bb4890db
(svn r11413) -Fix [FS#1405]: don't use cached override spriteset for callbacks
glx
parents:
8357
diff
changeset
|
857 |
/* We always use cached value, except for callbacks because the override spriteset |
82c8bb4890db
(svn r11413) -Fix [FS#1405]: don't use cached override spriteset for callbacks
glx
parents:
8357
diff
changeset
|
858 |
* to use may be different than the one cached. It happens for callback 0x15 (refit engine), |
82c8bb4890db
(svn r11413) -Fix [FS#1405]: don't use cached override spriteset for callbacks
glx
parents:
8357
diff
changeset
|
859 |
* as v->cargo_type is temporary changed to the new type */ |
82c8bb4890db
(svn r11413) -Fix [FS#1405]: don't use cached override spriteset for callbacks
glx
parents:
8357
diff
changeset
|
860 |
group = use_cache ? v->u.rail.cached_override : GetWagonOverrideSpriteSet(v->engine_type, v->cargo_type, v->u.rail.first_engine); |
4901
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
861 |
if (group != NULL) return group; |
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
862 |
} |
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
863 |
} |
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
864 |
|
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
865 |
const Engine *e = GetEngine(engine); |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
866 |
|
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
867 |
group = e->group[cargo]; |
4901
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
868 |
if (group != NULL) return group; |
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
869 |
|
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
870 |
/* Fall back to the default set if the selected cargo type is not defined */ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
871 |
return e->group[CT_DEFAULT]; |
4901
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
872 |
} |
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
873 |
|
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
874 |
|
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
875 |
SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction direction) |
0 | 876 |
{ |
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
877 |
const SpriteGroup *group; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
878 |
ResolverObject object; |
0 | 879 |
|
4057
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
880 |
NewVehicleResolver(&object, engine, v); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
881 |
|
4901
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
882 |
group = Resolve(GetVehicleSpriteGroup(engine, v), &object); |
10846
cd5463104792
(svn r13397) -Fix: Do not crash when resolving vehicle sprite groups with zero sprites.
frosch
parents:
10826
diff
changeset
|
883 |
if (group == NULL || group->type != SGT_RESULT || group->g.result.num_sprites == 0) return 0; |
3668
d7ed0a867b49
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3648
diff
changeset
|
884 |
|
d7ed0a867b49
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3648
diff
changeset
|
885 |
return group->g.result.sprite + (direction % group->g.result.num_sprites); |
0 | 886 |
} |
887 |
||
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
888 |
|
4056
30ceffc75059
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents:
4055
diff
changeset
|
889 |
SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle *v, bool info_view) |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
890 |
{ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
891 |
const Engine *e = GetEngine(engine); |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
892 |
|
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
893 |
/* Only valid for helicopters */ |
10800
5629c1896792
(svn r13351) -Codechange: disable warnings about unused variable for builds without asserts
smatz
parents:
10775
diff
changeset
|
894 |
assert(e->type == VEH_AIRCRAFT); |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
895 |
assert(!(e->u.air.subtype & AIR_CTOL)); |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
896 |
|
10800
5629c1896792
(svn r13351) -Codechange: disable warnings about unused variable for builds without asserts
smatz
parents:
10775
diff
changeset
|
897 |
ResolverObject object; |
5629c1896792
(svn r13351) -Codechange: disable warnings about unused variable for builds without asserts
smatz
parents:
10775
diff
changeset
|
898 |
|
4057
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
899 |
NewVehicleResolver(&object, engine, v); |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
900 |
|
4056
30ceffc75059
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents:
4055
diff
changeset
|
901 |
object.info_view = info_view; |
30ceffc75059
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents:
4055
diff
changeset
|
902 |
|
10800
5629c1896792
(svn r13351) -Codechange: disable warnings about unused variable for builds without asserts
smatz
parents:
10775
diff
changeset
|
903 |
const SpriteGroup *group = GetWagonOverrideSpriteSet(engine, CT_DEFAULT, engine); |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
904 |
group = Resolve(group, &object); |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
905 |
|
10846
cd5463104792
(svn r13397) -Fix: Do not crash when resolving vehicle sprite groups with zero sprites.
frosch
parents:
10826
diff
changeset
|
906 |
if (group == NULL || group->type != SGT_RESULT || group->g.result.num_sprites == 0) return 0; |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
907 |
|
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
908 |
if (v == NULL) return group->g.result.sprite; |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
909 |
|
7988
6075538f6111
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7823
diff
changeset
|
910 |
return group->g.result.sprite + (info_view ? 0 : (v->Next()->Next()->u.air.state % group->g.result.num_sprites)); |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
911 |
} |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
912 |
|
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3693
diff
changeset
|
913 |
|
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
914 |
/** |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1904
diff
changeset
|
915 |
* Check if a wagon is currently using a wagon override |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1904
diff
changeset
|
916 |
* @param v The wagon to check |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1904
diff
changeset
|
917 |
* @return true if it is using an override, false otherwise |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1904
diff
changeset
|
918 |
*/ |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2530
diff
changeset
|
919 |
bool UsesWagonOverride(const Vehicle* v) |
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2530
diff
changeset
|
920 |
{ |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
921 |
assert(v->type == VEH_TRAIN); |
7099
1528b11097af
(svn r9818) -Codechange: Cache wagon override sprite set whenever consist is changed, instead of 'recalculating' it every time it is used or just tested.
peter1138
parents:
7085
diff
changeset
|
922 |
return v->u.rail.cached_override != NULL; |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1904
diff
changeset
|
923 |
} |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1904
diff
changeset
|
924 |
|
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1904
diff
changeset
|
925 |
/** |
3390
f910bc27153e
(svn r4198) - NewGRF: Rename GetCallBackResult() to GetVehicleCallback(), as other types will exist later, and use separate parameters instead of bitshifting.
peter1138
parents:
3348
diff
changeset
|
926 |
* Evaluate a newgrf callback for vehicles |
f910bc27153e
(svn r4198) - NewGRF: Rename GetCallBackResult() to GetVehicleCallback(), as other types will exist later, and use separate parameters instead of bitshifting.
peter1138
parents:
3348
diff
changeset
|
927 |
* @param callback The callback to evalute |
f910bc27153e
(svn r4198) - NewGRF: Rename GetCallBackResult() to GetVehicleCallback(), as other types will exist later, and use separate parameters instead of bitshifting.
peter1138
parents:
3348
diff
changeset
|
928 |
* @param param1 First parameter of the callback |
f910bc27153e
(svn r4198) - NewGRF: Rename GetCallBackResult() to GetVehicleCallback(), as other types will exist later, and use separate parameters instead of bitshifting.
peter1138
parents:
3348
diff
changeset
|
929 |
* @param param2 Second parameter of the callback |
f910bc27153e
(svn r4198) - NewGRF: Rename GetCallBackResult() to GetVehicleCallback(), as other types will exist later, and use separate parameters instead of bitshifting.
peter1138
parents:
3348
diff
changeset
|
930 |
* @param engine Engine type of the vehicle to evaluate the callback for |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6674
diff
changeset
|
931 |
* @param v The vehicle to evaluate the callback for, or NULL if it doesnt exist yet |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
932 |
* @return The value the callback returned, or CALLBACK_FAILED if it failed |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
933 |
*/ |
7823
cad4dec2b899
(svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.
rubidium
parents:
7665
diff
changeset
|
934 |
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v) |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
935 |
{ |
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
936 |
const SpriteGroup *group; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
937 |
ResolverObject object; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
938 |
|
4057
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
939 |
NewVehicleResolver(&object, engine, v); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
940 |
|
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
941 |
object.callback = callback; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
942 |
object.callback_param1 = param1; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
943 |
object.callback_param2 = param2; |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
944 |
|
8359
82c8bb4890db
(svn r11413) -Fix [FS#1405]: don't use cached override spriteset for callbacks
glx
parents:
8357
diff
changeset
|
945 |
group = Resolve(GetVehicleSpriteGroup(engine, v, false), &object); |
4811
5149ead9b1d5
(svn r6735) - Codestyle: Just some tidying up...
peter1138
parents:
4656
diff
changeset
|
946 |
if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED; |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
947 |
|
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
948 |
return group->g.callback.result; |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
949 |
} |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
950 |
|
3726
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
951 |
/** |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
952 |
* Evaluate a newgrf callback for vehicles with a different vehicle for parent scope. |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
953 |
* @param callback The callback to evalute |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
954 |
* @param param1 First parameter of the callback |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
955 |
* @param param2 Second parameter of the callback |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
956 |
* @param engine Engine type of the vehicle to evaluate the callback for |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
957 |
* @param v The vehicle to evaluate the callback for, or NULL if it doesnt exist yet |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
958 |
* @param parent The vehicle to use for parent scope |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
959 |
* @return The value the callback returned, or CALLBACK_FAILED if it failed |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
960 |
*/ |
7823
cad4dec2b899
(svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.
rubidium
parents:
7665
diff
changeset
|
961 |
uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent) |
3726
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
962 |
{ |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
963 |
const SpriteGroup *group; |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
964 |
ResolverObject object; |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
965 |
|
4057
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
966 |
NewVehicleResolver(&object, engine, v); |
3726
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
967 |
|
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
968 |
object.callback = callback; |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
969 |
object.callback_param1 = param1; |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
970 |
object.callback_param2 = param2; |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
971 |
|
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
972 |
object.u.vehicle.parent = parent; |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
973 |
|
8359
82c8bb4890db
(svn r11413) -Fix [FS#1405]: don't use cached override spriteset for callbacks
glx
parents:
8357
diff
changeset
|
974 |
group = Resolve(GetVehicleSpriteGroup(engine, v, false), &object); |
4811
5149ead9b1d5
(svn r6735) - Codestyle: Just some tidying up...
peter1138
parents:
4656
diff
changeset
|
975 |
if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED; |
3726
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
976 |
|
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
977 |
return group->g.callback.result; |
a446208c7296
(svn r4702) - NewGRF: add support for 'special' vehicle callbacks that use a different vehicle for parent scope than the first vehicle in the consist.
peter1138
parents:
3724
diff
changeset
|
978 |
} |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
979 |
|
6986
168d3add1f13
(svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents:
6977
diff
changeset
|
980 |
|
7013
fb8489ae2770
(svn r9703) -Codechange: support callback 36 in vehicle purchase lists
peter1138
parents:
7012
diff
changeset
|
981 |
/* Callback 36 handlers */ |
6986
168d3add1f13
(svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents:
6977
diff
changeset
|
982 |
uint GetVehicleProperty(const Vehicle *v, uint8 property, uint orig_value) |
168d3add1f13
(svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents:
6977
diff
changeset
|
983 |
{ |
168d3add1f13
(svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents:
6977
diff
changeset
|
984 |
uint16 callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, v->engine_type, v); |
168d3add1f13
(svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents:
6977
diff
changeset
|
985 |
if (callback != CALLBACK_FAILED) return callback; |
168d3add1f13
(svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents:
6977
diff
changeset
|
986 |
|
168d3add1f13
(svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents:
6977
diff
changeset
|
987 |
return orig_value; |
168d3add1f13
(svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents:
6977
diff
changeset
|
988 |
} |
168d3add1f13
(svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents:
6977
diff
changeset
|
989 |
|
168d3add1f13
(svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents:
6977
diff
changeset
|
990 |
|
7013
fb8489ae2770
(svn r9703) -Codechange: support callback 36 in vehicle purchase lists
peter1138
parents:
7012
diff
changeset
|
991 |
uint GetEngineProperty(EngineID engine, uint8 property, uint orig_value) |
fb8489ae2770
(svn r9703) -Codechange: support callback 36 in vehicle purchase lists
peter1138
parents:
7012
diff
changeset
|
992 |
{ |
fb8489ae2770
(svn r9703) -Codechange: support callback 36 in vehicle purchase lists
peter1138
parents:
7012
diff
changeset
|
993 |
uint16 callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, engine, NULL); |
fb8489ae2770
(svn r9703) -Codechange: support callback 36 in vehicle purchase lists
peter1138
parents:
7012
diff
changeset
|
994 |
if (callback != CALLBACK_FAILED) return callback; |
fb8489ae2770
(svn r9703) -Codechange: support callback 36 in vehicle purchase lists
peter1138
parents:
7012
diff
changeset
|
995 |
|
fb8489ae2770
(svn r9703) -Codechange: support callback 36 in vehicle purchase lists
peter1138
parents:
7012
diff
changeset
|
996 |
return orig_value; |
fb8489ae2770
(svn r9703) -Codechange: support callback 36 in vehicle purchase lists
peter1138
parents:
7012
diff
changeset
|
997 |
} |
fb8489ae2770
(svn r9703) -Codechange: support callback 36 in vehicle purchase lists
peter1138
parents:
7012
diff
changeset
|
998 |
|
fb8489ae2770
(svn r9703) -Codechange: support callback 36 in vehicle purchase lists
peter1138
parents:
7012
diff
changeset
|
999 |
|
3680 | 1000 |
static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, byte base_random_bits, bool first) |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1001 |
{ |
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
1002 |
const SpriteGroup *group; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
1003 |
ResolverObject object; |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1004 |
byte new_random_bits; |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1005 |
|
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
1006 |
/* We can't trigger a non-existent vehicle... */ |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
1007 |
assert(v != NULL); |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
1008 |
|
4057
36ceb8e7cbd2
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
peter1138
parents:
4056
diff
changeset
|
1009 |
NewVehicleResolver(&object, v->engine_type, v); |
7665
ded23f6bc34c
(svn r10443) -Fix: randomizing triggers should be called with callback type set to 1
peter1138
parents:
7506
diff
changeset
|
1010 |
object.callback = CBID_RANDOM_TRIGGER; |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
1011 |
object.trigger = trigger; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
1012 |
|
4901
3f661c8faa1a
(svn r6870) - Codechange: (re-)unify the code to retrieve the sprite group for a vehicle.
peter1138
parents:
4869
diff
changeset
|
1013 |
group = Resolve(GetVehicleSpriteGroup(v->engine_type, v), &object); |
8357
279c5953ec04
(svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents:
8299
diff
changeset
|
1014 |
if (group == NULL) return; |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1881
diff
changeset
|
1015 |
|
542 | 1016 |
new_random_bits = Random(); |
3686
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
1017 |
v->random_bits &= ~object.reseed; |
55efe6da4dfb
(svn r4611) - NewGRF: introduce new vehicle sprite group resolver code. This also fixes some known bugs (e.g. the 'Standard Five' in UKRS is now the correct colour)
peter1138
parents:
3684
diff
changeset
|
1018 |
v->random_bits |= (first ? new_random_bits : base_random_bits) & object.reseed; |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1019 |
|
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1020 |
switch (trigger) { |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1021 |
case VEHICLE_TRIGGER_NEW_CARGO: |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1022 |
/* All vehicles in chain get ANY_NEW_CARGO trigger now. |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1023 |
* So we call it for the first one and they will recurse. */ |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1024 |
/* Indexing part of vehicle random bits needs to be |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1025 |
* same for all triggered vehicles in the chain (to get |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1026 |
* all the random-cargo wagons carry the same cargo, |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1027 |
* i.e.), so we give them all the NEW_CARGO triggered |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1028 |
* vehicle's portion of random bits. */ |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1029 |
assert(first); |
8046
41a55e6389c3
(svn r11070) -Fix [FS#1217]: due to making an Action2 variable work properly, the NewGRF called other code too that wasn't prepared for non-train vehicles.
rubidium
parents:
8044
diff
changeset
|
1030 |
DoTriggerVehicle(v->First(), VEHICLE_TRIGGER_ANY_NEW_CARGO, new_random_bits, false); |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1031 |
break; |
3680 | 1032 |
|
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1033 |
case VEHICLE_TRIGGER_DEPOT: |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1034 |
/* We now trigger the next vehicle in chain recursively. |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1035 |
* The random bits portions may be different for each |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1036 |
* vehicle in chain. */ |
7988
6075538f6111
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7823
diff
changeset
|
1037 |
if (v->Next() != NULL) DoTriggerVehicle(v->Next(), trigger, 0, true); |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1038 |
break; |
3680 | 1039 |
|
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1040 |
case VEHICLE_TRIGGER_EMPTY: |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1041 |
/* We now trigger the next vehicle in chain |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1042 |
* recursively. The random bits portions must be same |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1043 |
* for each vehicle in chain, so we give them all |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1044 |
* first chained vehicle's portion of random bits. */ |
7988
6075538f6111
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7823
diff
changeset
|
1045 |
if (v->Next() != NULL) DoTriggerVehicle(v->Next(), trigger, first ? new_random_bits : base_random_bits, false); |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1046 |
break; |
3680 | 1047 |
|
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1048 |
case VEHICLE_TRIGGER_ANY_NEW_CARGO: |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1049 |
/* Now pass the trigger recursively to the next vehicle |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1050 |
* in chain. */ |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1051 |
assert(!first); |
7988
6075538f6111
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7823
diff
changeset
|
1052 |
if (v->Next() != NULL) DoTriggerVehicle(v->Next(), VEHICLE_TRIGGER_ANY_NEW_CARGO, base_random_bits, false); |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1053 |
break; |
8299
d5c112dc0726
(svn r11353) -Codechange: add support for newgrf callback 32
glx
parents:
8046
diff
changeset
|
1054 |
|
d5c112dc0726
(svn r11353) -Codechange: add support for newgrf callback 32
glx
parents:
8046
diff
changeset
|
1055 |
case VEHICLE_TRIGGER_CALLBACK_32: |
d5c112dc0726
(svn r11353) -Codechange: add support for newgrf callback 32
glx
parents:
8046
diff
changeset
|
1056 |
/* Do not do any recursion */ |
d5c112dc0726
(svn r11353) -Codechange: add support for newgrf callback 32
glx
parents:
8046
diff
changeset
|
1057 |
break; |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1058 |
} |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1059 |
} |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1060 |
|
3680 | 1061 |
void TriggerVehicle(Vehicle *v, VehicleTrigger trigger) |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1062 |
{ |
2589
28c7b9b212af
(svn r3126) Autoreplace: Only the first vehicle in a chain should be marked as entering a depot, so call moved out of DoVehicleTrigger loop.
peter1138
parents:
2574
diff
changeset
|
1063 |
if (trigger == VEHICLE_TRIGGER_DEPOT) { |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
1064 |
/* store that the vehicle entered a depot this tick */ |
3680 | 1065 |
VehicleEnteredDepotThisTick(v); |
2589
28c7b9b212af
(svn r3126) Autoreplace: Only the first vehicle in a chain should be marked as entering a depot, so call moved out of DoVehicleTrigger loop.
peter1138
parents:
2574
diff
changeset
|
1066 |
} |
28c7b9b212af
(svn r3126) Autoreplace: Only the first vehicle in a chain should be marked as entering a depot, so call moved out of DoVehicleTrigger loop.
peter1138
parents:
2574
diff
changeset
|
1067 |
|
3680 | 1068 |
DoTriggerVehicle(v, trigger, 0, true); |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1069 |
} |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
433
diff
changeset
|
1070 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
1071 |
/* Functions for changing the order of vehicle purchase lists |
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6585
diff
changeset
|
1072 |
* This is currently only implemented for rail vehicles. */ |
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
1073 |
|
4812
dab5a9855b72
(svn r6736) - Add a function to get the list position of an engine ID, for use with sorting. This is basically a reversed version of GetRailVehAtPosition()
peter1138
parents:
4811
diff
changeset
|
1074 |
/** |
dab5a9855b72
(svn r6736) - Add a function to get the list position of an engine ID, for use with sorting. This is basically a reversed version of GetRailVehAtPosition()
peter1138
parents:
4811
diff
changeset
|
1075 |
* Get the list position of an engine. |
dab5a9855b72
(svn r6736) - Add a function to get the list position of an engine ID, for use with sorting. This is basically a reversed version of GetRailVehAtPosition()
peter1138
parents:
4811
diff
changeset
|
1076 |
* Used when sorting a list of engines. |
dab5a9855b72
(svn r6736) - Add a function to get the list position of an engine ID, for use with sorting. This is basically a reversed version of GetRailVehAtPosition()
peter1138
parents:
4811
diff
changeset
|
1077 |
* @param engine ID of the engine. |
dab5a9855b72
(svn r6736) - Add a function to get the list position of an engine ID, for use with sorting. This is basically a reversed version of GetRailVehAtPosition()
peter1138
parents:
4811
diff
changeset
|
1078 |
* @return The list position of the engine. |
dab5a9855b72
(svn r6736) - Add a function to get the list position of an engine ID, for use with sorting. This is basically a reversed version of GetRailVehAtPosition()
peter1138
parents:
4811
diff
changeset
|
1079 |
*/ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1080 |
uint ListPositionOfEngine(EngineID engine) |
4812
dab5a9855b72
(svn r6736) - Add a function to get the list position of an engine ID, for use with sorting. This is basically a reversed version of GetRailVehAtPosition()
peter1138
parents:
4811
diff
changeset
|
1081 |
{ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1082 |
const Engine *e = GetEngine(engine); |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1083 |
if (e->grffile == NULL) return e->list_position; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1084 |
|
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1085 |
/* Crude sorting to group by GRF ID */ |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1086 |
return (e->grffile->grfid * 256) + e->list_position; |
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
1087 |
} |
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
1088 |
|
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1089 |
struct ListOrderChange { |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1090 |
EngineID engine; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1091 |
EngineID target; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1092 |
}; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1093 |
|
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1094 |
static std::list<ListOrderChange> _list_order_changes; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1095 |
|
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
1096 |
void AlterRailVehListOrder(EngineID engine, EngineID target) |
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
1097 |
{ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1098 |
/* Add the list order change to a queue */ |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1099 |
ListOrderChange loc; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1100 |
loc.engine = engine; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1101 |
loc.target = target; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1102 |
_list_order_changes.push_back(loc); |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1103 |
} |
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
1104 |
|
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1105 |
void CommitRailVehListOrderChanges() |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1106 |
{ |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1107 |
/* List position to Engine map */ |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1108 |
typedef std::map<uint16, Engine*> ListPositionMap; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1109 |
ListPositionMap lptr_map; |
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
1110 |
|
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1111 |
std::list<ListOrderChange>::iterator it; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1112 |
for (it = _list_order_changes.begin(); it != _list_order_changes.end(); ++it) { |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1113 |
EngineID engine = it->engine; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1114 |
EngineID target = it->target; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1115 |
|
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1116 |
if (engine == target) continue; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1117 |
|
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1118 |
Engine *source_e = GetEngine(engine); |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1119 |
Engine *target_e = NULL; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1120 |
|
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1121 |
/* Populate map with current list positions */ |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1122 |
Engine *e; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1123 |
FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) { |
10775
7061477bfbcf
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
10703
diff
changeset
|
1124 |
if (!_settings_game.vehicle.dynamic_engines || e->grffile == source_e->grffile) { |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1125 |
if (e->internal_id == target) target_e = e; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1126 |
lptr_map[e->list_position] = e; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1127 |
} |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1128 |
} |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1129 |
|
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1130 |
/* Get the target position, if it exists */ |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1131 |
if (target_e != NULL) { |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1132 |
uint16 target_position = target_e->list_position; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1133 |
|
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1134 |
bool moving = false; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1135 |
for (ListPositionMap::iterator it = lptr_map.begin(); it != lptr_map.end(); ++it) { |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1136 |
if (it->first == target_position) moving = true; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1137 |
if (moving) it->second->list_position++; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1138 |
} |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1139 |
|
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1140 |
source_e->list_position = target_position; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1141 |
} |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1142 |
|
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1143 |
lptr_map.clear(); |
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
1144 |
} |
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
1145 |
|
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1146 |
/* Clear out the queue */ |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10373
diff
changeset
|
1147 |
_list_order_changes.clear(); |
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
1148 |
} |