author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6507 | ab8107a6c110 |
child 6515 | df4dba70cd68 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3 |
/** @file newgrf.cpp */ |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
6 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
7 |
#include <stdarg.h> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
8 |
|
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1883
diff
changeset
|
9 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1183
diff
changeset
|
10 |
#include "debug.h" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
11 |
#include "gfx.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
12 |
#include "fileio.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
13 |
#include "functions.h" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
14 |
#include "engine.h" |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
15 |
#include "spritecache.h" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
16 |
#include "station.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
17 |
#include "sprite.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
18 |
#include "newgrf.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2013
diff
changeset
|
19 |
#include "variables.h" |
3566
21db83574baf
(svn r4447) - NewGRF: It seems I committed printing action NOP Action 0x0C which is mainly used for comments. So leave it in, but fix the created warning. Use proper action name for check_length() in Action 0x10
Darkvater
parents:
3561
diff
changeset
|
20 |
#include "string.h" |
3821
57db5bab0f24
(svn r4832) - NewGRF: add support for original string ID to newgrf text handling. So far, this is used for vehicles when no English or American translation is provided.
peter1138
parents:
3814
diff
changeset
|
21 |
#include "table/strings.h" |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
22 |
#include "bridge.h" |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
23 |
#include "town.h" |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
24 |
#include "economy.h" |
2962
f0a49b646c48
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2958
diff
changeset
|
25 |
#include "newgrf_engine.h" |
3577
c6532e0bee4c
(svn r4463) -Codechange. Include vehicle.h directly instead of implicitly via station.h in a number of source files
celestar
parents:
3571
diff
changeset
|
26 |
#include "vehicle.h" |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
27 |
#include "newgrf_text.h" |
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
28 |
#include "table/sprites.h" |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
29 |
#include "fontcache.h" |
4293
4b7006c1b5eb
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4230
diff
changeset
|
30 |
#include "date.h" |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
31 |
#include "currency.h" |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
32 |
#include "landscape.h" |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
33 |
#include "sound.h" |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
34 |
#include "newgrf_config.h" |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
35 |
#include "newgrf_house.h" |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
36 |
#include "newgrf_sound.h" |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
37 |
#include "newgrf_spritegroup.h" |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
38 |
#include "helpers.hpp" |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
39 |
#include "table/town_land.h" |
6091
c8827d9ae04a
(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:
6090
diff
changeset
|
40 |
#include "cargotype.h" |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
41 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
42 |
/* TTDPatch extended GRF format codec |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
43 |
* (c) Petr Baudis 2004 (GPL'd) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
44 |
* Changes by Florian octo Forster are (c) by the OpenTTD development team. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
45 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
46 |
* Contains portions of documentation by TTDPatch team. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
47 |
* Thanks especially to Josef Drexler for the documentation as well as a lot |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
48 |
* of help at #tycoon. Also thanks to Michael Blunck for is GRF files which |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
49 |
* served as subject to the initial testing of this codec. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
50 |
|
455 | 51 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
52 |
static int _skip_sprites; // XXX |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
53 |
static uint _file_index; // XXX |
5209
1b7a72191019
(svn r7324) -Codechange: reset newgrf signal location data
peter1138
parents:
5161
diff
changeset
|
54 |
SpriteID _signal_base; |
5210
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
55 |
SpriteID _coast_base; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
56 |
|
2340
e18ef06bc59a
(svn r2866) Move all functions and tables which aren't directly involved in managing the sprite heap to a new file gfxinit.c.
tron
parents:
2336
diff
changeset
|
57 |
static GRFFile *_cur_grffile; |
1477 | 58 |
GRFFile *_first_grffile; |
3707
7dc7e4d2487e
(svn r4650) - NewGRF: use the correct type for _cur_spriteid
peter1138
parents:
3704
diff
changeset
|
59 |
static SpriteID _cur_spriteid; |
5225
af5d9de16c8d
(svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents:
5211
diff
changeset
|
60 |
static GrfLoadingStage _cur_stage; |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
61 |
static uint32 _nfo_line; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
62 |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
63 |
static GRFConfig *_cur_grfconfig; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
64 |
|
3814
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
65 |
/* Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E */ |
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
66 |
static byte _misc_grf_features = 0; |
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
67 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
68 |
/* 32 * 8 = 256 flags. Apparently TTDPatch uses this many.. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
69 |
static uint32 _ttdpatch_flags[8]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
70 |
|
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
71 |
/* Used by Action 0x06 to preload a pseudo sprite and modify its content */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
72 |
static byte *_preload_sprite = NULL; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
73 |
|
4742
d915db693186
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
74 |
/* Set if any vehicle is loaded which uses 2cc (two company colours) */ |
d915db693186
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
75 |
bool _have_2cc = false; |
d915db693186
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
76 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
77 |
/* Set if there are any newhouses loaded. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
78 |
bool _have_newhouses = false; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
79 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
80 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
81 |
enum GrfDataType { |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
82 |
GDT_SOUND, |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
83 |
}; |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
84 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
85 |
static byte _grf_data_blocks; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
86 |
static GrfDataType _grf_data_type; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
87 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
88 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
89 |
enum grfspec_feature { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
90 |
GSF_TRAIN, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
91 |
GSF_ROAD, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
92 |
GSF_SHIP, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
93 |
GSF_AIRCRAFT, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
94 |
GSF_STATION, |
2438
f0bf4adbd620
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
95 |
GSF_CANAL, |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
96 |
GSF_BRIDGE, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
97 |
GSF_TOWNHOUSE, |
3620
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
98 |
GSF_GLOBALVAR, |
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
99 |
GSF_INDUSTRYTILES, |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
100 |
GSF_INDUSTRIES, |
3620
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
101 |
GSF_CARGOS, |
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
102 |
GSF_SOUNDFX, |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
103 |
}; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
104 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
105 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
106 |
typedef void (*SpecialSpriteHandler)(byte *buf, int len); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
107 |
|
6281 | 108 |
static const uint _vehcounts[4] = { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
109 |
/* GSF_TRAIN */ NUM_TRAIN_ENGINES, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
110 |
/* GSF_ROAD */ NUM_ROAD_ENGINES, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
111 |
/* GSF_SHIP */ NUM_SHIP_ENGINES, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
112 |
/* GSF_AIRCRAFT */ NUM_AIRCRAFT_ENGINES |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
113 |
}; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
114 |
|
6281 | 115 |
static const uint _vehshifts[4] = { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
116 |
/* GSF_TRAIN */ 0, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
117 |
/* GSF_ROAD */ ROAD_ENGINES_INDEX, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
118 |
/* GSF_SHIP */ SHIP_ENGINES_INDEX, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
119 |
/* GSF_AIRCRAFT */ AIRCRAFT_ENGINES_INDEX, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
120 |
}; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
121 |
|
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
122 |
enum { |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
123 |
MAX_STATIONS = 256, |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
124 |
}; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
125 |
|
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
126 |
static uint16 cargo_allowed[TOTAL_NUM_ENGINES]; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
127 |
static uint16 cargo_disallowed[TOTAL_NUM_ENGINES]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
128 |
|
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
129 |
/* Contains the GRF ID of the owner of a vehicle if it has been reserved */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
130 |
static uint32 _grm_engines[TOTAL_NUM_ENGINES]; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
131 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
132 |
/** DEBUG() function dedicated to newGRF debugging messages |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
133 |
* Function is essentialy the same as DEBUG(grf, severity, ...) with the |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
134 |
* addition of file:line information when parsing grf files. |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
135 |
* NOTE: for the above reason(s) grfmsg() should ONLY be used for |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
136 |
* loading/parsing grf files, not for runtime debug messages as there |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
137 |
* is no file information available during that time. |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
138 |
* @param severity debugging severity level, see debug.h |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6479
diff
changeset
|
139 |
* @param str message in printf() format */ |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
140 |
void CDECL grfmsg(int severity, const char *str, ...) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
141 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
142 |
char buf[1024]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
143 |
va_list va; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
144 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
145 |
va_start(va, str); |
1477 | 146 |
vsnprintf(buf, sizeof(buf), str, va); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
147 |
va_end(va); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
148 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
149 |
DEBUG(grf, severity, "[%s:%d] %s", _cur_grfconfig->filename, _nfo_line, buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
150 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
151 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
152 |
static inline bool check_length(int real, int wanted, const char *str) |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
153 |
{ |
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
154 |
if (real >= wanted) return true; |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
155 |
grfmsg(0, "%s: Invalid pseudo sprite length %d (expected %d)!", str, real, wanted); |
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
156 |
return false; |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
157 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
158 |
|
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
490
diff
changeset
|
159 |
static inline byte grf_load_byte(byte **buf) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
160 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
161 |
return *(*buf)++; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
162 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
163 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
164 |
static uint16 grf_load_word(byte **buf) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
165 |
{ |
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
166 |
uint16 val = grf_load_byte(buf); |
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
167 |
return val | (grf_load_byte(buf) << 8); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
168 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
169 |
|
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
170 |
static uint16 grf_load_extended(byte** buf) |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
171 |
{ |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
172 |
uint16 val; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
173 |
val = grf_load_byte(buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
174 |
if (val == 0xFF) val = grf_load_word(buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
175 |
return val; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
176 |
} |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
177 |
|
2324 | 178 |
static uint32 grf_load_dword(byte **buf) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
179 |
{ |
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
180 |
uint32 val = grf_load_word(buf); |
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
181 |
return val | (grf_load_word(buf) << 16); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
182 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
183 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
184 |
static uint32 grf_load_var(byte size, byte **buf) |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
185 |
{ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
186 |
switch (size) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
187 |
case 1: return grf_load_byte(buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
188 |
case 2: return grf_load_word(buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
189 |
case 4: return grf_load_dword(buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
190 |
default: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
191 |
NOT_REACHED(); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
192 |
return 0; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
193 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
194 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
195 |
|
6090
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
196 |
static const char *grf_load_string(byte **buf, size_t max_len) |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
197 |
{ |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
198 |
const char *string = *(const char **)buf; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
199 |
size_t string_length = ttd_strnlen(string, max_len); |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
200 |
|
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
201 |
if (string_length == max_len) { |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
202 |
/* String was not NUL terminated, so make sure it is now. */ |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
203 |
(*buf)[string_length - 1] = '\0'; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
204 |
grfmsg(7, "String was not terminated with a zero byte."); |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
205 |
} else { |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
206 |
/* Increase the string length to include the NUL byte. */ |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
207 |
string_length++; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
208 |
} |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
209 |
*buf += string_length; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
210 |
|
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
211 |
return string; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
212 |
} |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
213 |
|
1477 | 214 |
static GRFFile *GetFileByGRFID(uint32 grfid) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
215 |
{ |
1477 | 216 |
GRFFile *file; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
217 |
|
1477 | 218 |
for (file = _first_grffile; file != NULL; file = file->next) { |
219 |
if (file->grfid == grfid) break; |
|
220 |
} |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
221 |
return file; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
222 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
223 |
|
1477 | 224 |
static GRFFile *GetFileByFilename(const char *filename) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
225 |
{ |
1477 | 226 |
GRFFile *file; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
227 |
|
1477 | 228 |
for (file = _first_grffile; file != NULL; file = file->next) { |
229 |
if (strcmp(file->filename, filename) == 0) break; |
|
230 |
} |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
231 |
return file; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
232 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
233 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
234 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
235 |
/** Used when setting an object's property to map to the GRF's strings |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
236 |
* while taking in consideration the "drift" between TTDPatch string system and OpenTTD's one |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6479
diff
changeset
|
237 |
* @param grfid Id of the grf file |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
238 |
* @param str StringID that we want to have the equivalent in OoenTTD |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
239 |
* @return the properly adjusted StringID |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
240 |
*/ |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
241 |
static StringID MapGRFStringID(uint32 grfid, StringID str) |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
242 |
{ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
243 |
/* 0xD0 and 0xDC stand for all the TextIDs in the range |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
244 |
* of 0xD000 (misc graphics texts) and 0xDC00 (misc persistent texts). |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
245 |
* These strings are unique to each grf file, and thus require to be used with the |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
246 |
* grfid in which they are declared */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
247 |
if (GB(str, 8, 8) == 0xD0 || GB(str, 8, 8) == 0xDC) { |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
248 |
return GetGRFStringID(grfid, str); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
249 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
250 |
|
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
251 |
/* We have some changes in our cargo strings, resulting in some missing. */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
252 |
if (str >= 0x006E && str <= 0x008D) return str - 0x20; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
253 |
if (str >= 0x008E && str <= 0x00AD) return str - 0x20; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
254 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
255 |
/* Map building names according to our lang file changes |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
256 |
* 0x200F = Tall Office Block, first house name in the original data, the one that TTDPatch stil uses |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
257 |
* 0x201F = Old houses is the last house name. |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
258 |
* OpenTTD does not have exactly the same order aymore, so, the code below allows |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
259 |
* to compensate for the difference */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
260 |
if (str >= 0x200F && str <= 0x201F) return str + (STR_200F_TALL_OFFICE_BLOCK - 0x200F); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
261 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
262 |
return str; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
263 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
264 |
|
6375
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
265 |
static uint8 MapDOSColour(uint8 colour) |
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
266 |
{ |
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
267 |
if (_use_dos_palette) return colour; |
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
268 |
|
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
269 |
if (colour < 10) { |
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
270 |
static uint8 dos_to_win_colour_map[] = { 0, 215, 216, 136, 88, 106, 32, 33, 40, 245 }; |
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
271 |
return dos_to_win_colour_map[colour]; |
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
272 |
} |
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
273 |
|
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
274 |
if (colour >= 245 && colour < 254) return colour - 28; |
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
275 |
|
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
276 |
return colour; |
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
277 |
} |
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
278 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
279 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
280 |
typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
281 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
282 |
#define FOR_EACH_OBJECT for (i = 0; i < numinfo; i++) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
283 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
284 |
static void dewagonize(int condition, int engine) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
285 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
286 |
EngineInfo *ei = &_engine_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
287 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
288 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
289 |
if (condition != 0) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
290 |
ei->unk2 &= ~0x80; |
6030
0415afaa9ac1
(svn r8753) -Regression (r8455): Do not unilateraly decide that this engine is a single-headed. Only do it if it previously had no power and that now there is. Or something...
belugas
parents:
5972
diff
changeset
|
291 |
if (rvi->railveh_type == RAILVEH_WAGON) |
0415afaa9ac1
(svn r8753) -Regression (r8455): Do not unilateraly decide that this engine is a single-headed. Only do it if it previously had no power and that now there is. Or something...
belugas
parents:
5972
diff
changeset
|
292 |
rvi->railveh_type = RAILVEH_SINGLEHEAD; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
293 |
} else { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
294 |
ei->unk2 |= 0x80; |
5868
94430141c189
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
5855
diff
changeset
|
295 |
rvi->railveh_type = RAILVEH_WAGON; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
296 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
297 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
298 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
299 |
static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
300 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
301 |
EngineInfo *ei = &_engine_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
302 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
303 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
304 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
305 |
bool ret = false; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
306 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
307 |
switch (prop) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
308 |
case 0x05: // Track type |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
309 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
310 |
uint8 tracktype = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
311 |
|
3026
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
312 |
switch (tracktype) { |
5763 | 313 |
case 0: rvi[i].railtype = rvi[i].engclass == 2 ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; break; |
314 |
case 1: rvi[i].railtype = RAILTYPE_MONO; break; |
|
315 |
case 2: rvi[i].railtype = RAILTYPE_MAGLEV; break; |
|
3026
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
316 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
317 |
grfmsg(1, "RailVehicleChangeInfo: Invalid track type %d specified, ignoring", tracktype); |
3026
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
318 |
break; |
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
319 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
320 |
} |
3026
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
321 |
break; |
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
322 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
323 |
case 0x08: // AI passenger service |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
324 |
/* @todo missing feature */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
325 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
326 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
327 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
328 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
329 |
case 0x09: // Speed (1 unit is 1 kmh) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
330 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
331 |
uint16 speed = grf_load_word(&buf); |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
332 |
if (speed == 0xFFFF) speed = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
333 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
334 |
rvi[i].max_speed = speed; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
335 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
336 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
337 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
338 |
case 0x0B: // Power |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
339 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
340 |
uint16 power = grf_load_word(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
341 |
|
5868
94430141c189
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
5855
diff
changeset
|
342 |
if (rvi[i].railveh_type == RAILVEH_MULTIHEAD) power /= 2; |
1894
c76c6bc57121
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
343 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
344 |
rvi[i].power = power; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
345 |
dewagonize(power, engine + i); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
346 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
347 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
348 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
349 |
case 0x0D: // Running cost factor |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
350 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
351 |
uint8 runcostfact = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
352 |
|
5868
94430141c189
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
5855
diff
changeset
|
353 |
if (rvi[i].railveh_type == RAILVEH_MULTIHEAD) runcostfact /= 2; |
2836
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
354 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
355 |
rvi[i].running_cost_base = runcostfact; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
356 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
357 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
358 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
359 |
case 0x0E: // Running cost base |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
360 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
361 |
uint32 base = grf_load_dword(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
362 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
363 |
switch (base) { |
2840
9038b4ab8c9a
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2838
diff
changeset
|
364 |
case 0x4C30: rvi[i].running_cost_class = 0; break; |
9038b4ab8c9a
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2838
diff
changeset
|
365 |
case 0x4C36: rvi[i].running_cost_class = 1; break; |
9038b4ab8c9a
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2838
diff
changeset
|
366 |
case 0x4C3C: rvi[i].running_cost_class = 2; break; |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
367 |
case 0: break; // Used by wagons |
5324
d5b8b676aee9
(svn r7485) -Codechange: [NewGRF] Add debug warning for unsupported running cost bases for rail vehicles.
peter1138
parents:
5317
diff
changeset
|
368 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
369 |
grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base); |
5324
d5b8b676aee9
(svn r7485) -Codechange: [NewGRF] Add debug warning for unsupported running cost bases for rail vehicles.
peter1138
parents:
5317
diff
changeset
|
370 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
371 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
372 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
373 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
374 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
375 |
case 0x12: // Sprite ID |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
376 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
377 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
378 |
|
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
379 |
/* TTD sprite IDs point to a location in a 16bit array, but we use it |
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
380 |
* as an array index, so we need it to be half the original value. */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
381 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
382 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
383 |
rvi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
384 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
385 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
386 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
387 |
case 0x13: // Dual-headed |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
388 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
389 |
uint8 dual = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
390 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
391 |
if (dual != 0) { |
5868
94430141c189
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
5855
diff
changeset
|
392 |
if (rvi[i].railveh_type != RAILVEH_MULTIHEAD) { |
2836
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
393 |
// adjust power and running cost if needed |
1894
c76c6bc57121
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
394 |
rvi[i].power /= 2; |
2836
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
395 |
rvi[i].running_cost_base /= 2; |
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
396 |
} |
5868
94430141c189
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
5855
diff
changeset
|
397 |
rvi[i].railveh_type = RAILVEH_MULTIHEAD; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
398 |
} else { |
5868
94430141c189
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
5855
diff
changeset
|
399 |
if (rvi[i].railveh_type == RAILVEH_MULTIHEAD) { |
2836
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
400 |
// adjust power and running cost if needed |
1894
c76c6bc57121
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
401 |
rvi[i].power *= 2; |
2840
9038b4ab8c9a
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2838
diff
changeset
|
402 |
rvi[i].running_cost_base *= 2; |
2836
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
403 |
} |
5875
fabb49e65684
(svn r8465) -Regression (r8455): Switching from dual to single head should switch to wagon if power is zero. .Or something.
peter1138
parents:
5868
diff
changeset
|
404 |
rvi[i].railveh_type = rvi[i].power == 0 ? |
fabb49e65684
(svn r8465) -Regression (r8455): Switching from dual to single head should switch to wagon if power is zero. .Or something.
peter1138
parents:
5868
diff
changeset
|
405 |
RAILVEH_WAGON : RAILVEH_SINGLEHEAD; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
406 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
407 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
408 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
409 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
410 |
case 0x14: // Cargo capacity |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
411 |
FOR_EACH_OBJECT rvi[i].capacity = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
412 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
413 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
414 |
case 0x15: // Cargo type |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
415 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
416 |
uint8 ctype = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
417 |
|
6280
977a42059676
(svn r9092) -Codechange: (NewGRF) (re r8885) Also set cargo type as invalid if the chosen type is not available in the current climate.
peter1138
parents:
6259
diff
changeset
|
418 |
if (ctype < NUM_CARGO && HASBIT(_cargo_mask, ctype)) { |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
419 |
rvi[i].cargo_type = ctype; |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
420 |
} else { |
6142
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
421 |
rvi[i].cargo_type = CT_INVALID; |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
422 |
grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, using first refittable", ctype); |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
423 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
424 |
} |
3023
d651099f7b18
(svn r3603) - NewGRF: Support loading of AI rank data
peter1138
parents:
3006
diff
changeset
|
425 |
break; |
d651099f7b18
(svn r3603) - NewGRF: Support loading of AI rank data
peter1138
parents:
3006
diff
changeset
|
426 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
427 |
case 0x16: // Weight |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
428 |
FOR_EACH_OBJECT SB(rvi[i].weight, 0, 8, grf_load_byte(&buf)); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
429 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
430 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
431 |
case 0x17: // Cost factor |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
432 |
FOR_EACH_OBJECT rvi[i].base_cost = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
433 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
434 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
435 |
case 0x18: // AI rank |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
436 |
FOR_EACH_OBJECT rvi[i].ai_rank = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
437 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
438 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
439 |
case 0x19: // Engine traction type |
2838
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
440 |
/* What do the individual numbers mean? |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
441 |
* 0x00 .. 0x07: Steam |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
442 |
* 0x08 .. 0x27: Diesel |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
443 |
* 0x28 .. 0x31: Electric |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
444 |
* 0x32 .. 0x37: Monorail |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
445 |
* 0x38 .. 0x41: Maglev |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
446 |
*/ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
447 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
448 |
uint8 traction = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
449 |
int engclass; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
450 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
451 |
if (traction <= 0x07) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
452 |
engclass = 0; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
453 |
} else if (traction <= 0x27) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
454 |
engclass = 1; |
3355
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3095
diff
changeset
|
455 |
} else if (traction <= 0x31) { |
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3095
diff
changeset
|
456 |
engclass = 2; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
457 |
} else if (traction <= 0x41) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
458 |
engclass = 2; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
459 |
} else { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
460 |
break; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
461 |
} |
5763 | 462 |
if (rvi[i].railtype == RAILTYPE_RAIL && engclass == 2) rvi[i].railtype = RAILTYPE_ELECTRIC; |
463 |
if (rvi[i].railtype == RAILTYPE_ELECTRIC && engclass != 2) rvi[i].railtype = RAILTYPE_RAIL; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
464 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
465 |
rvi[i].engclass = engclass; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
466 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
467 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
468 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
469 |
case 0x1A: // Alter purchase list sort order |
2971
cae3a81e8674
(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
|
470 |
FOR_EACH_OBJECT { |
cae3a81e8674
(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
|
471 |
EngineID pos = grf_load_byte(&buf); |
cae3a81e8674
(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
|
472 |
|
cae3a81e8674
(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
|
473 |
if (pos < NUM_TRAIN_ENGINES) { |
cae3a81e8674
(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
|
474 |
AlterRailVehListOrder(engine + i, pos); |
cae3a81e8674
(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
|
475 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
476 |
grfmsg(2, "RailVehicleChangeInfo: Invalid train engine ID %d, ignoring", pos); |
2971
cae3a81e8674
(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
|
477 |
} |
cae3a81e8674
(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
|
478 |
} |
cae3a81e8674
(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
|
479 |
break; |
cae3a81e8674
(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
|
480 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
481 |
case 0x1B: // Powered wagons power bonus |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
482 |
FOR_EACH_OBJECT rvi[i].pow_wag_power = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
483 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
484 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
485 |
case 0x1C: // Refit cost |
3997
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
486 |
FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
487 |
break; |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
488 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
489 |
case 0x1D: // Refit cargo |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
490 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
491 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
492 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
493 |
case 0x1E: // Callback |
3956
92362ba224b7
(svn r5105) - NewGRF: Move callbackmask from *VehicleInfo to EngineInfo. This simplifies code that works with more than one vehicle type.
peter1138
parents:
3924
diff
changeset
|
494 |
FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
495 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
496 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
497 |
case 0x1F: // Tractive effort coefficient |
5400
bba42ad3223b
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5382
diff
changeset
|
498 |
FOR_EACH_OBJECT rvi[i].tractive_effort = grf_load_byte(&buf); |
bba42ad3223b
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5382
diff
changeset
|
499 |
break; |
bba42ad3223b
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5382
diff
changeset
|
500 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
501 |
case 0x21: // Shorter vehicle |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
502 |
FOR_EACH_OBJECT rvi[i].shorten_factor = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
503 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
504 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
505 |
case 0x22: // Visual effect |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
506 |
/* see note in engine.h about rvi->visual_effect */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
507 |
FOR_EACH_OBJECT rvi[i].visual_effect = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
508 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
509 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
510 |
case 0x23: // Powered wagons weight bonus |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
511 |
FOR_EACH_OBJECT rvi[i].pow_wag_weight = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
512 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
513 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
514 |
case 0x24: // High byte of vehicle weight |
2542
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
515 |
FOR_EACH_OBJECT { |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
516 |
byte weight = grf_load_byte(&buf); |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
517 |
|
2545
aa71b3d576ce
(svn r3074) -NewGrf: Fix stupid typo in weight setting.
peter1138
parents:
2542
diff
changeset
|
518 |
if (weight > 4) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
519 |
grfmsg(2, "RailVehicleChangeInfo: Nonsensical weight of %d tons, ignoring", weight << 8); |
2542
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
520 |
} else { |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
521 |
SB(rvi[i].weight, 8, 8, weight); |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
522 |
} |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
523 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
524 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
525 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
526 |
case 0x25: // User-defined bit mask to set when checking veh. var. 42 |
3862
fe7b57944a39
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
peter1138
parents:
3845
diff
changeset
|
527 |
FOR_EACH_OBJECT rvi[i].user_def_data = grf_load_byte(&buf); |
fe7b57944a39
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
peter1138
parents:
3845
diff
changeset
|
528 |
break; |
fe7b57944a39
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
peter1138
parents:
3845
diff
changeset
|
529 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
530 |
case 0x27: // Miscellaneous flags |
4742
d915db693186
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
531 |
FOR_EACH_OBJECT { |
d915db693186
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
532 |
ei[i].misc_flags = grf_load_byte(&buf); |
d915db693186
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
533 |
if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
d915db693186
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
534 |
} |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
535 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
536 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
537 |
case 0x28: // Cargo classes allowed |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
538 |
FOR_EACH_OBJECT cargo_allowed[engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
539 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
540 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
541 |
case 0x29: // Cargo classes disallowed |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
542 |
FOR_EACH_OBJECT cargo_disallowed[engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
543 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
544 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
545 |
case 0x2A: // Long format introduction date (days since year 0) |
5114
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
546 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
547 |
break; |
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
548 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
549 |
/* @todo air drag and retire vehicle early |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
550 |
* Fall-through for unimplemented one byte long properties. */ |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
551 |
case 0x20: // Air drag |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
552 |
case 0x26: // Retire vehicle early |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
553 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
554 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
555 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
556 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
557 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
558 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
559 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
560 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
561 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
562 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
563 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
564 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
565 |
static bool RoadVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
566 |
{ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
567 |
EngineInfo *ei = &_engine_info[ROAD_ENGINES_INDEX + engine]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
568 |
RoadVehicleInfo *rvi = &_road_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
569 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
570 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
571 |
bool ret = false; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
572 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
573 |
switch (prop) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
574 |
case 0x08: // Speed (1 unit is 0.5 kmh) |
3488
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
575 |
FOR_EACH_OBJECT rvi[i].max_speed = grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
576 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
577 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
578 |
case 0x09: // Running cost factor |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
579 |
FOR_EACH_OBJECT rvi[i].running_cost = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
580 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
581 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
582 |
case 0x0A: // Running cost base |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
583 |
/* @todo : I have no idea. --pasky |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
584 |
* I THINK it is used for overriding the base cost of all road vehicle (_price.roadveh_base) --belugas */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
585 |
FOR_EACH_OBJECT grf_load_dword(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
586 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
587 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
588 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
589 |
case 0x0E: // Sprite ID |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
590 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
591 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
592 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
593 |
/* cars have different custom id in the GRF file */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
594 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
595 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
596 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
597 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
598 |
rvi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
599 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
600 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
601 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
602 |
case 0x0F: // Cargo capacity |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
603 |
FOR_EACH_OBJECT rvi[i].capacity = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
604 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
605 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
606 |
case 0x10: // Cargo type |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
607 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
608 |
uint8 cargo = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
609 |
|
6280
977a42059676
(svn r9092) -Codechange: (NewGRF) (re r8885) Also set cargo type as invalid if the chosen type is not available in the current climate.
peter1138
parents:
6259
diff
changeset
|
610 |
if (cargo < NUM_CARGO && HASBIT(_cargo_mask, cargo)) { |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
611 |
rvi[i].cargo_type = cargo; |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
612 |
} else { |
6142
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
613 |
rvi[i].cargo_type = CT_INVALID; |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
614 |
grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
615 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
616 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
617 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
618 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
619 |
case 0x11: // Cost factor |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
620 |
FOR_EACH_OBJECT rvi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
621 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
622 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
623 |
case 0x12: // SFX |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
624 |
FOR_EACH_OBJECT rvi[i].sfx = (SoundFx)grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
625 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
626 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
627 |
case 0x13: // Power in 10hp |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
628 |
case 0x14: // Weight in 1/4 tons |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
629 |
case 0x15: // Speed in mph*0.8 |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
630 |
/* TODO: Support for road vehicles realistic power |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
631 |
* computations (called rvpower in TTDPatch) is just |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
632 |
* missing in OTTD yet. --pasky */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
633 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
634 |
ret = true; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
635 |
break; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
636 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
637 |
case 0x16: // Cargos available for refitting |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
638 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3006
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
639 |
break; |
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
640 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
641 |
case 0x17: // Callback mask |
3956
92362ba224b7
(svn r5105) - NewGRF: Move callbackmask from *VehicleInfo to EngineInfo. This simplifies code that works with more than one vehicle type.
peter1138
parents:
3924
diff
changeset
|
642 |
FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
643 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
644 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
645 |
case 0x1A: // Refit cost |
3997
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
646 |
FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
647 |
break; |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
648 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
649 |
case 0x1C: // Miscellaneous flags |
4952
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
650 |
FOR_EACH_OBJECT { |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
651 |
ei[i].misc_flags = grf_load_byte(&buf); |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
652 |
if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
653 |
} |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
654 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
655 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
656 |
case 0x1D: // Cargo classes allowed |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
657 |
FOR_EACH_OBJECT cargo_allowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
658 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
659 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
660 |
case 0x1E: // Cargo classes disallowed |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
661 |
FOR_EACH_OBJECT cargo_disallowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
662 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
663 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
664 |
case 0x1F: // Long format introduction date (days since year 0) |
5114
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
665 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
666 |
break; |
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
667 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
668 |
case 0x18: // Tractive effort |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
669 |
case 0x19: // Air drag |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
670 |
case 0x1B: // Retire vehicle early |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
671 |
/* @todo */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
672 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
673 |
ret = true; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
674 |
break; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
675 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
676 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
677 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
678 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
679 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
680 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
681 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
682 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
683 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
684 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
685 |
static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
686 |
{ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
687 |
EngineInfo *ei = &_engine_info[SHIP_ENGINES_INDEX + engine]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
688 |
ShipVehicleInfo *svi = &_ship_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
689 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
690 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
691 |
bool ret = false; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
692 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
693 |
//printf("e %x prop %x?\n", engine, prop); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
694 |
switch (prop) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
695 |
case 0x08: // Sprite ID |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
696 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
697 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
698 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
699 |
/* ships have different custom id in the GRF file */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
700 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
701 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
702 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
703 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
704 |
svi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
705 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
706 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
707 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
708 |
case 0x09: // Refittable |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
709 |
FOR_EACH_OBJECT svi[i].refittable = (grf_load_byte(&buf) != 0); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
710 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
711 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
712 |
case 0x0A: // Cost factor |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
713 |
FOR_EACH_OBJECT svi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
714 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
715 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
716 |
case 0x0B: // Speed (1 unit is 0.5 kmh) |
3488
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
717 |
FOR_EACH_OBJECT svi[i].max_speed = grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
718 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
719 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
720 |
case 0x0C: // Cargo type |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
721 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
722 |
uint8 cargo = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
723 |
|
6280
977a42059676
(svn r9092) -Codechange: (NewGRF) (re r8885) Also set cargo type as invalid if the chosen type is not available in the current climate.
peter1138
parents:
6259
diff
changeset
|
724 |
if (cargo < NUM_CARGO && HASBIT(_cargo_mask, cargo)) { |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
725 |
svi[i].cargo_type = cargo; |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
726 |
} else { |
6142
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
727 |
svi[i].cargo_type = CT_INVALID; |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
728 |
grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
729 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
730 |
} |
3006
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
731 |
break; |
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
732 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
733 |
case 0x0D: // Cargo capacity |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
734 |
FOR_EACH_OBJECT svi[i].capacity = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
735 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
736 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
737 |
case 0x0F: // Running cost factor |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
738 |
FOR_EACH_OBJECT svi[i].running_cost = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
739 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
740 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
741 |
case 0x10: // SFX |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
742 |
FOR_EACH_OBJECT svi[i].sfx = (SoundFx)grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
743 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
744 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
745 |
case 0x11: // Cargos available for refitting |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
746 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
747 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
748 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
749 |
case 0x12: // Callback mask |
3956
92362ba224b7
(svn r5105) - NewGRF: Move callbackmask from *VehicleInfo to EngineInfo. This simplifies code that works with more than one vehicle type.
peter1138
parents:
3924
diff
changeset
|
750 |
FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
751 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
752 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
753 |
case 0x13: // Refit cost |
3997
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
754 |
FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
755 |
break; |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
756 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
757 |
case 0x17: // Miscellaneous flags |
4952
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
758 |
FOR_EACH_OBJECT { |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
759 |
ei[i].misc_flags = grf_load_byte(&buf); |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
760 |
if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
761 |
} |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
762 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
763 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
764 |
case 0x18: // Cargo classes allowed |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
765 |
FOR_EACH_OBJECT cargo_allowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
766 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
767 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
768 |
case 0x19: // Cargo classes disallowed |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
769 |
FOR_EACH_OBJECT cargo_disallowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
770 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
771 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
772 |
case 0x1A: // Long format introduction date (days since year 0) |
5114
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
773 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
774 |
break; |
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
775 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
776 |
case 0x14: // Ocean speed fraction |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
777 |
case 0x15: // Canal speed fraction |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
778 |
case 0x16: // Retire vehicle early |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
779 |
/* @todo */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
780 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
781 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
782 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
783 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
784 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
785 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
786 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
787 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
788 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
789 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
790 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
791 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
792 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
793 |
static bool AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
794 |
{ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
795 |
EngineInfo *ei = &_engine_info[AIRCRAFT_ENGINES_INDEX + engine]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
796 |
AircraftVehicleInfo *avi = &_aircraft_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
797 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
798 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
799 |
bool ret = false; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
800 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
801 |
//printf("e %x prop %x?\n", engine, prop); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
802 |
switch (prop) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
803 |
case 0x08: // Sprite ID |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
804 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
805 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
806 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
807 |
/* aircraft have different custom id in the GRF file */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
808 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
809 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
810 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
811 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
812 |
avi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
813 |
} |
3006
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
814 |
break; |
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
815 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
816 |
case 0x09: // Helicopter |
4926
4b2f470a4355
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
817 |
FOR_EACH_OBJECT { |
4b2f470a4355
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
818 |
if (grf_load_byte(&buf) == 0) { |
5855
6f273e99a57a
(svn r8429) -Codechange: Add a name for AircraftVehicleInfo subtype helicopter and remove some magic numbers related to the subtype.
Darkvater
parents:
5763
diff
changeset
|
819 |
avi[i].subtype = AIR_HELI; |
4926
4b2f470a4355
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
820 |
} else { |
5855
6f273e99a57a
(svn r8429) -Codechange: Add a name for AircraftVehicleInfo subtype helicopter and remove some magic numbers related to the subtype.
Darkvater
parents:
5763
diff
changeset
|
821 |
SB(avi[i].subtype, 0, 1, 1); // AIR_CTOL |
4926
4b2f470a4355
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
822 |
} |
4b2f470a4355
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
823 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
824 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
825 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
826 |
case 0x0A: // Large |
5855
6f273e99a57a
(svn r8429) -Codechange: Add a name for AircraftVehicleInfo subtype helicopter and remove some magic numbers related to the subtype.
Darkvater
parents:
5763
diff
changeset
|
827 |
FOR_EACH_OBJECT SB(avi[i].subtype, 1, 1, (grf_load_byte(&buf) != 0 ? 1 : 0)); // AIR_FAST |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
828 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
829 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
830 |
case 0x0B: // Cost factor |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
831 |
FOR_EACH_OBJECT avi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
832 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
833 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
834 |
case 0x0C: // Speed (1 unit is 8 mph, we translate to 1 unit is 1 km/h) |
6193
6f20de9e4f1b
(svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar
parents:
6186
diff
changeset
|
835 |
FOR_EACH_OBJECT avi[i].max_speed = (grf_load_byte(&buf) * 129) / 10; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
836 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
837 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
838 |
case 0x0D: // Acceleration |
6193
6f20de9e4f1b
(svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar
parents:
6186
diff
changeset
|
839 |
FOR_EACH_OBJECT avi[i].acceleration = (grf_load_byte(&buf) * 129) / 10; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
840 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
841 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
842 |
case 0x0E: // Running cost factor |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
843 |
FOR_EACH_OBJECT avi[i].running_cost = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
844 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
845 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
846 |
case 0x0F: // Passenger capacity |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
847 |
FOR_EACH_OBJECT avi[i].passenger_capacity = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
848 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
849 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
850 |
case 0x11: // Mail capacity |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
851 |
FOR_EACH_OBJECT avi[i].mail_capacity = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
852 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
853 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
854 |
case 0x12: // SFX |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
855 |
FOR_EACH_OBJECT avi[i].sfx = (SoundFx)grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
856 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
857 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
858 |
case 0x13: // Cargos available for refitting |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
859 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
860 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
861 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
862 |
case 0x14: // Callback mask |
3956
92362ba224b7
(svn r5105) - NewGRF: Move callbackmask from *VehicleInfo to EngineInfo. This simplifies code that works with more than one vehicle type.
peter1138
parents:
3924
diff
changeset
|
863 |
FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
864 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
865 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
866 |
case 0x15: // Refit cost |
3997
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
867 |
FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
868 |
break; |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
869 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
870 |
case 0x17: // Miscellaneous flags |
4952
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
871 |
FOR_EACH_OBJECT { |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
872 |
ei[i].misc_flags = grf_load_byte(&buf); |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
873 |
if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
874 |
} |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
875 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
876 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
877 |
case 0x18: // Cargo classes allowed |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
878 |
FOR_EACH_OBJECT cargo_allowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
879 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
880 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
881 |
case 0x19: // Cargo classes disallowed |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
882 |
FOR_EACH_OBJECT cargo_disallowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
883 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
884 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
885 |
case 0x1A: // Long format introduction date (days since year 0) |
5114
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
886 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
887 |
break; |
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
888 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
889 |
case 0x16: // Retire vehicle early |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
890 |
/* @todo */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
891 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
892 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
893 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
894 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
895 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
896 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
897 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
898 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
899 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
900 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
901 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
902 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
903 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
904 |
static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
905 |
{ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
906 |
StationSpec **statspec; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
907 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
908 |
int i; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
909 |
bool ret = false; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
910 |
|
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
911 |
if (stid + numinfo > MAX_STATIONS) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
912 |
grfmsg(1, "StationChangeInfo: Station %u is invalid, max %u, ignoring", stid + numinfo, MAX_STATIONS); |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
913 |
return false; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
914 |
} |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
915 |
|
3501
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
916 |
/* Allocate station specs if necessary */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
917 |
if (_cur_grffile->stations == NULL) _cur_grffile->stations = CallocT<StationSpec*>(MAX_STATIONS); |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
918 |
|
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
919 |
statspec = &_cur_grffile->stations[stid]; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
920 |
|
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
921 |
if (prop != 0x08) { |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
922 |
/* Check that all stations we are modifying are defined. */ |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
923 |
FOR_EACH_OBJECT { |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
924 |
if (statspec[i] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
925 |
grfmsg(2, "StationChangeInfo: Attempt to modify undefined station %u, ignoring", stid + i); |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
926 |
return false; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
927 |
} |
3501
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
928 |
} |
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
929 |
} |
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
930 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
931 |
switch (prop) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
932 |
case 0x08: // Class ID |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
933 |
FOR_EACH_OBJECT { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
934 |
/* Property 0x08 is special; it is where the station is allocated */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
935 |
if (statspec[i] == NULL) statspec[i] = CallocT<StationSpec>(1); |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
936 |
|
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
937 |
/* Swap classid because we read it in BE meaning WAYP or DFLT */ |
6281 | 938 |
uint32 classid = grf_load_dword(&buf); |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
939 |
statspec[i]->sclass = AllocateStationClass(BSWAP32(classid)); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
940 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
941 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
942 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
943 |
case 0x09: // Define sprite layout |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
944 |
FOR_EACH_OBJECT { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
945 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
946 |
|
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
947 |
statspec->tiles = grf_load_extended(&buf); |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
948 |
statspec->renderdata = CallocT<DrawTileSprites>(statspec->tiles); |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
949 |
statspec->copied_renderdata = false; |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
950 |
|
6281 | 951 |
for (uint t = 0; t < statspec->tiles; t++) { |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
952 |
DrawTileSprites *dts = &statspec->renderdata[t]; |
3570
707f93772b0a
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
953 |
uint seq_count = 0; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
954 |
|
3737
1e4df4eb9298
(svn r4719) - Newstations: instead of drawing nothing, fall back to the default sprite layout if a station layout specifies so.
peter1138
parents:
3736
diff
changeset
|
955 |
dts->seq = NULL; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
956 |
dts->ground_sprite = grf_load_word(&buf); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
957 |
dts->ground_pal = grf_load_word(&buf); |
3775
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
958 |
if (dts->ground_sprite == 0) continue; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
959 |
if (HASBIT(dts->ground_pal, 15)) { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
960 |
CLRBIT(dts->ground_pal, 15); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
961 |
SETBIT(dts->ground_sprite, SPRITE_MODIFIER_USE_OFFSET); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
962 |
} |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
963 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
964 |
while (buf < *bufp + len) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
965 |
DrawTileSeqStruct *dtss; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
966 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
967 |
/* no relative bounding box support */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
968 |
dts->seq = ReallocT((DrawTileSeqStruct*)dts->seq, ++seq_count); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
969 |
dtss = (DrawTileSeqStruct*) &dts->seq[seq_count - 1]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
970 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
971 |
dtss->delta_x = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
972 |
if ((byte) dtss->delta_x == 0x80) break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
973 |
dtss->delta_y = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
974 |
dtss->delta_z = grf_load_byte(&buf); |
4230
f4e93251e2f6
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
975 |
dtss->size_x = grf_load_byte(&buf); |
f4e93251e2f6
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
976 |
dtss->size_y = grf_load_byte(&buf); |
f4e93251e2f6
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
977 |
dtss->size_z = grf_load_byte(&buf); |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
978 |
dtss->image = grf_load_word(&buf); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
979 |
dtss->pal = grf_load_word(&buf); |
3771
9bce8ac706b2
(svn r4763) - Newstations: revert r4762, instead map bit the palette modifier from bit 14 to bit 31 on GRF load.
peter1138
parents:
3768
diff
changeset
|
980 |
|
3775
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
981 |
/* Remap flags as ours collide */ |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
982 |
if (HASBIT(dtss->pal, 15)) { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
983 |
CLRBIT(dtss->pal, 15); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
984 |
SETBIT(dtss->image, SPRITE_MODIFIER_USE_OFFSET); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
985 |
} |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
986 |
|
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
987 |
if (HASBIT(dtss->image, 15)) { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
988 |
CLRBIT(dtss->image, 15); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
989 |
SETBIT(dtss->image, PALETTE_MODIFIER_COLOR); |
3775
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
990 |
} |
3771
9bce8ac706b2
(svn r4763) - Newstations: revert r4762, instead map bit the palette modifier from bit 14 to bit 31 on GRF load.
peter1138
parents:
3768
diff
changeset
|
991 |
if (HASBIT(dtss->image, 14)) { |
9bce8ac706b2
(svn r4763) - Newstations: revert r4762, instead map bit the palette modifier from bit 14 to bit 31 on GRF load.
peter1138
parents:
3768
diff
changeset
|
992 |
CLRBIT(dtss->image, 14); |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
993 |
SETBIT(dtss->image, PALETTE_MODIFIER_TRANSPARENT); |
3771
9bce8ac706b2
(svn r4763) - Newstations: revert r4762, instead map bit the palette modifier from bit 14 to bit 31 on GRF load.
peter1138
parents:
3768
diff
changeset
|
994 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
995 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
996 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
997 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
998 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
999 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1000 |
case 0x0A: // Copy sprite layout |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1001 |
FOR_EACH_OBJECT { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1002 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1003 |
byte srcid = grf_load_byte(&buf); |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1004 |
const StationSpec *srcstatspec = _cur_grffile->stations[srcid]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1005 |
|
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1006 |
statspec->tiles = srcstatspec->tiles; |
3738
4694e7a0e2e4
(svn r4720) - Newstations: instead of literally copying sprite layout data, just copy the pointer to the existing data.
peter1138
parents:
3737
diff
changeset
|
1007 |
statspec->renderdata = srcstatspec->renderdata; |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
1008 |
statspec->copied_renderdata = true; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1009 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1010 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1011 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1012 |
case 0x0B: // Callback mask |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1013 |
FOR_EACH_OBJECT statspec[i]->callbackmask = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1014 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1015 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1016 |
case 0x0C: // Disallowed number of platforms |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1017 |
FOR_EACH_OBJECT statspec[i]->disallowed_platforms = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1018 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1019 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1020 |
case 0x0D: // Disallowed platform lengths |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1021 |
FOR_EACH_OBJECT statspec[i]->disallowed_lengths = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1022 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1023 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1024 |
case 0x0E: // Define custom layout |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1025 |
FOR_EACH_OBJECT { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1026 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1027 |
|
5060
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1028 |
statspec->copied_layouts = false; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1029 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1030 |
while (buf < *bufp + len) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1031 |
byte length = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1032 |
byte number = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1033 |
StationLayout layout; |
3570
707f93772b0a
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
1034 |
uint l, p; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1035 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1036 |
if (length == 0 || number == 0) break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1037 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1038 |
//debug("l %d > %d ?", length, stat->lengths); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1039 |
if (length > statspec->lengths) { |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1040 |
statspec->platforms = ReallocT(statspec->platforms, length); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1041 |
memset(statspec->platforms + statspec->lengths, 0, length - statspec->lengths); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1042 |
|
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1043 |
statspec->layouts = ReallocT(statspec->layouts, length); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1044 |
memset(statspec->layouts + statspec->lengths, 0, |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1045 |
(length - statspec->lengths) * sizeof(*statspec->layouts)); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1046 |
|
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1047 |
statspec->lengths = length; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1048 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1049 |
l = length - 1; // index is zero-based |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1050 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1051 |
//debug("p %d > %d ?", number, stat->platforms[l]); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1052 |
if (number > statspec->platforms[l]) { |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1053 |
statspec->layouts[l] = ReallocT(statspec->layouts[l], number); |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1054 |
/* We expect NULL being 0 here, but C99 guarantees that. */ |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1055 |
memset(statspec->layouts[l] + statspec->platforms[l], 0, |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1056 |
(number - statspec->platforms[l]) * sizeof(**statspec->layouts)); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1057 |
|
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1058 |
statspec->platforms[l] = number; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1059 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1060 |
|
542 | 1061 |
p = 0; |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1062 |
layout = MallocT<byte>(length * number); |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1063 |
for (l = 0; l < length; l++) { |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1064 |
for (p = 0; p < number; p++) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1065 |
layout[l * number + p] = grf_load_byte(&buf); |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1066 |
} |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1067 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1068 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1069 |
l--; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1070 |
p--; |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1071 |
free(statspec->layouts[l][p]); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1072 |
statspec->layouts[l][p] = layout; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1073 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1074 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1075 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1076 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1077 |
case 0x0F: // Copy custom layout |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1078 |
FOR_EACH_OBJECT { |
5060
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1079 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1080 |
byte srcid = grf_load_byte(&buf); |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1081 |
const StationSpec *srcstatspec = _cur_grffile->stations[srcid]; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1082 |
|
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1083 |
statspec->lengths = srcstatspec->lengths; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1084 |
statspec->platforms = srcstatspec->platforms; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1085 |
statspec->layouts = srcstatspec->layouts; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1086 |
statspec->copied_layouts = true; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1087 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1088 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1089 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1090 |
case 0x10: // Little/lots cargo threshold |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1091 |
FOR_EACH_OBJECT statspec[i]->cargo_threshold = grf_load_word(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1092 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1093 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1094 |
case 0x11: // Pylon placement |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1095 |
FOR_EACH_OBJECT statspec[i]->pylons = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1096 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1097 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1098 |
case 0x12: // Cargo types for random triggers |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1099 |
FOR_EACH_OBJECT statspec[i]->cargo_triggers = grf_load_dword(&buf); |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1100 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1101 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1102 |
case 0x13: // General flags |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1103 |
FOR_EACH_OBJECT statspec[i]->flags = grf_load_byte(&buf); |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1104 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1105 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1106 |
case 0x14: // Overhead wire placement |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1107 |
FOR_EACH_OBJECT statspec[i]->wires = grf_load_byte(&buf); |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1108 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1109 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1110 |
case 0x15: // Blocked tiles |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1111 |
FOR_EACH_OBJECT statspec[i]->blocked = grf_load_byte(&buf); |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1112 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1113 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1114 |
case 0x16: // @todo Animation info |
5903
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1115 |
FOR_EACH_OBJECT grf_load_word(&buf); |
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1116 |
ret = true; |
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1117 |
break; |
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1118 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1119 |
case 0x17: // @todo Animation speed |
5903
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1120 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1121 |
ret = true; |
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1122 |
break; |
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1123 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1124 |
case 0x18: // @todo Animation triggers |
5903
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1125 |
FOR_EACH_OBJECT grf_load_word(&buf); |
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1126 |
ret = true; |
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1127 |
break; |
2bb5b340115b
(svn r8526) -Codechange: add stubs for unsupported newgrf station properties
peter1138
parents:
5889
diff
changeset
|
1128 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1129 |
default: |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1130 |
ret = true; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1131 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1132 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1133 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1134 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1135 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1136 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1137 |
|
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1138 |
static bool BridgeChangeInfo(uint brid, int numinfo, int prop, byte **bufp, int len) |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1139 |
{ |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1140 |
byte *buf = *bufp; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1141 |
int i; |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1142 |
bool ret = false; |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1143 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1144 |
switch (prop) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1145 |
case 0x08: // Year of availability |
4322
f40bbdf476b3
(svn r5975) -Cleanup: use ORIGINAL_BASE_YEAR & ORIGINAL_MAX_YEAR where the functions really depend on the original date format.
rubidium
parents:
4321
diff
changeset
|
1146 |
FOR_EACH_OBJECT _bridge[brid + i].avail_year = ORIGINAL_BASE_YEAR + grf_load_byte(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1147 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1148 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1149 |
case 0x09: // Minimum length |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1150 |
FOR_EACH_OBJECT _bridge[brid + i].min_length = grf_load_byte(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1151 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1152 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1153 |
case 0x0A: // Maximum length |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1154 |
FOR_EACH_OBJECT _bridge[brid + i].max_length = grf_load_byte(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1155 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1156 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1157 |
case 0x0B: // Cost factor |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1158 |
FOR_EACH_OBJECT _bridge[brid + i].price = grf_load_byte(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1159 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1160 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1161 |
case 0x0C: // Maximum speed |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1162 |
FOR_EACH_OBJECT _bridge[brid + i].speed = grf_load_word(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1163 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1164 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1165 |
case 0x0D: // Bridge sprite tables |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1166 |
FOR_EACH_OBJECT { |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1167 |
Bridge *bridge = &_bridge[brid + i]; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1168 |
byte tableid = grf_load_byte(&buf); |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1169 |
byte numtables = grf_load_byte(&buf); |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1170 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1171 |
if (bridge->sprite_table == NULL) { |
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1172 |
/* Allocate memory for sprite table pointers and zero out */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1173 |
bridge->sprite_table = CallocT<PalSpriteID*>(7); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1174 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1175 |
|
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1176 |
for (; numtables-- != 0; tableid++) { |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1177 |
if (tableid >= 7) { // skip invalid data |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1178 |
grfmsg(1, "BridgeChangeInfo: Table %d >= 7, skipping", tableid); |
6281 | 1179 |
for (byte sprite = 0; sprite < 32; sprite++) grf_load_dword(&buf); |
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1180 |
continue; |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1181 |
} |
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1182 |
|
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1183 |
if (bridge->sprite_table[tableid] == NULL) { |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1184 |
bridge->sprite_table[tableid] = MallocT<PalSpriteID>(32); |
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1185 |
} |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1186 |
|
6281 | 1187 |
for (byte sprite = 0; sprite < 32; sprite++) { |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1188 |
SpriteID image = grf_load_word(&buf); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1189 |
SpriteID pal = grf_load_word(&buf); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1190 |
|
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1191 |
if (HASBIT(pal, 15)) { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1192 |
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1193 |
} |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1194 |
|
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1195 |
/* Clear old color modifer bit */ |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1196 |
CLRBIT(image, 15); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1197 |
|
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1198 |
bridge->sprite_table[tableid][sprite].sprite = image; |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1199 |
bridge->sprite_table[tableid][sprite].pal = pal; |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1200 |
} |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1201 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1202 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1203 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1204 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1205 |
case 0x0E: // Flags; bit 0 - disable far pillars |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1206 |
FOR_EACH_OBJECT _bridge[brid + i].flags = grf_load_byte(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1207 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1208 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1209 |
case 0x0F: // Long format year of availability (year since year 0) |
5114
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
1210 |
FOR_EACH_OBJECT _bridge[brid + i].avail_year = clamp(grf_load_dword(&buf), MIN_YEAR, MAX_YEAR); |
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
1211 |
break; |
9487e87478ba
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
1212 |
|
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1213 |
default: |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1214 |
ret = true; |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1215 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1216 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1217 |
*bufp = buf; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1218 |
return ret; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1219 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1220 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1221 |
static bool TownHouseChangeInfo(uint hid, int numinfo, int prop, byte **bufp, int len) |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1222 |
{ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1223 |
HouseSpec **housespec; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1224 |
byte *buf = *bufp; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1225 |
int i; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1226 |
bool ret = false; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1227 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1228 |
if (hid + numinfo >= HOUSE_MAX) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1229 |
grfmsg(1, "TownHouseChangeInfo: Too many houses loaded (%u), max (%u). Ignoring.", hid + numinfo, HOUSE_MAX-1); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1230 |
return false; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1231 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1232 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1233 |
/* Allocate house specs if they haven't been allocated already. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1234 |
if (_cur_grffile->housespec == NULL) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1235 |
_cur_grffile->housespec = CallocT<HouseSpec*>(HOUSE_MAX); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1236 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1237 |
/* Reset any overrides that have been set. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1238 |
ResetHouseOverrides(); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1239 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1240 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1241 |
housespec = &_cur_grffile->housespec[hid]; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1242 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1243 |
if (prop != 0x08) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1244 |
/* Check that all the houses being modified have been defined. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1245 |
FOR_EACH_OBJECT { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1246 |
if (housespec[i] == NULL) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1247 |
grfmsg(2, "TownHouseChangeInfo: Attempt to modify undefined house %u. Ignoring.", hid + i); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1248 |
return false; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1249 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1250 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1251 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1252 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1253 |
switch (prop) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1254 |
case 0x08: // Substitute building type, and definition of a new house |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1255 |
FOR_EACH_OBJECT { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1256 |
byte subs_id = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1257 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1258 |
if (subs_id == 0xFF) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1259 |
/* Instead of defining a new house, a substitute house id |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1260 |
* of 0xFF disables the old house with the current id. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1261 |
_house_specs[hid + i].enabled = false; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1262 |
continue; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1263 |
} else if (subs_id >= NEW_HOUSE_OFFSET) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1264 |
/* The substitute id must be one of the original houses. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1265 |
grfmsg(2, "TownHouseChangeInfo: Attempt to use new house %u as substitute house for %u. Ignoring.", subs_id, hid + i); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1266 |
return false; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1267 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1268 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1269 |
/* Allocate space for this house. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1270 |
if (housespec[i] == NULL) housespec[i] = CallocT<HouseSpec>(1); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1271 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1272 |
memcpy(housespec[i], &_house_specs[subs_id], sizeof(_house_specs[subs_id])); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1273 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1274 |
housespec[i]->enabled = true; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1275 |
housespec[i]->local_id = hid + i; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1276 |
housespec[i]->substitute_id = subs_id; |
6342
a44ad9acf82a
(svn r9367) -Fix (r9315): If a new house doesn't have a corresponding action 3, the
maedhros
parents:
6341
diff
changeset
|
1277 |
housespec[i]->grffile = _cur_grffile; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1278 |
housespec[i]->random_colour[0] = 0x04; // those 4 random colours are the base colour |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1279 |
housespec[i]->random_colour[1] = 0x08; // for all new houses |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1280 |
housespec[i]->random_colour[2] = 0x0C; // they stand for red, blue, orange and green |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1281 |
housespec[i]->random_colour[3] = 0x06; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1282 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1283 |
/* New houses do not (currently) expect to have a default start |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1284 |
* date before 1930, as this breaks the build date stuff. See |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1285 |
* FinaliseHouseArray() for more details. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1286 |
if (housespec[i]->min_date < 1930) housespec[i]->min_date = 1930; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1287 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1288 |
_have_newhouses = true; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1289 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1290 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1291 |
case 0x09: // Building flags |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1292 |
FOR_EACH_OBJECT { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1293 |
byte state = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1294 |
housespec[i]->building_flags = (BuildingFlags)state; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1295 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1296 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1297 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1298 |
case 0x0A: // Availability years |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1299 |
FOR_EACH_OBJECT { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1300 |
uint16 years = grf_load_word(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1301 |
housespec[i]->min_date = GB(years, 0, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 0, 8); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1302 |
housespec[i]->max_date = GB(years, 8, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 8, 8); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1303 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1304 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1305 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1306 |
case 0x0B: // Population |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1307 |
FOR_EACH_OBJECT housespec[i]->population = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1308 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1309 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1310 |
case 0x0C: // Mail generation multiplier |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1311 |
FOR_EACH_OBJECT housespec[i]->mail_generation = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1312 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1313 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1314 |
case 0x0D: // Passenger acceptance |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1315 |
case 0x0E: // Mail acceptance |
6341
b670e4765225
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6332
diff
changeset
|
1316 |
FOR_EACH_OBJECT housespec[i]->cargo_acceptance[prop - 0x0D] = grf_load_byte(&buf); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1317 |
break; |
6341
b670e4765225
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6332
diff
changeset
|
1318 |
case 0x0F: // Goods/candy, food/fizzy drinks acceptance |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1319 |
FOR_EACH_OBJECT { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1320 |
int8 goods = grf_load_byte(&buf); |
6341
b670e4765225
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6332
diff
changeset
|
1321 |
|
b670e4765225
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6332
diff
changeset
|
1322 |
/* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance. |
b670e4765225
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6332
diff
changeset
|
1323 |
* Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */ |
6357
f0f5e7d1713c
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6350
diff
changeset
|
1324 |
housespec[i]->accepts_cargo[2] = (goods >= 0) ? ((_opt.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) : |
f0f5e7d1713c
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6350
diff
changeset
|
1325 |
((_opt.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD); |
6341
b670e4765225
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6332
diff
changeset
|
1326 |
|
b670e4765225
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6332
diff
changeset
|
1327 |
housespec[i]->cargo_acceptance[2] = abs(goods); // but we do need positive value here |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1328 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1329 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1330 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1331 |
case 0x10: // Local authority rating decrease on removal |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1332 |
FOR_EACH_OBJECT housespec[i]->remove_rating_decrease = grf_load_word(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1333 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1334 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1335 |
case 0x11: // Removal cost multiplier |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1336 |
FOR_EACH_OBJECT housespec[i]->removal_cost = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1337 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1338 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1339 |
case 0x12: // Building name ID |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1340 |
FOR_EACH_OBJECT housespec[i]->building_name = MapGRFStringID(_cur_grffile->grfid, grf_load_word(&buf)); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1341 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1342 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1343 |
case 0x13: // Building availability mask |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1344 |
FOR_EACH_OBJECT { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1345 |
uint16 avail = grf_load_word(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1346 |
housespec[i]->building_availability = (HouseZones)avail; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1347 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1348 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1349 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1350 |
case 0x14: // House callback flags |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1351 |
FOR_EACH_OBJECT housespec[i]->callback_mask = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1352 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1353 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1354 |
case 0x15: // House override byte |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1355 |
FOR_EACH_OBJECT { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1356 |
byte override = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1357 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1358 |
/* The house being overridden must be an original house. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1359 |
if (override >= NEW_HOUSE_OFFSET) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1360 |
grfmsg(2, "TownHouseChangeInfo: Attempt to override new house %u with house id %u. Ignoring.", override, hid); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1361 |
return false; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1362 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1363 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1364 |
AddHouseOverride(hid, override); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1365 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1366 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1367 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1368 |
case 0x16: // Periodic refresh multiplier |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1369 |
FOR_EACH_OBJECT housespec[i]->processing_time = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1370 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1371 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1372 |
case 0x17: // Four random colours to use |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1373 |
FOR_EACH_OBJECT { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1374 |
uint j; |
6492
286a52449b54
(svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents:
6491
diff
changeset
|
1375 |
for (j = 0; j < 4; j++) housespec[i]->random_colour[j] = grf_load_byte(&buf); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1376 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1377 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1378 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1379 |
case 0x18: // Relative probability of appearing |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1380 |
FOR_EACH_OBJECT housespec[i]->probability = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1381 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1382 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1383 |
case 0x19: // Extra flags |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1384 |
FOR_EACH_OBJECT { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1385 |
byte flags = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1386 |
housespec[i]->extra_flags = (HouseExtraFlags)flags; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1387 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1388 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1389 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1390 |
case 0x1A: // Animation frames |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1391 |
FOR_EACH_OBJECT housespec[i]->animation_frames = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1392 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1393 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1394 |
case 0x1B: // Animation speed |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1395 |
FOR_EACH_OBJECT housespec[i]->animation_speed = clamp(grf_load_byte(&buf), 2, 16); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1396 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1397 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1398 |
case 0x1C: // Class of the building type |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1399 |
FOR_EACH_OBJECT housespec[i]->class_id = AllocateHouseClassID(grf_load_byte(&buf), _cur_grffile->grfid); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1400 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1401 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1402 |
case 0x1D: // Callback flags 2 |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1403 |
FOR_EACH_OBJECT housespec[i]->callback_mask |= (grf_load_byte(&buf) << 8); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1404 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1405 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1406 |
case 0x1E: // Accepted cargo types |
6461
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1407 |
FOR_EACH_OBJECT { |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1408 |
uint32 cargotypes = grf_load_dword(&buf); |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1409 |
|
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1410 |
/* Check if the cargo types should not be changed */ |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1411 |
if (cargotypes == 0xFFFFFFFF) break; |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1412 |
|
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1413 |
for (uint j = 0; j < 3; j++) { |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1414 |
/* Get the cargo number from the 'list' */ |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1415 |
uint8 cargo_part = GB(cargotypes, 8 * j, 8); |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1416 |
CargoID cargo = GetCargoTranslation(cargo_part, _cur_grffile); |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1417 |
|
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1418 |
if (cargo == CT_INVALID) { |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1419 |
/* Disable acceptance of invalid cargo type */ |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1420 |
housespec[i]->cargo_acceptance[j] = 0; |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1421 |
} else { |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1422 |
housespec[i]->accepts_cargo[j] = cargo; |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1423 |
} |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1424 |
} |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1425 |
} |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1426 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1427 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1428 |
default: |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1429 |
ret = true; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1430 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1431 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1432 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1433 |
*bufp = buf; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1434 |
return ret; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1435 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1436 |
|
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1437 |
static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, int len) |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1438 |
{ |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1439 |
byte *buf = *bufp; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1440 |
int i; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1441 |
bool ret = false; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1442 |
|
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1443 |
switch (prop) { |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1444 |
case 0x08: /* Cost base factor */ |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1445 |
FOR_EACH_OBJECT { |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1446 |
byte factor = grf_load_byte(&buf); |
2508
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1447 |
uint price = gvid + i; |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1448 |
|
2508
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1449 |
if (price < NUM_PRICES) { |
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1450 |
SetPriceBaseMultiplier(price, factor); |
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1451 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1452 |
grfmsg(1, "GlobalVarChangeInfo: Price %d out of range, ignoring", price); |
2508
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1453 |
} |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1454 |
} |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1455 |
break; |
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1456 |
|
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1457 |
case 0x09: /* Cargo translation table */ |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1458 |
/* This is loaded during the initialisation stage, so just skip it here. */ |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1459 |
/* Each entry is 4 bytes. */ |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1460 |
buf += numinfo * 4; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1461 |
break; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1462 |
|
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1463 |
case 0x0A: // Currency display names |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1464 |
FOR_EACH_OBJECT { |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1465 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1466 |
StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf)); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1467 |
|
4504
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1468 |
if ((newone != STR_UNDEFINED) && (curidx < NUM_CURRENCY)) { |
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1469 |
_currency_specs[curidx].name = newone; |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1470 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1471 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1472 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1473 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1474 |
case 0x0B: // Currency multipliers |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1475 |
FOR_EACH_OBJECT { |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1476 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1477 |
uint32 rate = grf_load_dword(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1478 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1479 |
if (curidx < NUM_CURRENCY) { |
4602
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1480 |
/* TTDPatch uses a multiple of 1000 for its conversion calculations, |
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1481 |
* which OTTD does not. For this reason, divide grf value by 1000, |
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1482 |
* to be compatible */ |
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1483 |
_currency_specs[curidx].rate = rate / 1000; |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1484 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1485 |
grfmsg(1, "GlobalVarChangeInfo: Currency multipliers %d out of range, ignoring", curidx); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1486 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1487 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1488 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1489 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1490 |
case 0x0C: // Currency options |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1491 |
FOR_EACH_OBJECT { |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1492 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1493 |
uint16 options = grf_load_word(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1494 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1495 |
if (curidx < NUM_CURRENCY) { |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1496 |
_currency_specs[curidx].separator = GB(options, 0, 8); |
4602
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1497 |
/* By specifying only one bit, we prevent errors, |
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1498 |
* since newgrf specs said that only 0 and 1 can be set for symbol_pos */ |
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1499 |
_currency_specs[curidx].symbol_pos = GB(options, 8, 1); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1500 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1501 |
grfmsg(1, "GlobalVarChangeInfo: Currency option %d out of range, ignoring", curidx); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1502 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1503 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1504 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1505 |
|
4602
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1506 |
case 0x0D: // Currency prefix symbol |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1507 |
FOR_EACH_OBJECT { |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1508 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1509 |
uint32 tempfix = grf_load_dword(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1510 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1511 |
if (curidx < NUM_CURRENCY) { |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1512 |
memcpy(_currency_specs[curidx].prefix,&tempfix,4); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1513 |
_currency_specs[curidx].prefix[4] = 0; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1514 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1515 |
grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1516 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1517 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1518 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1519 |
|
4602
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1520 |
case 0x0E: // Currency suffix symbol |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1521 |
FOR_EACH_OBJECT { |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1522 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1523 |
uint32 tempfix = grf_load_dword(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1524 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1525 |
if (curidx < NUM_CURRENCY) { |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6481
diff
changeset
|
1526 |
memcpy(&_currency_specs[curidx].suffix, &tempfix, 4); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1527 |
_currency_specs[curidx].suffix[4] = 0; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1528 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1529 |
grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1530 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1531 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1532 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1533 |
|
4504
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1534 |
case 0x0F: // Euro introduction dates |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1535 |
FOR_EACH_OBJECT { |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1536 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1537 |
Year year_euro = grf_load_word(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1538 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1539 |
if (curidx < NUM_CURRENCY) { |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1540 |
_currency_specs[curidx].to_euro = year_euro; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1541 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1542 |
grfmsg(1, "GlobalVarChangeInfo: Euro intro date %d out of range, ignoring", curidx); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1543 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1544 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1545 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1546 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1547 |
case 0x10: // 12 * 32 * B Snow line height table |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1548 |
if (numinfo > 1 || IsSnowLineSet()) { |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1549 |
grfmsg(1, "GlobalVarChangeInfo: The snowline can only be set once (%d)", numinfo); |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1550 |
} else if (len < SNOW_LINE_MONTHS * SNOW_LINE_DAYS) { |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1551 |
grfmsg(1, "GlobalVarChangeInfo: Not enough entries set in the snowline table (%d)", len); |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1552 |
} else { |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1553 |
byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]; |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1554 |
|
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1555 |
for (uint i = 0; i < SNOW_LINE_MONTHS; i++) { |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1556 |
for (uint j = 0; j < SNOW_LINE_DAYS; j++) { |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1557 |
table[i][j] = grf_load_byte(&buf); |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1558 |
} |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1559 |
} |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1560 |
SetSnowLine(table); |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1561 |
} |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1562 |
break; |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1563 |
|
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1564 |
default: |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1565 |
ret = true; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1566 |
} |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1567 |
|
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1568 |
*bufp = buf; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1569 |
return ret; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1570 |
} |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1571 |
|
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1572 |
static bool CargoChangeInfo(uint cid, int numinfo, int prop, byte **bufp, int len) |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1573 |
{ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1574 |
if (cid + numinfo > NUM_CARGO) { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1575 |
grfmsg(2, "CargoChangeInfo: Cargo type %d out of range (max %d)", cid + numinfo, NUM_CARGO - 1); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1576 |
return false; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1577 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1578 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1579 |
CargoSpec *cs = &_cargo[cid]; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1580 |
byte *buf = *bufp; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1581 |
int i; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1582 |
bool ret = false; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1583 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1584 |
switch (prop) { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1585 |
case 0x08: /* Bit number of cargo */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1586 |
FOR_EACH_OBJECT { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1587 |
cs[i].bitnum = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1588 |
cs[i].grfid = _cur_grffile->grfid; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1589 |
if (cs->IsValid()) { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1590 |
SETBIT(_cargo_mask, cid + i); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1591 |
} else { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1592 |
CLRBIT(_cargo_mask, cid + i); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1593 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1594 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1595 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1596 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1597 |
case 0x09: /* String ID for cargo type name */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1598 |
FOR_EACH_OBJECT cs[i].name = grf_load_word(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1599 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1600 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1601 |
case 0x0A: /* String for cargo name, plural */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1602 |
FOR_EACH_OBJECT cs[i].name_plural = grf_load_word(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1603 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1604 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1605 |
case 0x0B: |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1606 |
/* String for units of cargo. This is different in OpenTTD to TTDPatch |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1607 |
* (e.g. 10 tonnes of coal) */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1608 |
FOR_EACH_OBJECT cs[i].units_volume = grf_load_word(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1609 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1610 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1611 |
case 0x0C: /* String for quantity of cargo (e.g. 10 tonnes of coal) */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1612 |
FOR_EACH_OBJECT cs[i].quantifier = grf_load_word(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1613 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1614 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1615 |
case 0x0D: /* String for two letter cargo abbreviation */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1616 |
FOR_EACH_OBJECT cs[i].abbrev = grf_load_word(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1617 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1618 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1619 |
case 0x0E: /* Sprite ID for cargo icon */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1620 |
FOR_EACH_OBJECT cs[i].sprite = grf_load_word(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1621 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1622 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1623 |
case 0x0F: /* Weight of one unit of cargo */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1624 |
FOR_EACH_OBJECT cs[i].weight = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1625 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1626 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1627 |
case 0x10: /* Used for payment calculation */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1628 |
FOR_EACH_OBJECT cs[i].transit_days[0] = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1629 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1630 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1631 |
case 0x11: /* Used for payment calculation */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1632 |
FOR_EACH_OBJECT cs[i].transit_days[1] = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1633 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1634 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1635 |
case 0x12: /* Base cargo price */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1636 |
FOR_EACH_OBJECT cs[i].initial_payment = grf_load_dword(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1637 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1638 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1639 |
case 0x13: /* Colour for station rating bars */ |
6375
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
1640 |
FOR_EACH_OBJECT cs[i].rating_colour = MapDOSColour(grf_load_byte(&buf)); |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1641 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1642 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1643 |
case 0x14: /* Colour for cargo graph */ |
6375
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
1644 |
FOR_EACH_OBJECT cs[i].legend_colour = MapDOSColour(grf_load_byte(&buf)); |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1645 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1646 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1647 |
case 0x15: /* Freight status */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1648 |
FOR_EACH_OBJECT cs[i].is_freight = grf_load_byte(&buf) != 0; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1649 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1650 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1651 |
case 0x16: /* Cargo classes */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1652 |
FOR_EACH_OBJECT cs[i].classes = grf_load_word(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1653 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1654 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1655 |
case 0x17: /* Cargo label */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1656 |
FOR_EACH_OBJECT { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1657 |
cs[i].label = grf_load_dword(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1658 |
cs[i].label = BSWAP32(cs[i].label); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1659 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1660 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1661 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1662 |
case 0x18: /* Town growth substitute type */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1663 |
FOR_EACH_OBJECT { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1664 |
uint8 substitute_type = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1665 |
switch (substitute_type) { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1666 |
case 0x00: cs[i].town_effect = TE_PASSENGERS; break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1667 |
case 0x02: cs[i].town_effect = TE_MAIL; break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1668 |
case 0x05: cs[i].town_effect = TE_GOODS; break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1669 |
case 0x09: cs[i].town_effect = TE_WATER; break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1670 |
case 0x0B: cs[i].town_effect = TE_FOOD; break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1671 |
default: |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1672 |
grfmsg(1, "CargoChangeInfo: Unknown town growth substitute value %d, setting to none.", substitute_type); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1673 |
case 0xFF: cs[i].town_effect = TE_NONE; break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1674 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1675 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1676 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1677 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1678 |
case 0x19: /* Town growth coefficient */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1679 |
FOR_EACH_OBJECT cs[i].multipliertowngrowth = grf_load_word(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1680 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1681 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1682 |
case 0x1A: /* Bitmask of callbacks to use */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1683 |
FOR_EACH_OBJECT cs[i].callback_mask = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1684 |
break; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1685 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1686 |
default: |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1687 |
ret = true; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1688 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1689 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1690 |
*bufp = buf; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1691 |
return ret; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1692 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1693 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1694 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1695 |
static bool SoundEffectChangeInfo(uint sid, int numinfo, int prop, byte **bufp, int len) |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1696 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1697 |
byte *buf = *bufp; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1698 |
int i; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1699 |
bool ret = false; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1700 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1701 |
if (_cur_grffile->sound_offset == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1702 |
grfmsg(1, "SoundEffectChangeInfo: No effects defined, skipping"); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1703 |
return false; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1704 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1705 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1706 |
switch (prop) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1707 |
case 0x08: // Relative volume |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1708 |
FOR_EACH_OBJECT { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1709 |
uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1710 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1711 |
if (sound >= GetNumSounds()) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1712 |
grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1713 |
} else { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1714 |
GetSound(sound)->volume = grf_load_byte(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1715 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1716 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1717 |
break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1718 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1719 |
case 0x09: // Priority |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1720 |
FOR_EACH_OBJECT { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1721 |
uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1722 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1723 |
if (sound >= GetNumSounds()) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1724 |
grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1725 |
} else { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1726 |
GetSound(sound)->priority = grf_load_byte(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1727 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1728 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1729 |
break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1730 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1731 |
case 0x0A: // Override old sound |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1732 |
FOR_EACH_OBJECT { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1733 |
uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1734 |
uint orig_sound = grf_load_byte(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1735 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1736 |
if (sound >= GetNumSounds() || orig_sound >= GetNumSounds()) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1737 |
grfmsg(1, "SoundEffectChangeInfo: Sound %d or %d not defined (max %d)", sound, orig_sound, GetNumSounds()); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1738 |
} else { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1739 |
FileEntry *newfe = GetSound(sound); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1740 |
FileEntry *oldfe = GetSound(orig_sound); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1741 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1742 |
/* Literally copy the data of the new sound over the original */ |
5024
5e98bf731469
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5011
diff
changeset
|
1743 |
*oldfe = *newfe; |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1744 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1745 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1746 |
break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1747 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1748 |
default: |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1749 |
ret = true; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1750 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1751 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1752 |
*bufp = buf; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1753 |
return ret; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1754 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1755 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1756 |
/* Action 0x00 */ |
3879
cfa3cf4731d2
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1757 |
static void FeatureChangeInfo(byte *buf, int len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1758 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1759 |
byte *bufend = buf + len; |
6288
f8103e0d58ba
(svn r9108) -Fix(9093) : MSVC was a bit unhappy with some of the type changes. So basically, widening the types makes the difference
belugas
parents:
6284
diff
changeset
|
1760 |
uint i; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1761 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1762 |
/* <00> <feature> <num-props> <num-info> <id> (<property <new-info>)... |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1763 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1764 |
* B feature 0, 1, 2 or 3 for trains, road vehicles, ships or planes |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1765 |
* 4 for defining new train station sets |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1766 |
* B num-props how many properties to change per vehicle/station |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1767 |
* B num-info how many vehicles/stations to change |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1768 |
* B id ID of first vehicle/station to change, if num-info is |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1769 |
* greater than one, this one and the following |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1770 |
* vehicles/stations will be changed |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1771 |
* B property what property to change, depends on the feature |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1772 |
* V new-info new bytes of info (variable size; depends on properties) */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1773 |
/* TODO: Bridges, town houses. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1774 |
|
2438
f0bf4adbd620
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
1775 |
static const VCI_Handler handler[] = { |
3825 | 1776 |
/* GSF_TRAIN */ RailVehicleChangeInfo, |
1777 |
/* GSF_ROAD */ RoadVehicleChangeInfo, |
|
1778 |
/* GSF_SHIP */ ShipVehicleChangeInfo, |
|
1779 |
/* GSF_AIRCRAFT */ AircraftVehicleChangeInfo, |
|
1780 |
/* GSF_STATION */ StationChangeInfo, |
|
1781 |
/* GSF_CANAL */ NULL, |
|
1782 |
/* GSF_BRIDGE */ BridgeChangeInfo, |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1783 |
/* GSF_TOWNHOUSE */ TownHouseChangeInfo, |
3825 | 1784 |
/* GSF_GLOBALVAR */ GlobalVarChangeInfo, |
1785 |
/* GSF_INDUSTRYTILES */NULL, |
|
1786 |
/* GSF_INDUSTRIES */ NULL, |
|
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1787 |
/* GSF_CARGOS */ NULL, /* Cargo is handled during reservation */ |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1788 |
/* GSF_SOUNDFX */ SoundEffectChangeInfo, |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1789 |
}; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1790 |
|
542 | 1791 |
EngineInfo *ei = NULL; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1792 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1793 |
if (len == 1) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1794 |
grfmsg(8, "Silently ignoring one-byte special sprite 0x00"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1795 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1796 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1797 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
1798 |
if (!check_length(len, 6, "FeatureChangeInfo")) return; |
3714
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1799 |
buf++; |
6281 | 1800 |
uint8 feature = grf_load_byte(&buf); |
1801 |
uint8 numprops = grf_load_byte(&buf); |
|
6288
f8103e0d58ba
(svn r9108) -Fix(9093) : MSVC was a bit unhappy with some of the type changes. So basically, widening the types makes the difference
belugas
parents:
6284
diff
changeset
|
1802 |
uint numinfo = grf_load_byte(&buf); |
f8103e0d58ba
(svn r9108) -Fix(9093) : MSVC was a bit unhappy with some of the type changes. So basically, widening the types makes the difference
belugas
parents:
6284
diff
changeset
|
1803 |
uint engine = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1804 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1805 |
grfmsg(6, "FeatureChangeInfo: feature %d, %d properties, to apply to %d+%d", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1806 |
feature, numprops, engine, numinfo); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1807 |
|
2440
d0c69700c72e
(svn r2966) Fix: newgrf: Replace special case with a check for the existence of a handler in VehicleChangeInfo.
peter1138
parents:
2439
diff
changeset
|
1808 |
if (feature >= lengthof(handler) || handler[feature] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1809 |
grfmsg(1, "FeatureChangeInfo: Unsupported feature %d, skipping", feature); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1810 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1811 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1812 |
|
2439
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1813 |
if (feature <= GSF_AIRCRAFT) { |
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1814 |
if (engine + numinfo > _vehcounts[feature]) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1815 |
grfmsg(0, "FeatureChangeInfo: Last engine ID %d out of bounds (max %d), skipping", engine + numinfo, _vehcounts[feature]); |
2439
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1816 |
return; |
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1817 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1818 |
ei = &_engine_info[engine + _vehshifts[feature]]; |
2439
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1819 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1820 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1821 |
while (numprops-- && buf < bufend) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1822 |
uint8 prop = grf_load_byte(&buf); |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1823 |
bool ignoring = false; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1824 |
|
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1825 |
switch (feature) { |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1826 |
case GSF_TRAIN: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1827 |
case GSF_ROAD: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1828 |
case GSF_SHIP: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1829 |
case GSF_AIRCRAFT: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1830 |
/* Common properties for vehicles */ |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1831 |
switch (prop) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1832 |
case 0x00: // Introduction date |
4322
f40bbdf476b3
(svn r5975) -Cleanup: use ORIGINAL_BASE_YEAR & ORIGINAL_MAX_YEAR where the functions really depend on the original date format.
rubidium
parents:
4321
diff
changeset
|
1833 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_word(&buf) + DAYS_TILL_ORIGINAL_BASE_YEAR; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1834 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1835 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1836 |
case 0x02: // Decay speed |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1837 |
FOR_EACH_OBJECT SB(ei[i].unk2, 0, 7, grf_load_byte(&buf) & 0x7F); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1838 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1839 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1840 |
case 0x03: // Vehicle life |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1841 |
FOR_EACH_OBJECT ei[i].lifelength = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1842 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1843 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1844 |
case 0x04: // Model life |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1845 |
FOR_EACH_OBJECT ei[i].base_life = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1846 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1847 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1848 |
case 0x06: // Climates available |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1849 |
FOR_EACH_OBJECT ei[i].climates = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1850 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1851 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1852 |
case 0x07: // Loading speed |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1853 |
/* Hyronymus explained me what does |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1854 |
* this mean and insists on having a |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1855 |
* credit ;-). --pasky */ |
5211
fb4dc0ca975d
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents:
5210
diff
changeset
|
1856 |
FOR_EACH_OBJECT ei[i].load_amount = grf_load_byte(&buf); |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1857 |
break; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1858 |
|
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1859 |
default: |
6281 | 1860 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) { |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1861 |
ignoring = true; |
6281 | 1862 |
} |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1863 |
break; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1864 |
} |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1865 |
break; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1866 |
|
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1867 |
default: |
6281 | 1868 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) { |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1869 |
ignoring = true; |
6281 | 1870 |
} |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1871 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1872 |
} |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1873 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1874 |
if (ignoring) grfmsg(2, "FeatureChangeInfo: Ignoring property 0x%02X (not implemented)", prop); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1875 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1876 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1877 |
|
5525
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1878 |
/* Action 0x00 (GLS_SAFETYSCAN) */ |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1879 |
static void SafeChangeInfo(byte *buf, int len) |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1880 |
{ |
6128
e4a3586c6ca6
(svn r8865) -Codechange: (NewGRF) Ignore 1 byte action 0s during safety check
peter1138
parents:
6113
diff
changeset
|
1881 |
if (len == 1) { |
e4a3586c6ca6
(svn r8865) -Codechange: (NewGRF) Ignore 1 byte action 0s during safety check
peter1138
parents:
6113
diff
changeset
|
1882 |
grfmsg(8, "Silently ignoring one-byte special sprite 0x00"); |
e4a3586c6ca6
(svn r8865) -Codechange: (NewGRF) Ignore 1 byte action 0s during safety check
peter1138
parents:
6113
diff
changeset
|
1883 |
return; |
e4a3586c6ca6
(svn r8865) -Codechange: (NewGRF) Ignore 1 byte action 0s during safety check
peter1138
parents:
6113
diff
changeset
|
1884 |
} |
e4a3586c6ca6
(svn r8865) -Codechange: (NewGRF) Ignore 1 byte action 0s during safety check
peter1138
parents:
6113
diff
changeset
|
1885 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
1886 |
if (!check_length(len, 6, "SafeChangeInfo")) return; |
5525
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1887 |
buf++; |
6281 | 1888 |
uint8 feature = grf_load_byte(&buf); |
1889 |
uint8 numprops = grf_load_byte(&buf); |
|
1890 |
grf_load_byte(&buf); |
|
1891 |
grf_load_byte(&buf); |
|
5525
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1892 |
|
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1893 |
if (feature == GSF_BRIDGE && numprops == 1) { |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1894 |
uint8 prop = grf_load_byte(&buf); |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1895 |
/* Bridge property 0x0D is redefinition of sprite layout tables, which |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1896 |
* is considered safe. */ |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1897 |
if (prop == 0x0D) return; |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1898 |
} |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1899 |
|
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1900 |
SETBIT(_cur_grfconfig->flags, GCF_UNSAFE); |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1901 |
|
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1902 |
/* Skip remainder of GRF */ |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1903 |
_skip_sprites = -1; |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1904 |
} |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
1905 |
|
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1906 |
/* Action 0x00 (GLS_INIT) */ |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1907 |
static void InitChangeInfo(byte *buf, int len) |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1908 |
{ |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1909 |
byte *bufend = buf + len; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1910 |
|
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1911 |
if (len == 1) { |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1912 |
grfmsg(8, "Silently ignoring one-byte special sprite 0x00"); |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1913 |
return; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1914 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1915 |
|
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1916 |
if (!check_length(len, 6, "InitChangeInfo")) return; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1917 |
buf++; |
6281 | 1918 |
uint8 feature = grf_load_byte(&buf); |
1919 |
uint8 numprops = grf_load_byte(&buf); |
|
1920 |
uint8 numinfo = grf_load_byte(&buf); |
|
1921 |
uint8 index = grf_load_byte(&buf); |
|
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1922 |
|
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1923 |
while (numprops-- && buf < bufend) { |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1924 |
uint8 prop = grf_load_byte(&buf); |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1925 |
|
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1926 |
switch (feature) { |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1927 |
case GSF_GLOBALVAR: |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1928 |
switch (prop) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1929 |
case 0x09: // Cargo Translation Table |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1930 |
if (index != 0) { |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1931 |
grfmsg(1, "InitChangeInfo: Cargo translation table must start at zero"); |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1932 |
return; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1933 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1934 |
|
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1935 |
free(_cur_grffile->cargo_list); |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1936 |
_cur_grffile->cargo_max = numinfo; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1937 |
_cur_grffile->cargo_list = MallocT<CargoLabel>(numinfo); |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1938 |
|
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1939 |
int i; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1940 |
FOR_EACH_OBJECT { |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1941 |
CargoLabel cl = grf_load_dword(&buf); |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1942 |
_cur_grffile->cargo_list[i] = BSWAP32(cl); |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1943 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1944 |
break; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1945 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1946 |
break; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1947 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1948 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1949 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
1950 |
|
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1951 |
/* Action 0x00 (GLS_RESERVE) */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1952 |
static void ReserveChangeInfo(byte *buf, int len) |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1953 |
{ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1954 |
byte *bufend = buf + len; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1955 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1956 |
if (len == 1) { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1957 |
grfmsg(8, "Silently ignoring one-byte special sprite 0x00"); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1958 |
return; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1959 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1960 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1961 |
if (!check_length(len, 6, "InitChangeInfo")) return; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1962 |
buf++; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1963 |
uint8 feature = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1964 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1965 |
if (feature != GSF_CARGOS) return; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1966 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1967 |
uint8 numprops = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1968 |
uint8 numinfo = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1969 |
uint8 index = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1970 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1971 |
while (numprops-- && buf < bufend) { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1972 |
uint8 prop = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1973 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1974 |
if (CargoChangeInfo(index, numinfo, prop, &buf, bufend - buf)) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
1975 |
grfmsg(2, "ReserveChangeInfo: Ignoring property 0x%02X (not implemented)", prop); |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1976 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1977 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1978 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1979 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1980 |
#undef FOR_EACH_OBJECT |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1981 |
|
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1982 |
/** |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1983 |
* Creates a spritegroup representing a callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1984 |
* @param value The value that was used to represent this callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1985 |
* @return A spritegroup representing that callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1986 |
*/ |
4893
000692659d8c
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
1987 |
static const SpriteGroup* NewCallBackResultSpriteGroup(uint16 value) |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1988 |
{ |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
1989 |
SpriteGroup *group = AllocateSpriteGroup(); |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1990 |
|
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1991 |
group->type = SGT_CALLBACK; |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1992 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1993 |
/* Old style callback results have the highest byte 0xFF so signify it is a callback result |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1994 |
* New style ones only have the highest bit set (allows 15-bit results, instead of just 8) */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1995 |
if ((value >> 8) == 0xFF) { |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1996 |
value &= ~0xFF00; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1997 |
} else { |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1998 |
value &= ~0x8000; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1999 |
} |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2000 |
|
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
2001 |
group->g.callback.result = value; |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2002 |
|
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2003 |
return group; |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2004 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2005 |
|
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2006 |
/** |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2007 |
* Creates a spritegroup representing a sprite number result. |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6479
diff
changeset
|
2008 |
* @param sprite The sprite number. |
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6479
diff
changeset
|
2009 |
* @param num_sprites The number of sprites per set. |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2010 |
* @return A spritegroup representing the sprite number result. |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2011 |
*/ |
4893
000692659d8c
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
2012 |
static const SpriteGroup* NewResultSpriteGroup(SpriteID sprite, byte num_sprites) |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2013 |
{ |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2014 |
SpriteGroup *group = AllocateSpriteGroup(); |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2015 |
group->type = SGT_RESULT; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2016 |
group->g.result.sprite = sprite; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2017 |
group->g.result.num_sprites = num_sprites; |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2018 |
return group; |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2019 |
} |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2020 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2021 |
/* Action 0x01 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2022 |
static void NewSpriteSet(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2023 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2024 |
/* <01> <feature> <num-sets> <num-ent> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2025 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2026 |
* B feature feature to define sprites for |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2027 |
* 0, 1, 2, 3: veh-type, 4: train stations |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2028 |
* B num-sets number of sprite sets |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2029 |
* E num-ent how many entries per sprite set |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2030 |
* For vehicles, this is the number of different |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2031 |
* vehicle directions in each sprite set |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2032 |
* Set num-dirs=8, unless your sprites are symmetric. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2033 |
* In that case, use num-dirs=4. |
6281 | 2034 |
*/ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2035 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
2036 |
if (!check_length(len, 4, "NewSpriteSet")) return; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2037 |
buf++; |
6281 | 2038 |
uint8 feature = grf_load_byte(&buf); |
2039 |
uint8 num_sets = grf_load_byte(&buf); |
|
2040 |
uint16 num_ents = grf_load_extended(&buf); |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2041 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2042 |
_cur_grffile->spriteset_start = _cur_spriteid; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2043 |
_cur_grffile->spriteset_feature = feature; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2044 |
_cur_grffile->spriteset_numsets = num_sets; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2045 |
_cur_grffile->spriteset_numents = num_ents; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2046 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2047 |
grfmsg(7, "New sprite set at %d of type %d, consisting of %d sets with %d views each (total %d)", |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2048 |
_cur_spriteid, feature, num_sets, num_ents, num_sets * num_ents |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2049 |
); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2050 |
|
6288
f8103e0d58ba
(svn r9108) -Fix(9093) : MSVC was a bit unhappy with some of the type changes. So basically, widening the types makes the difference
belugas
parents:
6284
diff
changeset
|
2051 |
for (uint16 i = 0; i < num_sets * num_ents; i++) { |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2052 |
LoadNextSprite(_cur_spriteid++, _file_index); |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
2053 |
_nfo_line++; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2054 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2055 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2056 |
|
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2057 |
/* Helper function to either create a callback or link to a previously |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2058 |
* defined spritegroup. */ |
4893
000692659d8c
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
2059 |
static const SpriteGroup* GetGroupFromGroupID(byte setid, byte type, uint16 groupid) |
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2060 |
{ |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2061 |
if (HASBIT(groupid, 15)) return NewCallBackResultSpriteGroup(groupid); |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2062 |
|
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2063 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2064 |
grfmsg(1, "GetGroupFromGroupID(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty", setid, type, groupid); |
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2065 |
return NULL; |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2066 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2067 |
|
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2068 |
return _cur_grffile->spritegroups[groupid]; |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2069 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2070 |
|
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2071 |
/* Helper function to either create a callback or a result sprite group. */ |
4893
000692659d8c
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
2072 |
static const SpriteGroup* CreateGroupFromGroupID(byte feature, byte setid, byte type, uint16 spriteid, uint16 num_sprites) |
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2073 |
{ |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2074 |
if (HASBIT(spriteid, 15)) return NewCallBackResultSpriteGroup(spriteid); |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2075 |
|
3667
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2076 |
if (spriteid >= _cur_grffile->spriteset_numsets) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2077 |
grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Sprite set %u invalid, max %u", setid, type, spriteid, _cur_grffile->spriteset_numsets); |
3667
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2078 |
return NULL; |
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2079 |
} |
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2080 |
|
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2081 |
/* Check if the sprite is within range. This can fail if the Action 0x01 |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2082 |
* is skipped, as TTDPatch mandates that Action 0x02s must be processed. |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2083 |
* We don't have that rule, but must live by the Patch... */ |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2084 |
if (_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites > _cur_spriteid) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2085 |
grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Real Sprite IDs 0x%04X - 0x%04X do not (all) exist (max 0x%04X), leaving empty", |
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2086 |
setid, type, |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2087 |
_cur_grffile->spriteset_start + spriteid * num_sprites, |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2088 |
_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites - 1, _cur_spriteid - 1); |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2089 |
return NULL; |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2090 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2091 |
|
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2092 |
if (feature != _cur_grffile->spriteset_feature) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2093 |
grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Sprite set feature 0x%02X does not match action feature 0x%02X, skipping", |
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2094 |
_cur_grffile->spriteset_feature, feature); |
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2095 |
return NULL; |
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2096 |
} |
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2097 |
|
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2098 |
return NewResultSpriteGroup(_cur_grffile->spriteset_start + spriteid * num_sprites, num_sprites); |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2099 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2100 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2101 |
/* Action 0x02 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2102 |
static void NewSpriteGroup(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2103 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2104 |
/* <02> <feature> <set-id> <type/num-entries> <feature-specific-data...> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2105 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2106 |
* B feature see action 1 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2107 |
* B set-id ID of this particular definition |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2108 |
* B type/num-entries |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2109 |
* if 80 or greater, this is a randomized or variational |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2110 |
* list definition, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2111 |
* otherwise it specifies a number of entries, the exact |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2112 |
* meaning depends on the feature |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2113 |
* V feature-specific-data (huge mess, don't even look it up --pasky) */ |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2114 |
SpriteGroup *group = NULL; |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2115 |
byte *bufend = buf + len; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2116 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
2117 |
if (!check_length(len, 5, "NewSpriteGroup")) return; |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2118 |
buf++; |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2119 |
|
6281 | 2120 |
uint8 feature = grf_load_byte(&buf); |
2121 |
uint8 setid = grf_load_byte(&buf); |
|
2122 |
uint8 type = grf_load_byte(&buf); |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2123 |
|
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
2124 |
if (setid >= _cur_grffile->spritegroups_count) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2125 |
/* Allocate memory for new sprite group references. */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
2126 |
_cur_grffile->spritegroups = ReallocT(_cur_grffile->spritegroups, setid + 1); |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2127 |
/* Initialise new space to NULL */ |
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
2128 |
for (; _cur_grffile->spritegroups_count < (setid + 1); _cur_grffile->spritegroups_count++) |
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
2129 |
_cur_grffile->spritegroups[_cur_grffile->spritegroups_count] = NULL; |
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
2130 |
} |
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
2131 |
|
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2132 |
switch (type) { |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2133 |
/* Deterministic Sprite Group */ |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2134 |
case 0x81: // Self scope, byte |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2135 |
case 0x82: // Parent scope, byte |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2136 |
case 0x85: // Self scope, word |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2137 |
case 0x86: // Parent scope, word |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2138 |
case 0x89: // Self scope, dword |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2139 |
case 0x8A: // Parent scope, dword |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2140 |
{ |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2141 |
byte varadjust; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2142 |
byte varsize; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2143 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2144 |
/* Check we can load the var size parameter */ |
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
2145 |
if (!check_length(bufend - buf, 1, "NewSpriteGroup (Deterministic) (1)")) return; |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2146 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2147 |
group = AllocateSpriteGroup(); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2148 |
group->type = SGT_DETERMINISTIC; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2149 |
group->g.determ.var_scope = HASBIT(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2150 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2151 |
switch (GB(type, 2, 2)) { |
3672
f626ea3c9994
(svn r4588) - NewGRF: silence a false compiler warning
peter1138
parents:
3668
diff
changeset
|
2152 |
default: NOT_REACHED(); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2153 |
case 0: group->g.determ.size = DSG_SIZE_BYTE; varsize = 1; break; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2154 |
case 1: group->g.determ.size = DSG_SIZE_WORD; varsize = 2; break; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2155 |
case 2: group->g.determ.size = DSG_SIZE_DWORD; varsize = 4; break; |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2156 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2157 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
2158 |
if (!check_length(bufend - buf, 5 + varsize, "NewSpriteGroup (Deterministic) (2)")) return; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2159 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2160 |
/* Loop through the var adjusts. Unfortunately we don't know how many we have |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2161 |
* from the outset, so we shall have to keep reallocing. */ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2162 |
do { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2163 |
DeterministicSpriteGroupAdjust *adjust; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2164 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2165 |
if (group->g.determ.num_adjusts > 0) { |
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
2166 |
if (!check_length(bufend - buf, 2 + varsize + 3, "NewSpriteGroup (Deterministic) (3)")) return; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2167 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2168 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2169 |
group->g.determ.num_adjusts++; |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
2170 |
group->g.determ.adjusts = ReallocT(group->g.determ.adjusts, group->g.determ.num_adjusts); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2171 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2172 |
adjust = &group->g.determ.adjusts[group->g.determ.num_adjusts - 1]; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2173 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2174 |
/* The first var adjust doesn't have an operation specified, so we set it to add. */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
2175 |
adjust->operation = group->g.determ.num_adjusts == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)grf_load_byte(&buf); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2176 |
adjust->variable = grf_load_byte(&buf); |
5617
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
2177 |
if (adjust->variable == 0x7E) { |
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
2178 |
/* Link subroutine group */ |
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
2179 |
adjust->subroutine = GetGroupFromGroupID(setid, type, grf_load_byte(&buf)); |
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
2180 |
} else { |
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
2181 |
adjust->parameter = IS_BYTE_INSIDE(adjust->variable, 0x60, 0x80) ? grf_load_byte(&buf) : 0; |
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
2182 |
} |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2183 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2184 |
varadjust = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2185 |
adjust->shift_num = GB(varadjust, 0, 5); |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
2186 |
adjust->type = (DeterministicSpriteGroupAdjustType)GB(varadjust, 6, 2); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2187 |
adjust->and_mask = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2188 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2189 |
if (adjust->type != DSGA_TYPE_NONE) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2190 |
adjust->add_val = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2191 |
adjust->divmod_val = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2192 |
} else { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2193 |
adjust->add_val = 0; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2194 |
adjust->divmod_val = 0; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2195 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2196 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2197 |
/* Continue reading var adjusts while bit 5 is set. */ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2198 |
} while (HASBIT(varadjust, 5)); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2199 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2200 |
group->g.determ.num_ranges = grf_load_byte(&buf); |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
2201 |
group->g.determ.ranges = CallocT<DeterministicSpriteGroupRange>(group->g.determ.num_ranges); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2202 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
2203 |
if (!check_length(bufend - buf, 2 + (2 + 2 * varsize) * group->g.determ.num_ranges, "NewSpriteGroup (Deterministic)")) return; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2204 |
|
6281 | 2205 |
for (uint i = 0; i < group->g.determ.num_ranges; i++) { |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2206 |
group->g.determ.ranges[i].group = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2207 |
group->g.determ.ranges[i].low = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2208 |
group->g.determ.ranges[i].high = grf_load_var(varsize, &buf); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2209 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2210 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2211 |
group->g.determ.default_group = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2212 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2213 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2214 |
|
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2215 |
/* Randomized Sprite Group */ |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2216 |
case 0x80: // Self scope |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2217 |
case 0x83: // Parent scope |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2218 |
{ |
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
2219 |
if (!check_length(bufend - buf, 7, "NewSpriteGroup (Randomized) (1)")) return; |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2220 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2221 |
group = AllocateSpriteGroup(); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2222 |
group->type = SGT_RANDOMIZED; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2223 |
group->g.random.var_scope = HASBIT(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2224 |
|
6281 | 2225 |
uint8 triggers = grf_load_byte(&buf); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2226 |
group->g.random.triggers = GB(triggers, 0, 7); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2227 |
group->g.random.cmp_mode = HASBIT(triggers, 7) ? RSG_CMP_ALL : RSG_CMP_ANY; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2228 |
group->g.random.lowest_randbit = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2229 |
group->g.random.num_groups = grf_load_byte(&buf); |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
2230 |
group->g.random.groups = CallocT<const SpriteGroup*>(group->g.random.num_groups); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2231 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
2232 |
if (!check_length(bufend - buf, 2 * group->g.random.num_groups, "NewSpriteGroup (Randomized) (2)")) return; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2233 |
|
6281 | 2234 |
for (uint i = 0; i < group->g.random.num_groups; i++) { |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2235 |
group->g.random.groups[i] = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2236 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2237 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2238 |
break; |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2239 |
} |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2240 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2241 |
/* Neither a variable or randomized sprite group... must be a real group */ |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2242 |
default: |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2243 |
{ |
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2244 |
|
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2245 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2246 |
switch (feature) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2247 |
case GSF_TRAIN: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2248 |
case GSF_ROAD: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2249 |
case GSF_SHIP: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2250 |
case GSF_AIRCRAFT: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2251 |
case GSF_STATION: |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2252 |
case GSF_CARGOS: |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2253 |
{ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2254 |
byte sprites = _cur_grffile->spriteset_numents; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2255 |
byte num_loaded = type; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2256 |
byte num_loading = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2257 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2258 |
if (_cur_grffile->spriteset_start == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2259 |
grfmsg(0, "NewSpriteGroup: No sprite set to work on! Skipping"); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2260 |
return; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2261 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2262 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
2263 |
if (!check_length(bufend - buf, 2 * num_loaded + 2 * num_loading, "NewSpriteGroup (Real) (1)")) return; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2264 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2265 |
group = AllocateSpriteGroup(); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2266 |
group->type = SGT_REAL; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2267 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2268 |
group->g.real.num_loaded = num_loaded; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2269 |
group->g.real.num_loading = num_loading; |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
2270 |
if (num_loaded > 0) group->g.real.loaded = CallocT<const SpriteGroup*>(num_loaded); |
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
2271 |
if (num_loading > 0) group->g.real.loading = CallocT<const SpriteGroup*>(num_loading); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2272 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2273 |
grfmsg(6, "NewSpriteGroup: New SpriteGroup 0x%02X, %u views, %u loaded, %u loading", |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2274 |
setid, sprites, num_loaded, num_loading); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2275 |
|
6281 | 2276 |
for (uint i = 0; i < num_loaded; i++) { |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2277 |
uint16 spriteid = grf_load_word(&buf); |
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2278 |
group->g.real.loaded[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2279 |
grfmsg(8, "NewSpriteGroup: + rg->loaded[%i] = subset %u", i, spriteid); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2280 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2281 |
|
6281 | 2282 |
for (uint i = 0; i < num_loading; i++) { |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2283 |
uint16 spriteid = grf_load_word(&buf); |
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2284 |
group->g.real.loading[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2285 |
grfmsg(8, "NewSpriteGroup: + rg->loading[%i] = subset %u", i, spriteid); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2286 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2287 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2288 |
break; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2289 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2290 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2291 |
case GSF_TOWNHOUSE: { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2292 |
byte sprites = _cur_grffile->spriteset_numents; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2293 |
byte num_sprites = max((uint8)1, type); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2294 |
uint i; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2295 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2296 |
group = AllocateSpriteGroup(); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2297 |
group->type = SGT_TILELAYOUT; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2298 |
group->g.layout.num_sprites = sprites; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2299 |
group->g.layout.dts = CallocT<DrawTileSprites>(1); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2300 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2301 |
/* Groundsprite */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2302 |
group->g.layout.dts->ground_sprite = grf_load_word(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2303 |
group->g.layout.dts->ground_pal = grf_load_word(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2304 |
/* Remap transparent/colour modifier bits */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2305 |
if (HASBIT(group->g.layout.dts->ground_sprite, 14)) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2306 |
CLRBIT(group->g.layout.dts->ground_sprite, 14); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2307 |
SETBIT(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_TRANSPARENT); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2308 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2309 |
if (HASBIT(group->g.layout.dts->ground_sprite, 15)) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2310 |
CLRBIT(group->g.layout.dts->ground_sprite, 15); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2311 |
SETBIT(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_COLOR); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2312 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2313 |
if (HASBIT(group->g.layout.dts->ground_pal, 14)) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2314 |
CLRBIT(group->g.layout.dts->ground_pal, 14); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2315 |
SETBIT(group->g.layout.dts->ground_sprite, SPRITE_MODIFIER_OPAQUE); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2316 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2317 |
if (HASBIT(group->g.layout.dts->ground_pal, 15)) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2318 |
/* Bit 31 set means this is a custom sprite, so rewrite it to the |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2319 |
* last spriteset defined. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2320 |
SpriteID sprite = _cur_grffile->spriteset_start + GB(group->g.layout.dts->ground_sprite, 0, 14) * sprites; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2321 |
SB(group->g.layout.dts->ground_sprite, 0, SPRITE_WIDTH, sprite); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2322 |
CLRBIT(group->g.layout.dts->ground_pal, 15); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2323 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2324 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2325 |
group->g.layout.dts->seq = CallocT<DrawTileSeqStruct>(num_sprites + 1); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2326 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2327 |
for (i = 0; i < num_sprites; i++) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2328 |
DrawTileSeqStruct *seq = (DrawTileSeqStruct*)&group->g.layout.dts->seq[i]; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2329 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2330 |
seq->image = grf_load_word(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2331 |
seq->pal = grf_load_word(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2332 |
seq->delta_x = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2333 |
seq->delta_y = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2334 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2335 |
if (HASBIT(seq->image, 14)) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2336 |
CLRBIT(seq->image, 14); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2337 |
SETBIT(seq->image, PALETTE_MODIFIER_TRANSPARENT); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2338 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2339 |
if (HASBIT(seq->image, 15)) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2340 |
CLRBIT(seq->image, 15); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2341 |
SETBIT(seq->image, PALETTE_MODIFIER_COLOR); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2342 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2343 |
if (HASBIT(seq->pal, 14)) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2344 |
CLRBIT(seq->pal, 14); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2345 |
SETBIT(seq->image, SPRITE_MODIFIER_OPAQUE); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2346 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2347 |
if (HASBIT(seq->pal, 15)) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2348 |
/* Bit 31 set means this is a custom sprite, so rewrite it to the |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2349 |
* last spriteset defined. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2350 |
SpriteID sprite = _cur_grffile->spriteset_start + GB(seq->image, 0, 14) * sprites; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2351 |
SB(seq->image, 0, SPRITE_WIDTH, sprite); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2352 |
CLRBIT(seq->pal, 15); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2353 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2354 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2355 |
if (type > 0) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2356 |
seq->delta_z = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2357 |
if ((byte)seq->delta_z == 0x80) continue; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2358 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2359 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2360 |
seq->size_x = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2361 |
seq->size_y = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2362 |
seq->size_z = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2363 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2364 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2365 |
/* Set the terminator value. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2366 |
((DrawTileSeqStruct*)group->g.layout.dts->seq)[i].delta_x = (byte)0x80; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2367 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2368 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2369 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2370 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2371 |
/* Loading of Tile Layout and Production Callback groups would happen here */ |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2372 |
default: grfmsg(1, "NewSpriteGroup: Unsupported feature %d, skipping", feature); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2373 |
} |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2374 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2375 |
} |
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
2376 |
|
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
2377 |
_cur_grffile->spritegroups[setid] = group; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2378 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2379 |
|
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2380 |
static CargoID TranslateCargo(uint8 feature, uint8 ctype) |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2381 |
{ |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2382 |
/* Special cargo types for purchase list and stations */ |
6148
5247b66aad19
(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:
6147
diff
changeset
|
2383 |
if (feature == GSF_STATION && ctype == 0xFE) return CT_DEFAULT_NA; |
5247b66aad19
(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:
6147
diff
changeset
|
2384 |
if (ctype == 0xFF) return CT_PURCHASE; |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2385 |
|
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2386 |
if (_cur_grffile->cargo_max == 0) { |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2387 |
/* No cargo table, so use bitnum values */ |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2388 |
if (ctype >= 32) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2389 |
grfmsg(1, "TranslateCargo: Cargo bitnum %d out of range (max 31), skipping.", ctype); |
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2390 |
return CT_INVALID; |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2391 |
} |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2392 |
|
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2393 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2394 |
const CargoSpec *cs = GetCargo(c); |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2395 |
if (!cs->IsValid()) continue; |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2396 |
|
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2397 |
if (cs->bitnum == ctype) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2398 |
grfmsg(6, "TranslateCargo: Cargo bitnum %d mapped to cargo type %d.", ctype, c); |
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2399 |
return c; |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2400 |
} |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2401 |
} |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2402 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2403 |
grfmsg(5, "TranslateCargo: Cargo bitnum %d not available in this climate, skipping.", ctype); |
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2404 |
return CT_INVALID; |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2405 |
} |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2406 |
|
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2407 |
/* Check if the cargo type is out of bounds of the cargo translation table */ |
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2408 |
if (ctype >= _cur_grffile->cargo_max) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2409 |
grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, _cur_grffile->cargo_max - 1); |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2410 |
return CT_INVALID; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2411 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2412 |
|
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2413 |
/* Look up the cargo label from the translation table */ |
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2414 |
CargoLabel cl = _cur_grffile->cargo_list[ctype]; |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2415 |
if (cl == 0) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2416 |
grfmsg(5, "TranslateCargo: Cargo type %d not available in this climate, skipping.", ctype); |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2417 |
return CT_INVALID; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2418 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2419 |
|
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2420 |
ctype = GetCargoIDByLabel(cl); |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2421 |
if (ctype == CT_INVALID) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2422 |
grfmsg(5, "TranslateCargo: Cargo '%c%c%c%c' unsupported, skipping.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8)); |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2423 |
return CT_INVALID; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2424 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2425 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2426 |
grfmsg(6, "TranslateCargo: Cargo '%c%c%c%c' mapped to cargo type %d.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8), ctype); |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2427 |
return ctype; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2428 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2429 |
|
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2430 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2431 |
static void VehicleMapSpriteGroup(byte *buf, byte feature, uint8 idcount, uint8 cidcount, bool wagover) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2432 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2433 |
static byte *last_engines; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2434 |
static int last_engines_count; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2435 |
|
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2436 |
if (!wagover) { |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2437 |
if (last_engines_count != idcount) { |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2438 |
last_engines = ReallocT(last_engines, idcount); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2439 |
last_engines_count = idcount; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2440 |
} |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2441 |
} else { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2442 |
if (last_engines_count == 0) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2443 |
grfmsg(0, "VehicleMapSpriteGroup: WagonOverride: No engine to do override with"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2444 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2445 |
} |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2446 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2447 |
grfmsg(6, "VehicleMapSpriteGroup: WagonOverride: %u engines, %u wagons", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2448 |
last_engines_count, idcount); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2449 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2450 |
|
6281 | 2451 |
for (uint i = 0; i < idcount; i++) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2452 |
uint8 engine_id = buf[3 + i]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2453 |
uint8 engine = engine_id + _vehshifts[feature]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2454 |
byte *bp = &buf[4 + idcount]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2455 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2456 |
if (engine_id > _vehcounts[feature]) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2457 |
grfmsg(0, "Id %u for feature 0x%02X is out of bounds", engine_id, feature); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2458 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2459 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2460 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2461 |
grfmsg(7, "VehicleMapSpriteGroup: [%d] Engine %d...", i, engine); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2462 |
|
6281 | 2463 |
for (uint c = 0; c < cidcount; c++) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2464 |
uint8 ctype = grf_load_byte(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2465 |
uint16 groupid = grf_load_word(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2466 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2467 |
grfmsg(8, "VehicleMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2468 |
|
2516
4659ceee4dcb
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
2469 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2470 |
grfmsg(1, "VehicleMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2471 |
continue; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2472 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2473 |
|
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2474 |
ctype = TranslateCargo(feature, ctype); |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2475 |
if (ctype == CT_INVALID) continue; |
5338
a78592405640
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5334
diff
changeset
|
2476 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2477 |
if (wagover) { |
4869
3a75d9b3b5ea
(svn r6795) - NewGRF: Add support for cargo-specific wagon overrides.
peter1138
parents:
4818
diff
changeset
|
2478 |
SetWagonOverrideSprites(engine, ctype, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2479 |
} else { |
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
2480 |
SetCustomEngineSprites(engine, ctype, _cur_grffile->spritegroups[groupid]); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2481 |
last_engines[i] = engine; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2482 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2483 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2484 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2485 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2486 |
{ |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2487 |
byte *bp = &buf[4 + idcount + cidcount * 3]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2488 |
uint16 groupid = grf_load_word(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2489 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2490 |
grfmsg(8, "-- Default group id 0x%04X", groupid); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2491 |
|
6281 | 2492 |
for (uint i = 0; i < idcount; i++) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2493 |
uint8 engine = buf[3 + i] + _vehshifts[feature]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2494 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2495 |
/* Don't tell me you don't love duplicated code! */ |
2516
4659ceee4dcb
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
2496 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2497 |
grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2498 |
groupid, _cur_grffile->spritegroups_count); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2499 |
continue; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2500 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2501 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2502 |
if (wagover) { |
3695
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
2503 |
/* If the ID for this action 3 is the same as the vehicle ID, |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2504 |
* this indicates we have a helicopter rotor override. */ |
3695
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
2505 |
if (feature == GSF_AIRCRAFT && engine == last_engines[i]) { |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
2506 |
SetRotorOverrideSprites(engine, _cur_grffile->spritegroups[groupid]); |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
2507 |
} else { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2508 |
/* TODO: No multiple cargo types per vehicle yet. --pasky */ |
6148
5247b66aad19
(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:
6147
diff
changeset
|
2509 |
SetWagonOverrideSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
3695
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
2510 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2511 |
} else { |
6148
5247b66aad19
(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:
6147
diff
changeset
|
2512 |
SetCustomEngineSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid]); |
3924
d06b513d65c3
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3895
diff
changeset
|
2513 |
SetEngineGRF(engine, _cur_grffile); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2514 |
last_engines[i] = engine; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2515 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2516 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2517 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2518 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2519 |
|
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2520 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2521 |
static void StationMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount) |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2522 |
{ |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2523 |
for (uint i = 0; i < idcount; i++) { |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2524 |
uint8 stid = buf[3 + i]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2525 |
StationSpec *statspec = _cur_grffile->stations[stid]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2526 |
byte *bp = &buf[4 + idcount]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2527 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2528 |
for (uint c = 0; c < cidcount; c++) { |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2529 |
uint8 ctype = grf_load_byte(&bp); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2530 |
uint16 groupid = grf_load_word(&bp); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2531 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2532 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2533 |
grfmsg(1, "StationMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2534 |
groupid, _cur_grffile->spritegroups_count); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2535 |
continue; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2536 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2537 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2538 |
ctype = TranslateCargo(GSF_STATION, ctype); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2539 |
if (ctype == CT_INVALID) continue; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2540 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2541 |
statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2542 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2543 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2544 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2545 |
{ |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2546 |
byte *bp = &buf[4 + idcount + cidcount * 3]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2547 |
uint16 groupid = grf_load_word(&bp); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2548 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2549 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2550 |
grfmsg(1, "StationMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2551 |
groupid, _cur_grffile->spritegroups_count); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2552 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2553 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2554 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2555 |
for (uint i = 0; i < idcount; i++) { |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2556 |
uint8 stid = buf[3 + i]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2557 |
StationSpec *statspec = _cur_grffile->stations[stid]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2558 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2559 |
statspec->spritegroup[CT_DEFAULT] = _cur_grffile->spritegroups[groupid]; |
6451
e576c71bfc09
(svn r9601) -Codechange: Store grf file reference in station spec, not just GRF ID
peter1138
parents:
6424
diff
changeset
|
2560 |
statspec->grffile = _cur_grffile; |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2561 |
statspec->localidx = stid; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2562 |
SetCustomStationSpec(statspec); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2563 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2564 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2565 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2566 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2567 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2568 |
static void TownHouseMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount) |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2569 |
{ |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2570 |
byte *bp = &buf[4 + idcount + cidcount * 3]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2571 |
uint16 groupid = grf_load_word(&bp); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2572 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2573 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2574 |
grfmsg(1, "TownHouseMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2575 |
groupid, _cur_grffile->spritegroups_count); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2576 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2577 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2578 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2579 |
for (uint i = 0; i < idcount; i++) { |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2580 |
uint8 hid = buf[3 + i]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2581 |
HouseSpec *hs = _cur_grffile->housespec[hid]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2582 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2583 |
if (hs == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2584 |
grfmsg(1, "TownHouseMapSpriteGroup: Too many houses defined, skipping"); |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2585 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2586 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2587 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2588 |
hs->spritegroup = _cur_grffile->spritegroups[groupid]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2589 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2590 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2591 |
|
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2592 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2593 |
static void CargoMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount) |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2594 |
{ |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2595 |
byte *bp = &buf[4 + idcount + cidcount * 3]; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2596 |
uint16 groupid = grf_load_word(&bp); |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2597 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2598 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2599 |
grfmsg(1, "CargoMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2600 |
groupid, _cur_grffile->spritegroups_count); |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2601 |
return; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2602 |
} |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2603 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2604 |
for (uint i = 0; i < idcount; i++) { |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2605 |
CargoID cid = buf[3 + i]; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2606 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2607 |
if (cid >= NUM_CARGO) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2608 |
grfmsg(1, "CargoMapSpriteGroup: Cargo ID %d out of range, skipping"); |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2609 |
continue; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2610 |
} |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2611 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2612 |
CargoSpec *cs = &_cargo[cid]; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2613 |
cs->grfid = _cur_grffile->grfid; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2614 |
cs->group = _cur_grffile->spritegroups[groupid]; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2615 |
} |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2616 |
} |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2617 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2618 |
|
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2619 |
/* Action 0x03 */ |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2620 |
static void FeatureMapSpriteGroup(byte *buf, int len) |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2621 |
{ |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2622 |
/* <03> <feature> <n-id> <ids>... <num-cid> [<cargo-type> <cid>]... <def-cid> |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2623 |
* id-list := [<id>] [id-list] |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2624 |
* cargo-list := <cargo-type> <cid> [cargo-list] |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2625 |
* |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2626 |
* B feature see action 0 |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2627 |
* B n-id bits 0-6: how many IDs this definition applies to |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2628 |
* bit 7: if set, this is a wagon override definition (see below) |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2629 |
* B ids the IDs for which this definition applies |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2630 |
* B num-cid number of cargo IDs (sprite group IDs) in this definition |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2631 |
* can be zero, in that case the def-cid is used always |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2632 |
* B cargo-type type of this cargo type (e.g. mail=2, wood=7, see below) |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2633 |
* W cid cargo ID (sprite group ID) for this type of cargo |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2634 |
* W def-cid default cargo ID (sprite group ID) */ |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2635 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2636 |
if (!check_length(len, 6, "FeatureMapSpriteGroup")) return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2637 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2638 |
uint8 feature = buf[1]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2639 |
uint8 idcount = buf[2] & 0x7F; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2640 |
bool wagover = (buf[2] & 0x80) == 0x80; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2641 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2642 |
if (!check_length(len, 3 + idcount, "FeatureMapSpriteGroup")) return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2643 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2644 |
/* If idcount is zero, this is a feature callback */ |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2645 |
if (idcount == 0) { |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2646 |
grfmsg(2, "FeatureMapSpriteGroup: Feature callbacks not implemented yet"); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2647 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2648 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2649 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2650 |
uint8 cidcount = buf[3 + idcount]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2651 |
if (!check_length(len, 4 + idcount + cidcount * 3, "FeatureMapSpriteGroup")) return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2652 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2653 |
grfmsg(6, "FeatureMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d", |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2654 |
feature, idcount, cidcount, wagover); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2655 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2656 |
if (_cur_grffile->spriteset_start == 0 || _cur_grffile->spritegroups == 0) { |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2657 |
grfmsg(1, "FeatureMapSpriteGroup: No sprite set to work on! Skipping"); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2658 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2659 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2660 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2661 |
switch (feature) { |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2662 |
case GSF_TRAIN: |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2663 |
case GSF_ROAD: |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2664 |
case GSF_SHIP: |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2665 |
case GSF_AIRCRAFT: |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2666 |
VehicleMapSpriteGroup(buf, feature, idcount, cidcount, wagover); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2667 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2668 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2669 |
case GSF_STATION: |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2670 |
StationMapSpriteGroup(buf, idcount, cidcount); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2671 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2672 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2673 |
case GSF_TOWNHOUSE: |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2674 |
TownHouseMapSpriteGroup(buf, idcount, cidcount); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2675 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2676 |
|
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2677 |
case GSF_CARGOS: |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2678 |
CargoMapSpriteGroup(buf, idcount, cidcount); |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2679 |
return; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2680 |
|
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2681 |
default: |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2682 |
grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature %d, skipping", feature); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2683 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2684 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2685 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2686 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2687 |
/* Action 0x04 */ |
3879
cfa3cf4731d2
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
2688 |
static void FeatureNewName(byte *buf, int len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2689 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2690 |
/* <04> <veh-type> <language-id> <num-veh> <offset> <data...> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2691 |
* |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2692 |
* B veh-type see action 0 (as 00..07, + 0A |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2693 |
* But IF veh-type = 48, then generic text |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2694 |
* B language-id If bit 6 is set, This is the extended language scheme, |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2695 |
with up to 64 language. |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2696 |
Otherwise, it is a mapping where set bits have meaning |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2697 |
0 = american, 1 = english, 2 = german, 3 = french, 4 = spanish |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2698 |
Bit 7 set means this is a generic text, not a vehicle one (or else) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2699 |
* B num-veh number of vehicles which are getting a new name |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2700 |
* B/W offset number of the first vehicle that gets a new name |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2701 |
* Byte : ID of vehicle to change |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2702 |
* Word : ID of string to change/add |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2703 |
* S data new texts, each of them zero-terminated, after |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2704 |
* which the next name begins. */ |
6281 | 2705 |
|
3643
c04228043cb0
(svn r4552) - NewGRF: fix braino... in r4550, new_scheme should true when the version is 7 or higher, not less than 7...
peter1138
parents:
3642
diff
changeset
|
2706 |
bool new_scheme = _cur_grffile->grf_version >= 7; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2707 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
2708 |
if (!check_length(len, 6, "FeatureNewName")) return; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2709 |
buf++; |
6281 | 2710 |
uint8 feature = grf_load_byte(&buf); |
2711 |
uint8 lang = grf_load_byte(&buf); |
|
2712 |
uint8 num = grf_load_byte(&buf); |
|
2713 |
bool generic = HASBIT(lang, 7); |
|
2714 |
uint16 id = generic ? grf_load_word(&buf) : grf_load_byte(&buf); |
|
4992
bd2716c79584
(svn r6995) - Codechange: NewGRF; strip bit 7 of the language ID earlier and handle handle a language ID of 0x7F as the preferred default language.
peter1138
parents:
4964
diff
changeset
|
2715 |
|
bd2716c79584
(svn r6995) - Codechange: NewGRF; strip bit 7 of the language ID earlier and handle handle a language ID of 0x7F as the preferred default language.
peter1138
parents:
4964
diff
changeset
|
2716 |
CLRBIT(lang, 7); |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2717 |
|
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
2718 |
if (feature <= GSF_AIRCRAFT && id < _vehcounts[feature]) { |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2719 |
id += _vehshifts[feature]; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2720 |
} |
6281 | 2721 |
uint16 endid = id + num; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2722 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2723 |
grfmsg(6, "FeatureNewName: About to rename engines %d..%d (feature %d) in language 0x%02X", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2724 |
id, endid, feature, lang); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2725 |
|
4992
bd2716c79584
(svn r6995) - Codechange: NewGRF; strip bit 7 of the language ID earlier and handle handle a language ID of 0x7F as the preferred default language.
peter1138
parents:
4964
diff
changeset
|
2726 |
len -= generic ? 6 : 5; |
bd2716c79584
(svn r6995) - Codechange: NewGRF; strip bit 7 of the language ID earlier and handle handle a language ID of 0x7F as the preferred default language.
peter1138
parents:
4964
diff
changeset
|
2727 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2728 |
for (; id < endid && len > 0; id++) { |
6090
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
2729 |
const char *name = grf_load_string(&buf, len); |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
2730 |
size_t name_length = strlen(name) + 1; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
2731 |
|
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
2732 |
len -= (int)name_length; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
2733 |
|
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
2734 |
if (name_length == 1) { |
6062
bc99beb6607d
(svn r8792) -Fix (r6623): Don't check whether a string length is 1 when you already know it isn't.
maedhros
parents:
6030
diff
changeset
|
2735 |
grfmsg(7, "FeatureNewName: Can't add empty name"); |
6090
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
2736 |
} else if (name_length > 127) { |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
2737 |
grfmsg(7, "FeatureNewName: Too long a name (%d)", name_length); |
6062
bc99beb6607d
(svn r8792) -Fix (r6623): Don't check whether a string length is 1 when you already know it isn't.
maedhros
parents:
6030
diff
changeset
|
2738 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2739 |
grfmsg(8, "FeatureNewName: %d <- %s", id, name); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2740 |
|
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2741 |
switch (feature) { |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2742 |
case GSF_TRAIN: |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2743 |
case GSF_ROAD: |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2744 |
case GSF_SHIP: |
3614 | 2745 |
case GSF_AIRCRAFT: { |
3821
57db5bab0f24
(svn r4832) - NewGRF: add support for original string ID to newgrf text handling. So far, this is used for vehicles when no English or American translation is provided.
peter1138
parents:
3814
diff
changeset
|
2746 |
if (id < TOTAL_NUM_ENGINES) { |
57db5bab0f24
(svn r4832) - NewGRF: add support for original string ID to newgrf text handling. So far, this is used for vehicles when no English or American translation is provided.
peter1138
parents:
3814
diff
changeset
|
2747 |
StringID string = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_8000_KIRBY_PAUL_TANK_STEAM + id); |
57db5bab0f24
(svn r4832) - NewGRF: add support for original string ID to newgrf text handling. So far, this is used for vehicles when no English or American translation is provided.
peter1138
parents:
3814
diff
changeset
|
2748 |
SetCustomEngineName(id, string); |
57db5bab0f24
(svn r4832) - NewGRF: add support for original string ID to newgrf text handling. So far, this is used for vehicles when no English or American translation is provided.
peter1138
parents:
3814
diff
changeset
|
2749 |
} else { |
57db5bab0f24
(svn r4832) - NewGRF: add support for original string ID to newgrf text handling. So far, this is used for vehicles when no English or American translation is provided.
peter1138
parents:
3814
diff
changeset
|
2750 |
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, id); |
57db5bab0f24
(svn r4832) - NewGRF: add support for original string ID to newgrf text handling. So far, this is used for vehicles when no English or American translation is provided.
peter1138
parents:
3814
diff
changeset
|
2751 |
} |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2752 |
break; |
3614 | 2753 |
} |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2754 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2755 |
case GSF_TOWNHOUSE: |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
2756 |
default: |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2757 |
switch (GB(id, 8, 8)) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2758 |
case 0xC4: // Station class name |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
2759 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2760 |
grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
2761 |
} else { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
2762 |
StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass; |
3821
57db5bab0f24
(svn r4832) - NewGRF: add support for original string ID to newgrf text handling. So far, this is used for vehicles when no English or American translation is provided.
peter1138
parents:
3814
diff
changeset
|
2763 |
SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED)); |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
2764 |
} |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2765 |
break; |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
2766 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2767 |
case 0xC5: // Station name |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
2768 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2769 |
grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
2770 |
} else { |
3821
57db5bab0f24
(svn r4832) - NewGRF: add support for original string ID to newgrf text handling. So far, this is used for vehicles when no English or American translation is provided.
peter1138
parents:
3814
diff
changeset
|
2771 |
_cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
2772 |
} |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2773 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2774 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2775 |
case 0xC9: { // House name |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2776 |
if (_cur_grffile->housespec == NULL || _cur_grffile->housespec[GB(id, 0, 8)] == NULL) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2777 |
grfmsg(1, "FeatureNewName: Attempt to name undefined house 0x%X, ignoring.", GB(id, 0, 8)); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2778 |
} else { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2779 |
_cur_grffile->housespec[GB(id, 0, 8)]->building_name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2780 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2781 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2782 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2783 |
|
4504
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2784 |
case 0xD0: |
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2785 |
case 0xDC: |
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2786 |
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2787 |
break; |
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2788 |
|
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2789 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2790 |
grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2791 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2792 |
} |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2793 |
break; |
3642
8da309b5fd2b
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
2794 |
|
8da309b5fd2b
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
2795 |
#if 0 |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2796 |
case GSF_CANAL : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2797 |
case GSF_BRIDGE : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2798 |
AddGRFString(_cur_spriteid, id, lang, name); |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6481
diff
changeset
|
2799 |
switch (GB(id, 8, 8)) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2800 |
case 0xC9: // House name |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2801 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2802 |
grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2803 |
} |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2804 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2805 |
|
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2806 |
case GSF_INDUSTRIES : |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2807 |
case 0x48 : // for generic strings |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2808 |
AddGRFString(_cur_spriteid, id, lang, name); |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2809 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2810 |
default : |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2811 |
grfmsg(7, "FeatureNewName: Unsupported feature (0x%02X)", feature); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2812 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2813 |
#endif |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2814 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2815 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2816 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2817 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2818 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2819 |
/* Action 0x05 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2820 |
static void GraphicsNew(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2821 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2822 |
/* <05> <graphics-type> <num-sprites> <other data...> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2823 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2824 |
* B graphics-type What set of graphics the sprites define. |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2825 |
* E num-sprites How many sprites are in this set? |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2826 |
* V other data Graphics type specific data. Currently unused. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2827 |
/* TODO */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2828 |
|
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2829 |
SpriteID replace = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2830 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
2831 |
if (!check_length(len, 2, "GraphicsNew")) return; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2832 |
buf++; |
6281 | 2833 |
uint8 type = grf_load_byte(&buf); |
2834 |
uint16 num = grf_load_extended(&buf); |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2835 |
|
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2836 |
switch (type) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2837 |
case 0x04: // Signal graphics |
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2838 |
if (num != 112 && num != 240) { |
6469
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2839 |
grfmsg(1, "GraphicsNew: Signal graphics sprite count must be 112 or 240, skipping"); |
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2840 |
return; |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2841 |
} |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2842 |
_signal_base = _cur_spriteid; |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2843 |
break; |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2844 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2845 |
case 0x05: // Catenary graphics |
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2846 |
if (num != 48) { |
6469
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2847 |
grfmsg(1, "GraphicsNew: Catenary graphics sprite count must be 48, skipping"); |
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2848 |
return; |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2849 |
} |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2850 |
replace = SPR_ELRAIL_BASE + 3; |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2851 |
break; |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2852 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2853 |
case 0x06: // Foundations |
3709
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2854 |
if (num != 74) { |
6469
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2855 |
grfmsg(1, "GraphicsNew: Foundation graphics sprite count must be 74, skipping"); |
3709
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2856 |
return; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2857 |
} |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2858 |
replace = SPR_SLOPES_BASE; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2859 |
break; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2860 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2861 |
case 0x08: // Canal graphics |
3709
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2862 |
if (num != 65) { |
6469
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2863 |
grfmsg(1, "GraphicsNew: Canal graphics sprite count must be 65, skipping"); |
3709
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2864 |
return; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2865 |
} |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2866 |
replace = SPR_CANALS_BASE + 5; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2867 |
break; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2868 |
|
6469
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2869 |
case 0x0A: // 2CC colour maps |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2870 |
if (num != 256) { |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2871 |
grfmsg(1, "GraphicsNew: 2CC colour maps sprite count must be 256, skipping"); |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2872 |
return; |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2873 |
} |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2874 |
replace = SPR_2CCMAP_BASE; |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2875 |
break; |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2876 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2877 |
case 0x0D: // Coast graphics |
5210
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2878 |
if (num != 16) { |
6469
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2879 |
grfmsg(1, "GraphicsNew: Coast graphics sprite count must be 16, skipping"); |
5210
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2880 |
return; |
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2881 |
} |
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2882 |
_coast_base = _cur_spriteid; |
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2883 |
break; |
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2884 |
|
6469
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2885 |
case 0x10: // New airport sprites |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2886 |
if (num != 15) { |
6470
bd3a843a560b
(svn r9646) -Fix (r9645): incorrect count in error message for airport graphics
peter1138
parents:
6469
diff
changeset
|
2887 |
grfmsg(1, "GraphicsNew: Airport graphics sprite count must be 15, skipping"); |
6469
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2888 |
return; |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2889 |
} |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2890 |
replace = SPR_AIRPORTX_BASE; |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2891 |
break; |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2892 |
|
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2893 |
case 0x11: // Road stop sprites |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2894 |
if (num != 8) { |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2895 |
grfmsg(1, "GraphicsNew: Road stop graphics sprite count must be 8, skipping"); |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2896 |
return; |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2897 |
} |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2898 |
replace = SPR_ROADSTOP_BASE; |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2899 |
break; |
74a3ed883324
(svn r9645) -Feature: Add NewGRF Action 5 (Sprite Replacement) support for 2cc colour maps, airport, and road stop sprites.
peter1138
parents:
6463
diff
changeset
|
2900 |
|
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2901 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2902 |
grfmsg(2, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring)", |
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2903 |
type, num); |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2904 |
return; |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2905 |
} |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2906 |
|
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2907 |
if (replace == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2908 |
grfmsg(2, "GraphicsNew: Loading %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, _cur_spriteid); |
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2909 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2910 |
grfmsg(2, "GraphicsNew: Replacing %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, replace); |
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2911 |
} |
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2912 |
|
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2913 |
for (; num > 0; num--) { |
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2914 |
LoadNextSprite(replace == 0 ? _cur_spriteid++ : replace++, _file_index); |
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2915 |
_nfo_line++; |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
2916 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2917 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2918 |
|
3806 | 2919 |
static uint32 GetParamVal(byte param, uint32 *cond_val) |
2920 |
{ |
|
2921 |
switch (param) { |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2922 |
case 0x81: // current year |
5340
8e534cd781cc
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5338
diff
changeset
|
2923 |
return clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; |
8e534cd781cc
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5338
diff
changeset
|
2924 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2925 |
case 0x83: // current climate, 0=temp, 1=arctic, 2=trop, 3=toyland |
3806 | 2926 |
return _opt.landscape; |
2927 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2928 |
case 0x84: // GRF loading stage |
5161
e5ba90f4da6f
(svn r7266) -Codechange: Make the NewGRF loading stage look like ttdpatch to NewGRFs
peter1138
parents:
5115
diff
changeset
|
2929 |
return (_cur_stage > GLS_INIT) | ((_cur_stage == GLS_ACTIVATION) << 9); |
3806 | 2930 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2931 |
case 0x85: // TTDPatch flags, only for bit tests |
3811
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2932 |
if (cond_val == NULL) { |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2933 |
/* Supported in Action 0x07 and 0x09, not 0x0D */ |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2934 |
return 0; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2935 |
} else { |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2936 |
uint32 param_val = _ttdpatch_flags[*cond_val / 0x20]; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2937 |
*cond_val %= 0x20; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2938 |
return param_val; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2939 |
} |
3806 | 2940 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2941 |
case 0x86: // road traffic side, bit 4 clear=left, set=right |
3806 | 2942 |
return _opt.road_side << 4; |
2943 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2944 |
case 0x88: // GRF ID check |
3806 | 2945 |
return 0; |
2946 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2947 |
case 0x8B: { // TTDPatch version |
3806 | 2948 |
uint major = 2; |
4993
dc740984a32f
(svn r6996) - Codechange: Pretend to be the current version of TTDPatch. This value doesn't anything to us as we don't follow TTDPatch's development timeline...
peter1138
parents:
4992
diff
changeset
|
2949 |
uint minor = 6; |
dc740984a32f
(svn r6996) - Codechange: Pretend to be the current version of TTDPatch. This value doesn't anything to us as we don't follow TTDPatch's development timeline...
peter1138
parents:
4992
diff
changeset
|
2950 |
uint revision = 0; // special case: 2.0.1 is 2.0.10 |
dc740984a32f
(svn r6996) - Codechange: Pretend to be the current version of TTDPatch. This value doesn't anything to us as we don't follow TTDPatch's development timeline...
peter1138
parents:
4992
diff
changeset
|
2951 |
uint build = 1168; |
dc740984a32f
(svn r6996) - Codechange: Pretend to be the current version of TTDPatch. This value doesn't anything to us as we don't follow TTDPatch's development timeline...
peter1138
parents:
4992
diff
changeset
|
2952 |
return (major << 24) | (minor << 20) | (revision << 16) | build; |
3806 | 2953 |
} |
2954 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2955 |
case 0x8D: // TTD Version, 00=DOS, 01=Windows |
3806 | 2956 |
return !_use_dos_palette; |
2957 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2958 |
case 0x8E: // Y-offset for train sprites |
3806 | 2959 |
return _traininfo_vehicle_pitch; |
2960 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2961 |
case 0x92: // Game mode |
3806 | 2962 |
return _game_mode; |
2963 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2964 |
case 0x9A: // Always -1 |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
2965 |
return UINT_MAX; |
5287
917cc6407bda
(svn r7436) -Codechange: Add action7/9/D variable 0x9A (-1)
peter1138
parents:
5234
diff
changeset
|
2966 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2967 |
case 0x9D: // TTD Platform, 00=TTDPatch, 01=OpenTTD |
3806 | 2968 |
return 1; |
2969 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2970 |
case 0x9E: // Miscellaneous GRF features |
3814
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2971 |
return _misc_grf_features; |
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2972 |
|
3806 | 2973 |
default: |
2974 |
/* GRF Parameter */ |
|
2975 |
if (param < 0x80) return _cur_grffile->param[param]; |
|
2976 |
||
2977 |
/* In-game variable. */ |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2978 |
grfmsg(1, "Unsupported in-game variable 0x%02X", param); |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
2979 |
return UINT_MAX; |
3806 | 2980 |
} |
2981 |
} |
|
2982 |
||
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2983 |
/* Action 0x06 */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2984 |
static void CfgApply(byte *buf, int len) |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2985 |
{ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2986 |
/* <06> <param-num> <param-size> <offset> ... <FF> |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2987 |
* |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2988 |
* B param-num Number of parameter to substitute (First = "zero") |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2989 |
* Ignored if that parameter was not specified in newgrf.cfg |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2990 |
* B param-size How many bytes to replace. If larger than 4, the |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2991 |
* bytes of the following parameter are used. In that |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2992 |
* case, nothing is applied unless *all* parameters |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2993 |
* were specified. |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2994 |
* B offset Offset into data from beginning of next sprite |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2995 |
* to place where parameter is to be stored. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2996 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2997 |
/* Preload the next sprite */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2998 |
uint32 pos = FioGetPos(); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2999 |
uint16 num = FioReadWord(); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3000 |
uint8 type = FioReadByte(); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3001 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3002 |
/* Check if the sprite is a pseudo sprite. We can't operate on real sprites. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3003 |
if (type == 0xFF) { |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
3004 |
_preload_sprite = MallocT<byte>(num); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3005 |
FioReadBlock(_preload_sprite, num); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3006 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3007 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3008 |
/* Reset the file position to the start of the next sprite */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3009 |
FioSeekTo(pos, SEEK_SET); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3010 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3011 |
if (type != 0xFF) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3012 |
grfmsg(2, "CfgApply: Ignoring (next sprite is real, unsupported)"); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3013 |
return; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3014 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3015 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3016 |
/* Now perform the Action 0x06 on our data. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3017 |
buf++; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3018 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3019 |
for (;;) { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3020 |
uint i; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3021 |
uint param_num; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3022 |
uint param_size; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3023 |
uint offset; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3024 |
bool add_value; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3025 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3026 |
/* Read the parameter to apply. 0xFF indicates no more data to change. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3027 |
param_num = grf_load_byte(&buf); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3028 |
if (param_num == 0xFF) break; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3029 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3030 |
/* Get the size of the parameter to use. If the size covers multiple |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3031 |
* double words, sequential parameter values are used. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3032 |
param_size = grf_load_byte(&buf); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3033 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3034 |
/* Bit 7 of param_size indicates we should add to the original value |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3035 |
* instead of replacing it. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3036 |
add_value = HASBIT(param_size, 7); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3037 |
param_size = GB(param_size, 0, 7); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3038 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3039 |
/* Where to apply the data to within the pseudo sprite data. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3040 |
offset = grf_load_extended(&buf); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3041 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3042 |
/* If the parameter is a GRF parameter (not an internal variable) check |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3043 |
* if it (and all further sequential parameters) has been defined. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3044 |
if (param_num < 0x80 && (param_num + (param_size - 1) / 4) >= _cur_grffile->param_end) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3045 |
grfmsg(2, "CfgApply: Ignoring (param %d not set)", (param_num + (param_size - 1) / 4)); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3046 |
break; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3047 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3048 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3049 |
grfmsg(8, "CfgApply: Applying %u bytes from parameter 0x%02X at offset 0x%04X", param_size, param_num, offset); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3050 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3051 |
for (i = 0; i < param_size; i++) { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3052 |
uint32 value = GetParamVal(param_num + i / 4, NULL); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3053 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3054 |
if (add_value) { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3055 |
_preload_sprite[offset + i] += GB(value, (i % 4) * 8, 8); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3056 |
} else { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3057 |
_preload_sprite[offset + i] = GB(value, (i % 4) * 8, 8); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3058 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3059 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3060 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3061 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3062 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3063 |
/* Action 0x07 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3064 |
/* Action 0x09 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3065 |
static void SkipIf(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3066 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3067 |
/* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3068 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3069 |
* B param-num |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3070 |
* B param-size |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3071 |
* B condition-type |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3072 |
* V value |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3073 |
* B num-sprites */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3074 |
/* TODO: More params. More condition types. */ |
2336
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
3075 |
uint32 cond_val = 0; |
3806 | 3076 |
uint32 mask = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3077 |
bool result; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3078 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
3079 |
if (!check_length(len, 6, "SkipIf")) return; |
3714
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
3080 |
buf++; |
6281 | 3081 |
uint8 param = grf_load_byte(&buf); |
3082 |
uint8 paramsize = grf_load_byte(&buf); |
|
3083 |
uint8 condtype = grf_load_byte(&buf); |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3084 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3085 |
if (condtype < 2) { |
1611 | 3086 |
/* Always 1 for bit tests, the given value should be ignored. */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3087 |
paramsize = 1; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3088 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3089 |
|
1611 | 3090 |
switch (paramsize) { |
3806 | 3091 |
case 4: cond_val = grf_load_dword(&buf); mask = 0xFFFFFFFF; break; |
3092 |
case 2: cond_val = grf_load_word(&buf); mask = 0x0000FFFF; break; |
|
3093 |
case 1: cond_val = grf_load_byte(&buf); mask = 0x000000FF; break; |
|
1611 | 3094 |
default: break; |
3095 |
} |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3096 |
|
3806 | 3097 |
if (param < 0x80 && _cur_grffile->param_end <= param) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3098 |
grfmsg(7, "SkipIf: Param %d undefined, skipping test", param); |
3806 | 3099 |
return; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3100 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3101 |
|
6281 | 3102 |
uint32 param_val = GetParamVal(param, &cond_val); |
3806 | 3103 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3104 |
grfmsg(7, "SkipIf: Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val); |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3105 |
|
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3106 |
if (param == 0x88) { |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3107 |
/* GRF ID checks */ |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3108 |
|
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3109 |
const GRFConfig *c = GetGRFConfig(cond_val); |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3110 |
|
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3111 |
if (condtype != 10 && c == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3112 |
grfmsg(7, "SkipIf: GRFID 0x%08X unknown, skipping test", BSWAP32(cond_val)); |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3113 |
return; |
5234
980aa61260aa
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5228
diff
changeset
|
3114 |
} |
980aa61260aa
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5228
diff
changeset
|
3115 |
|
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3116 |
switch (condtype) { |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3117 |
/* Tests 6 to 10 are only for param 0x88, GRFID checks */ |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3118 |
case 6: // Is GRFID active? |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3119 |
result = c->status == GCS_ACTIVATED; |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3120 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3121 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3122 |
case 7: // Is GRFID non-active? |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3123 |
result = c->status != GCS_ACTIVATED; |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3124 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3125 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3126 |
case 8: // GRFID is not but will be active? |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3127 |
result = c->status == GCS_INITIALISED; |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3128 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3129 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3130 |
case 9: // GRFID is or will be active? |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3131 |
result = c->status == GCS_ACTIVATED || c->status == GCS_INITIALISED; |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3132 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3133 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3134 |
case 10: // GRFID is not nor will be active |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3135 |
/* This is the only condtype that doesn't get ignored if the GRFID is not found */ |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3136 |
result = c == NULL || c->flags == GCS_DISABLED || c->status == GCS_NOT_FOUND; |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3137 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3138 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3139 |
default: grfmsg(1, "SkipIf: Unsupported GRF test %d. Ignoring", condtype); return; |
5234
980aa61260aa
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5228
diff
changeset
|
3140 |
} |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3141 |
} else { |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3142 |
/* Parameter or variable tests */ |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3143 |
switch (condtype) { |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3144 |
case 0: result = !!(param_val & (1 << cond_val)); |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3145 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3146 |
case 1: result = !(param_val & (1 << cond_val)); |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3147 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3148 |
case 2: result = (param_val & mask) == cond_val; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3149 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3150 |
case 3: result = (param_val & mask) != cond_val; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3151 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3152 |
case 4: result = (param_val & mask) < cond_val; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3153 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3154 |
case 5: result = (param_val & mask) > cond_val; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3155 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3156 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3157 |
default: grfmsg(1, "SkipIf: Unsupported test %d. Ignoring", condtype); return; |
5234
980aa61260aa
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5228
diff
changeset
|
3158 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3159 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3160 |
|
1607
fd027776f222
(svn r2111) So, result is bool therefore no need for this horrible == 0 thing.
pasky
parents:
1606
diff
changeset
|
3161 |
if (!result) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3162 |
grfmsg(2, "SkipIf: Not skipping sprites, test was false"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3163 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3164 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3165 |
|
6281 | 3166 |
uint8 numsprites = grf_load_byte(&buf); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3167 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3168 |
/* numsprites can be a GOTO label if it has been defined in the GRF |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3169 |
* file. The jump will always be the first matching label that follows |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3170 |
* the current nfo_line. If no matching label is found, the first matching |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3171 |
* label in the file is used. */ |
6281 | 3172 |
GRFLabel *choice = NULL; |
3173 |
for (GRFLabel *label = _cur_grffile->label; label != NULL; label = label->next) { |
|
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3174 |
if (label->label != numsprites) continue; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3175 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3176 |
/* Remember a goto before the current line */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3177 |
if (choice == NULL) choice = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3178 |
/* If we find a label here, this is definitely good */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3179 |
if (label->nfo_line > _nfo_line) { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3180 |
choice = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3181 |
break; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3182 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3183 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3184 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3185 |
if (choice != NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3186 |
grfmsg(2, "SkipIf: Jumping to label 0x%0X at line %d, test was true", choice->label, choice->nfo_line); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3187 |
FioSeekTo(choice->pos, SEEK_SET); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3188 |
_nfo_line = choice->nfo_line; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3189 |
return; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3190 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3191 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3192 |
grfmsg(2, "SkipIf: Skipping %d sprites, test was true", numsprites); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3193 |
_skip_sprites = numsprites; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3194 |
if (_skip_sprites == 0) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3195 |
/* Zero means there are no sprites to skip, so |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3196 |
* we use -1 to indicate that all further |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3197 |
* sprites should be skipped. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3198 |
_skip_sprites = -1; |
6096
aafc68ecee06
(svn r8831) -Feature: If an action 7/9 leads to skipping the rest of the file, disable the
maedhros
parents:
6095
diff
changeset
|
3199 |
|
aafc68ecee06
(svn r8831) -Feature: If an action 7/9 leads to skipping the rest of the file, disable the
maedhros
parents:
6095
diff
changeset
|
3200 |
/* If an action 8 hasn't been encountered yet, disable the grf. */ |
6373
75654b0484cd
(svn r9436) -Fix (r9411): don't deactivate GRF in an action 7/9 during reservation (and loading of cargo data), and action 6 should be run also
peter1138
parents:
6365
diff
changeset
|
3201 |
if (_cur_stage != GLS_RESERVE && _cur_grfconfig->status != GCS_ACTIVATED) _cur_grfconfig->status = GCS_DISABLED; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3202 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3203 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3204 |
|
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
3205 |
|
5502
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3206 |
/* Action 0x08 (GLS_FILESCAN) */ |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3207 |
static void ScanInfo(byte *buf, int len) |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3208 |
{ |
6281 | 3209 |
if (!check_length(len, 8, "Info")) return; |
3210 |
buf++; |
|
3211 |
grf_load_byte(&buf); |
|
3212 |
uint32 grfid = grf_load_dword(&buf); |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3213 |
|
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3214 |
_cur_grfconfig->grfid = grfid; |
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
3215 |
|
5329
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
3216 |
/* GRF IDs starting with 0xFF are reserved for internal TTDPatch use */ |
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
3217 |
if (GB(grfid, 24, 8) == 0xFF) SETBIT(_cur_grfconfig->flags, GCF_SYSTEM); |
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
3218 |
|
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
3219 |
len -= 6; |
6281 | 3220 |
const char *name = grf_load_string(&buf, len); |
6186
fdb3705ca465
(svn r8964) -Codechange: use grf_load_string to read action 8 strings instead of trying to do the same manually.
rubidium
parents:
6148
diff
changeset
|
3221 |
_cur_grfconfig->name = TranslateTTDPatchCodes(name); |
fdb3705ca465
(svn r8964) -Codechange: use grf_load_string to read action 8 strings instead of trying to do the same manually.
rubidium
parents:
6148
diff
changeset
|
3222 |
|
fdb3705ca465
(svn r8964) -Codechange: use grf_load_string to read action 8 strings instead of trying to do the same manually.
rubidium
parents:
6148
diff
changeset
|
3223 |
len -= strlen(name) + 1; |
fdb3705ca465
(svn r8964) -Codechange: use grf_load_string to read action 8 strings instead of trying to do the same manually.
rubidium
parents:
6148
diff
changeset
|
3224 |
if (len > 0) { |
6281 | 3225 |
const char *info = grf_load_string(&buf, len); |
6186
fdb3705ca465
(svn r8964) -Codechange: use grf_load_string to read action 8 strings instead of trying to do the same manually.
rubidium
parents:
6148
diff
changeset
|
3226 |
_cur_grfconfig->info = TranslateTTDPatchCodes(info); |
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
3227 |
} |
5329
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
3228 |
|
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
3229 |
/* GLS_INFOSCAN only looks for the action 8, so we can skip the rest of the file */ |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3230 |
_skip_sprites = -1; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3231 |
} |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3232 |
|
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
3233 |
/* Action 0x08 */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3234 |
static void GRFInfo(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3235 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3236 |
/* <08> <version> <grf-id> <name> <info> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3237 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3238 |
* B version newgrf version, currently 06 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3239 |
* 4*B grf-id globally unique ID of this .grf file |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3240 |
* S name name of this .grf set |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3241 |
* S info string describing the set, and e.g. author and copyright */ |
6281 | 3242 |
|
3243 |
if (!check_length(len, 8, "GRFInfo")) return; |
|
3244 |
buf++; |
|
3245 |
uint8 version = grf_load_byte(&buf); |
|
3246 |
uint32 grfid = grf_load_dword(&buf); |
|
3247 |
const char *name = grf_load_string(&buf, len - 6); |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3248 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3249 |
_cur_grffile->grfid = grfid; |
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
3250 |
_cur_grffile->grf_version = version; |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3251 |
_cur_grfconfig->status = _cur_stage < GLS_ACTIVATION ? GCS_INITIALISED : GCS_ACTIVATED; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3252 |
|
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
3253 |
/* Do swap the GRFID for displaying purposes since people expect that */ |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3254 |
DEBUG(grf, 1, "GRFInfo: Loaded GRFv%d set %08lX - %s", version, BSWAP32(grfid), name); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3255 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3256 |
|
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
3257 |
/* Action 0x0A */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3258 |
static void SpriteReplace(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3259 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3260 |
/* <0A> <num-sets> <set1> [<set2> ...] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3261 |
* <set>: <num-sprites> <first-sprite> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3262 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3263 |
* B num-sets How many sets of sprites to replace. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3264 |
* Each set: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3265 |
* B num-sprites How many sprites are in this set |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3266 |
* W first-sprite First sprite number to replace */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3267 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3268 |
buf++; // skip action byte |
6281 | 3269 |
uint8 num_sets = grf_load_byte(&buf); |
3270 |
||
3271 |
for (uint i = 0; i < num_sets; i++) { |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
3272 |
uint8 num_sprites = grf_load_byte(&buf); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
3273 |
uint16 first_sprite = grf_load_word(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3274 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3275 |
grfmsg(2, "SpriteReplace: [Set %d] Changing %d sprites, beginning with %d", |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
3276 |
i, num_sprites, first_sprite |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
3277 |
); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3278 |
|
6281 | 3279 |
for (uint j = 0; j < num_sprites; j++) { |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
3280 |
LoadNextSprite(first_sprite + j, _file_index); // XXX |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
3281 |
_nfo_line++; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3282 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3283 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3284 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3285 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
3286 |
/* Action 0x0B */ |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3287 |
static void GRFLoadError(byte *buf, int len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3288 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3289 |
/* <0B> <severity> <language-id> <message-id> [<message...> 00] [<data...>] 00 [<parnum>] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3290 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3291 |
* B severity 00: notice, contine loading grf file |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3292 |
* 01: warning, continue loading grf file |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3293 |
* 02: error, but continue loading grf file, and attempt |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3294 |
* loading grf again when loading or starting next game |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3295 |
* 03: error, abort loading and prevent loading again in |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3296 |
* the future (only when restarting the patch) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3297 |
* B language-id see action 4, use 1F for built-in error messages |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3298 |
* B message-id message to show, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3299 |
* S message for custom messages (message-id FF), text of the message |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3300 |
* not present for built-in messages. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3301 |
* V data additional data for built-in (or custom) messages |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3302 |
* B parnum parameter numbers to be shown in the message (maximum of 2) */ |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3303 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3304 |
static const StringID msgstr[] = { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3305 |
STR_NEWGRF_ERROR_VERSION_NUMBER, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3306 |
STR_NEWGRF_ERROR_DOS_OR_WINDOWS, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3307 |
STR_NEWGRF_ERROR_UNSET_SWITCH, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3308 |
STR_NEWGRF_ERROR_INVALID_PARAMETER, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3309 |
STR_NEWGRF_ERROR_LOAD_BEFORE, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3310 |
STR_NEWGRF_ERROR_LOAD_AFTER |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3311 |
}; |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
3312 |
|
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3313 |
static const StringID sevstr[] = { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3314 |
STR_NEWGRF_ERROR_MSG_INFO, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3315 |
STR_NEWGRF_ERROR_MSG_WARNING, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3316 |
STR_NEWGRF_ERROR_MSG_ERROR, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3317 |
STR_NEWGRF_ERROR_MSG_FATAL |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
3318 |
}; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3319 |
|
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3320 |
/* AddGRFString expects the string to be referred to by an id in the newgrf |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3321 |
* file. Errors messages are never referred to however, so invent ids that |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3322 |
* are unlikely to be reached in a newgrf file so they don't overwrite |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3323 |
* anything else. */ |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3324 |
enum { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3325 |
MESSAGE_STRING_ID = MAX_UVALUE(StringID) - 1, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3326 |
MESSAGE_DATA_ID = MAX_UVALUE(StringID) |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3327 |
}; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3328 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3329 |
if (!check_length(len, 6, "GRFLoadError")) return; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3330 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3331 |
/* For now we can only show one message per newgrf file. */ |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3332 |
if (_cur_grfconfig->error != NULL) return; |
6090
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
3333 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3334 |
buf++; // Skip the action byte. |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3335 |
byte severity = grf_load_byte(&buf); |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3336 |
byte lang = grf_load_byte(&buf); |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3337 |
byte message_id = grf_load_byte(&buf); |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3338 |
len -= 4; |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3339 |
|
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3340 |
/* Skip the error until the activation stage unless bit 7 of the severity |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3341 |
* is set. */ |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3342 |
if (!HASBIT(severity, 7) && _cur_stage < GLS_ACTIVATION) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3343 |
grfmsg(7, "GRFLoadError: Skipping non-fatal GRFLoadError in stage 1"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3344 |
return; |
3588
69817310ddf8
(svn r4474) - NewGRF: Skip non-fatal errors when not in stage 2.
peter1138
parents:
3577
diff
changeset
|
3345 |
} |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3346 |
CLRBIT(severity, 7); |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3347 |
|
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3348 |
if (severity >= lengthof(sevstr)) { |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3349 |
grfmsg(7, "GRFLoadError: Invalid severity id %d. Setting to 2 (non-fatal error).", severity); |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3350 |
severity = 2; |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3351 |
} else if (severity == 3) { |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3352 |
/* This is a fatal error, so make sure the GRF is deactivated and no |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3353 |
* more of it gets loaded. */ |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3354 |
_cur_grfconfig->status = GCS_DISABLED; |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3355 |
|
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3356 |
_skip_sprites = -1; |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3357 |
} |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3358 |
|
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3359 |
if (message_id >= lengthof(msgstr) && message_id != 0xFF) { |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3360 |
grfmsg(7, "GRFLoadError: Invalid message id."); |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3361 |
return; |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3362 |
} |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3363 |
|
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3364 |
if (len <= 1) { |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3365 |
grfmsg(7, "GRFLoadError: No message data supplied."); |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3366 |
return; |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3367 |
} |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
3368 |
|
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3369 |
bool new_scheme = _cur_grffile->grf_version >= 7; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3370 |
GRFError *error = CallocT<GRFError>(1); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3371 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3372 |
error->severity = sevstr[severity]; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3373 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3374 |
if (message_id == 0xFF) { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3375 |
/* This is a custom error message. */ |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3376 |
const char *message = grf_load_string(&buf, len); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3377 |
len -= (strlen(message) + 1); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3378 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3379 |
error->message = AddGRFString(_cur_grffile->grfid, MESSAGE_STRING_ID, lang, new_scheme, message, STR_UNDEFINED); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3380 |
} else { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3381 |
error->message = msgstr[message_id]; |
6103
d38163ddfef9
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6096
diff
changeset
|
3382 |
} |
d38163ddfef9
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6096
diff
changeset
|
3383 |
|
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3384 |
if (len > 0) { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3385 |
const char *data = grf_load_string(&buf, len); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3386 |
len -= (strlen(data) + 1); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3387 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3388 |
error->data = AddGRFString(_cur_grffile->grfid, MESSAGE_DATA_ID, lang, new_scheme, data, STR_UNDEFINED); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3389 |
} |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3390 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3391 |
/* Only two parameter numbers can be used in the string. */ |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3392 |
uint i = 0; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3393 |
for (; i < 2 && len > 0; i++) { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3394 |
error->param_number[i] = grf_load_byte(&buf); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3395 |
len--; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3396 |
} |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3397 |
error->num_params = i; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3398 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
3399 |
_cur_grfconfig->error = error; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3400 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3401 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
3402 |
/* Action 0x0C */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3403 |
static void GRFComment(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3404 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3405 |
/* <0C> [<ignored...>] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3406 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3407 |
* V ignored Anything following the 0C is ignored */ |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3408 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3409 |
if (len == 1) return; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3410 |
|
6107 | 3411 |
int text_len = len - 1; |
3412 |
const char *text = (const char*)(buf + 1); |
|
3413 |
grfmsg(2, "GRFComment: %.*s", text_len, text); |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3414 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3415 |
|
5525
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3416 |
/* Action 0x0D (GLS_SAFETYSCAN) */ |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3417 |
static void SafeParamSet(byte *buf, int len) |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3418 |
{ |
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
3419 |
if (!check_length(len, 5, "SafeParamSet")) return; |
5525
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3420 |
buf++; |
6281 | 3421 |
uint8 target = grf_load_byte(&buf); |
5525
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3422 |
|
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3423 |
/* Only writing GRF parameters is considered safe */ |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3424 |
if (target < 0x80) return; |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3425 |
|
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3426 |
/* GRM could be unsafe, but as here it can only happen after other GRFs |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3427 |
* are loaded, it should be okay. If the GRF tried to use the slots it |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3428 |
* reserved, it would be marked unsafe anyway. GRM for (e.g. bridge) |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3429 |
* sprites is considered safe. */ |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3430 |
|
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3431 |
SETBIT(_cur_grfconfig->flags, GCF_UNSAFE); |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3432 |
|
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3433 |
/* Skip remainder of GRF */ |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3434 |
_skip_sprites = -1; |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3435 |
} |
c4aadd23c749
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5502
diff
changeset
|
3436 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3437 |
/* Action 0x0D */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3438 |
static void ParamSet(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3439 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3440 |
/* <0D> <target> <operation> <source1> <source2> [<data>] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3441 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3442 |
* B target parameter number where result is stored |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3443 |
* B operation operation to perform, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3444 |
* B source1 first source operand |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3445 |
* B source2 second source operand |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3446 |
* D data data to use in the calculation, not necessary |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3447 |
* if both source1 and source2 refer to actual parameters |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3448 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3449 |
* Operations |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3450 |
* 00 Set parameter equal to source1 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3451 |
* 01 Addition, source1 + source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3452 |
* 02 Subtraction, source1 - source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3453 |
* 03 Unsigned multiplication, source1 * source2 (both unsigned) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3454 |
* 04 Signed multiplication, source1 * source2 (both signed) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3455 |
* 05 Unsigned bit shift, source1 by source2 (source2 taken to be a |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3456 |
* signed quantity; left shift if positive and right shift if |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3457 |
* negative, source1 is unsigned) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3458 |
* 06 Signed bit shift, source1 by source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3459 |
* (source2 like in 05, and source1 as well) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3460 |
*/ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3461 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
3462 |
if (!check_length(len, 5, "ParamSet")) return; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3463 |
buf++; |
6281 | 3464 |
uint8 target = grf_load_byte(&buf); |
3465 |
uint8 oper = grf_load_byte(&buf); |
|
3466 |
uint32 src1 = grf_load_byte(&buf); |
|
3467 |
uint32 src2 = grf_load_byte(&buf); |
|
3468 |
||
3469 |
uint32 data = 0; |
|
2345 | 3470 |
if (len >= 8) data = grf_load_dword(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3471 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3472 |
/* You can add 80 to the operation to make it apply only if the target |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3473 |
* is not defined yet. In this respect, a parameter is taken to be |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3474 |
* defined if any of the following applies: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3475 |
* - it has been set to any value in the newgrf(w).cfg parameter list |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3476 |
* - it OR A PARAMETER WITH HIGHER NUMBER has been set to any value by |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3477 |
* an earlier action D */ |
6281 | 3478 |
if (HASBIT(oper, 7)) { |
3807
736ea84b3cf4
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
3479 |
if (target < 0x80 && target < _cur_grffile->param_end) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3480 |
grfmsg(7, "ParamSet: Param %u already defined, skipping", target); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3481 |
return; |
3807
736ea84b3cf4
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
3482 |
} |
736ea84b3cf4
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
3483 |
|
6281 | 3484 |
oper = GB(oper, 0, 7); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3485 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3486 |
|
3808
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3487 |
if (src2 == 0xFE) { |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3488 |
if (GB(data, 0, 8) == 0xFF) { |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3489 |
if (data == 0x0000FFFF) { |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3490 |
/* Patch variables */ |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3491 |
grfmsg(2, "ParamSet: Reading Patch variables unsupported"); |
3808
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3492 |
return; |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3493 |
} else { |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3494 |
/* GRF Resource Management */ |
5225
af5d9de16c8d
(svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents:
5211
diff
changeset
|
3495 |
if (_cur_stage != GLS_ACTIVATION) { |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3496 |
/* Ignore GRM during initialization */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3497 |
src1 = 0; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3498 |
} else { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3499 |
uint8 op = src1; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3500 |
uint8 feature = GB(data, 8, 8); |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3501 |
uint16 count = GB(data, 16, 16); |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3502 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3503 |
switch (feature) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3504 |
case 0x00: // Trains |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3505 |
case 0x01: // Road Vehicles |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3506 |
case 0x02: // Ships |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3507 |
case 0x03: // Aircraft |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3508 |
{ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3509 |
uint start = 0; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3510 |
uint size = 0; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3511 |
uint shift = _vehshifts[feature]; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3512 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3513 |
if (op == 6) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3514 |
/* Return GRFID of set that reserved ID */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3515 |
src1 = _grm_engines[shift + _cur_grffile->param[target]]; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3516 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3517 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3518 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3519 |
/* With an operation of 2 or 3, we want to reserve a specific block of IDs */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3520 |
if (op == 2 || op == 3) start = _cur_grffile->param[target]; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3521 |
|
6281 | 3522 |
for (uint i = start; i < _vehcounts[feature]; i++) { |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3523 |
if (_grm_engines[shift + i] == 0) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3524 |
size++; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3525 |
} else { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3526 |
if (op == 2 || op == 3) break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3527 |
start = i + 1; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3528 |
size = 0; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3529 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3530 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3531 |
if (size == count) break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3532 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3533 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3534 |
if (size == count) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3535 |
/* Got the slot... */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3536 |
if (op == 0 || op == 3) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3537 |
grfmsg(2, "ParamSet: GRM: Reserving %d vehicles at %d", count, start); |
6281 | 3538 |
for (uint i = 0; i < count; i++) _grm_engines[shift + start + i] = _cur_grffile->grfid; |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3539 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3540 |
src1 = start; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3541 |
} else { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3542 |
/* Unable to allocate */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3543 |
if (op != 4 && op != 5) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3544 |
/* Deactivate GRF */ |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3545 |
grfmsg(0, "ParamSet: GRM: Unable to allocate %d vehicles, deactivating", count); |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3546 |
_cur_grfconfig->status = GCS_DISABLED; |
5011
0b0003ba213e
(svn r7031) -Codechange: Use _skip_sprites to skip the rest of the NewGRF when disabled by GRM, and add a shortcut so that the rest of the file isn't scanned.
peter1138
parents:
5008
diff
changeset
|
3547 |
|
0b0003ba213e
(svn r7031) -Codechange: Use _skip_sprites to skip the rest of the NewGRF when disabled by GRM, and add a shortcut so that the rest of the file isn't scanned.
peter1138
parents:
5008
diff
changeset
|
3548 |
_skip_sprites = -1; |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3549 |
return; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3550 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3551 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3552 |
grfmsg(1, "ParamSet: GRM: Unable to allocate %d vehicles", count); |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
3553 |
src1 = UINT_MAX; |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3554 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3555 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3556 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3557 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3558 |
case 0x08: // General sprites |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3559 |
switch (op) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3560 |
case 0: |
5889
461a9fbf58da
(svn r8505) -Codechange: Ensure GRM allocated sprites will be below the original 16384 sprite limit. If not, fail and disable the NewGRF.
peter1138
parents:
5875
diff
changeset
|
3561 |
/* Check if the allocated sprites will fit below the original sprite limit */ |
461a9fbf58da
(svn r8505) -Codechange: Ensure GRM allocated sprites will be below the original 16384 sprite limit. If not, fail and disable the NewGRF.
peter1138
parents:
5875
diff
changeset
|
3562 |
if (_cur_spriteid + count >= 16384) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3563 |
grfmsg(0, "ParamSet: GRM: Unable to allocate %d sprites; try changing NewGRF order", count); |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3564 |
_cur_grfconfig->status = GCS_DISABLED; |
5889
461a9fbf58da
(svn r8505) -Codechange: Ensure GRM allocated sprites will be below the original 16384 sprite limit. If not, fail and disable the NewGRF.
peter1138
parents:
5875
diff
changeset
|
3565 |
|
461a9fbf58da
(svn r8505) -Codechange: Ensure GRM allocated sprites will be below the original 16384 sprite limit. If not, fail and disable the NewGRF.
peter1138
parents:
5875
diff
changeset
|
3566 |
_skip_sprites = -1; |
461a9fbf58da
(svn r8505) -Codechange: Ensure GRM allocated sprites will be below the original 16384 sprite limit. If not, fail and disable the NewGRF.
peter1138
parents:
5875
diff
changeset
|
3567 |
return; |
461a9fbf58da
(svn r8505) -Codechange: Ensure GRM allocated sprites will be below the original 16384 sprite limit. If not, fail and disable the NewGRF.
peter1138
parents:
5875
diff
changeset
|
3568 |
} |
461a9fbf58da
(svn r8505) -Codechange: Ensure GRM allocated sprites will be below the original 16384 sprite limit. If not, fail and disable the NewGRF.
peter1138
parents:
5875
diff
changeset
|
3569 |
|
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3570 |
/* 'Reserve' space at the current sprite ID */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3571 |
src1 = _cur_spriteid; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3572 |
_cur_spriteid += count; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3573 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3574 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3575 |
case 1: |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3576 |
src1 = _cur_spriteid; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3577 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3578 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3579 |
default: |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3580 |
grfmsg(1, "ParamSet: GRM: Unsupported operation %d for general sprites", op); |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3581 |
return; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3582 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3583 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3584 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3585 |
default: grfmsg(1, "ParamSet: GRM: Unsupported feature 0x%X", feature); return; |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3586 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3587 |
} |
3808
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3588 |
} |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3589 |
} else { |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3590 |
/* Read another GRF File's parameter */ |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3591 |
const GRFFile *file = GetFileByGRFID(data); |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3592 |
if (file == NULL || src1 >= file->param_end) { |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3593 |
src1 = 0; |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3594 |
} else { |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3595 |
src1 = file->param[src1]; |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3596 |
} |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3597 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3598 |
} else { |
3808
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3599 |
/* The source1 and source2 operands refer to the grf parameter number |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3600 |
* like in action 6 and 7. In addition, they can refer to the special |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3601 |
* variables available in action 7, or they can be FF to use the value |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3602 |
* of <data>. If referring to parameters that are undefined, a value |
dadaaa757e8f
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
3603 |
* of 0 is used instead. */ |
3811
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3604 |
src1 = (src1 == 0xFF) ? data : GetParamVal(src1, NULL); |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3605 |
src2 = (src2 == 0xFF) ? data : GetParamVal(src2, NULL); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3606 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3607 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3608 |
/* TODO: You can access the parameters of another GRF file by using |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3609 |
* source2=FE, source1=the other GRF's parameter number and data=GRF |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3610 |
* ID. This is only valid with operation 00 (set). If the GRF ID |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3611 |
* cannot be found, a value of 0 is used for the parameter value |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3612 |
* instead. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3613 |
|
6281 | 3614 |
uint32 res; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3615 |
switch (oper) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3616 |
case 0x00: |
2345 | 3617 |
res = src1; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3618 |
break; |
2345 | 3619 |
|
3620 |
case 0x01: |
|
3621 |
res = src1 + src2; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3622 |
break; |
2345 | 3623 |
|
3624 |
case 0x02: |
|
3625 |
res = src1 - src2; |
|
3626 |
break; |
|
3627 |
||
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3628 |
case 0x03: |
2345 | 3629 |
res = src1 * src2; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3630 |
break; |
2345 | 3631 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3632 |
case 0x04: |
2345 | 3633 |
res = (int32)src1 * (int32)src2; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3634 |
break; |
2345 | 3635 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3636 |
case 0x05: |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
3637 |
if ((int32)src2 < 0) { |
2345 | 3638 |
res = src1 >> -(int32)src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
3639 |
} else { |
2345 | 3640 |
res = src1 << src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
3641 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3642 |
break; |
2345 | 3643 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3644 |
case 0x06: |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
3645 |
if ((int32)src2 < 0) { |
2345 | 3646 |
res = (int32)src1 >> -(int32)src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
3647 |
} else { |
2345 | 3648 |
res = (int32)src1 << src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
3649 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3650 |
break; |
2345 | 3651 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3652 |
case 0x07: // Bitwise AND |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3653 |
res = src1 & src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3654 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3655 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3656 |
case 0x08: // Bitwise OR |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3657 |
res = src1 | src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3658 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3659 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3660 |
case 0x09: // Unsigned division |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3661 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3662 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3663 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3664 |
res = src1 / src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3665 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3666 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3667 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3668 |
case 0x0A: // Signed divison |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3669 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3670 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3671 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3672 |
res = (int32)src1 / (int32)src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3673 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3674 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3675 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3676 |
case 0x0B: // Unsigned modulo |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3677 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3678 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3679 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3680 |
res = src1 % src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3681 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3682 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3683 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3684 |
case 0x0C: // Signed modulo |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3685 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3686 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3687 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3688 |
res = (int32)src1 % (int32)src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3689 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3690 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
3691 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3692 |
default: grfmsg(0, "ParamSet: Unknown operation %d, skipping", oper); return; |
2345 | 3693 |
} |
3694 |
||
3695 |
switch (target) { |
|
3696 |
case 0x8E: // Y-Offset for train sprites |
|
3697 |
_traininfo_vehicle_pitch = res; |
|
3698 |
break; |
|
3699 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3700 |
/* @todo implement */ |
2345 | 3701 |
case 0x8F: // Rail track type cost factors |
3702 |
case 0x93: // Tile refresh offset to left |
|
3703 |
case 0x94: // Tile refresh offset to right |
|
3704 |
case 0x95: // Tile refresh offset upwards |
|
3705 |
case 0x96: // Tile refresh offset downwards |
|
3706 |
case 0x97: // Snow line height |
|
3707 |
case 0x99: // Global ID offset |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3708 |
grfmsg(7, "ParamSet: Skipping unimplemented target 0x%02X", target); |
2345 | 3709 |
break; |
3710 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3711 |
case 0x9E: // Miscellaneous GRF features |
3814
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
3712 |
_misc_grf_features = res; |
3845
af6eb0103fed
(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:
3825
diff
changeset
|
3713 |
/* Set train list engine width */ |
af6eb0103fed
(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:
3825
diff
changeset
|
3714 |
_traininfo_vehicle_width = HASBIT(res, 3) ? 32 : 29; |
3814
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
3715 |
break; |
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
3716 |
|
2345 | 3717 |
default: |
3718 |
if (target < 0x80) { |
|
3719 |
_cur_grffile->param[target] = res; |
|
3720 |
if (target + 1U > _cur_grffile->param_end) _cur_grffile->param_end = target + 1; |
|
3721 |
} else { |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3722 |
grfmsg(7, "ParamSet: Skipping unknown target 0x%02X", target); |
2345 | 3723 |
} |
3724 |
break; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3725 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3726 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3727 |
|
5502
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3728 |
/* Action 0x0E (GLS_SAFETYSCAN) */ |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3729 |
static void SafeGRFInhibit(byte *buf, int len) |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3730 |
{ |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3731 |
/* <0E> <num> <grfids...> |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3732 |
* |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3733 |
* B num Number of GRFIDs that follow |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3734 |
* D grfids GRFIDs of the files to deactivate */ |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3735 |
|
6281 | 3736 |
if (!check_length(len, 2, "GRFInhibit")) return; |
3737 |
buf++; |
|
3738 |
uint8 num = grf_load_byte(&buf); |
|
3739 |
if (!check_length(len, 2 + 4 * num, "GRFInhibit")) return; |
|
3740 |
||
3741 |
for (uint i = 0; i < num; i++) { |
|
5502
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3742 |
uint32 grfid = grf_load_dword(&buf); |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3743 |
|
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3744 |
/* GRF is unsafe it if tries to deactivate other GRFs */ |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3745 |
if (grfid != _cur_grfconfig->grfid) { |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3746 |
SETBIT(_cur_grfconfig->flags, GCF_UNSAFE); |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3747 |
|
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3748 |
/* Skip remainder of GRF */ |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3749 |
_skip_sprites = -1; |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3750 |
|
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3751 |
return; |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3752 |
} |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3753 |
} |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3754 |
} |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
3755 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
3756 |
/* Action 0x0E */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3757 |
static void GRFInhibit(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3758 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3759 |
/* <0E> <num> <grfids...> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3760 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3761 |
* B num Number of GRFIDs that follow |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3762 |
* D grfids GRFIDs of the files to deactivate */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3763 |
|
6281 | 3764 |
if (!check_length(len, 2, "GRFInhibit")) return; |
3765 |
buf++; |
|
3766 |
uint8 num = grf_load_byte(&buf); |
|
3767 |
if (!check_length(len, 2 + 4 * num, "GRFInhibit")) return; |
|
3768 |
||
3769 |
for (uint i = 0; i < num; i++) { |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3770 |
uint32 grfid = grf_load_dword(&buf); |
5333
dedf1f6de6d3
(svn r7495) -Fix (r7354): [NewGRF] Deactivate the target GRF, not the current GRF.
peter1138
parents:
5329
diff
changeset
|
3771 |
GRFConfig *file = GetGRFConfig(grfid); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3772 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3773 |
/* Unset activation flag */ |
5369
6420e8dd829c
(svn r7554) -Fix (r7496): In Action 0xE, don't deactivate the current GRF (to be ported to 0.5)
peter1138
parents:
5340
diff
changeset
|
3774 |
if (file != NULL && file != _cur_grfconfig) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3775 |
grfmsg(2, "GRFInhibit: Deactivating file '%s'", file->filename); |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3776 |
file->status = GCS_DISABLED; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3777 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3778 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3779 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3780 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
3781 |
/* Action 0x10 */ |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3782 |
static void DefineGotoLabel(byte *buf, int len) |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3783 |
{ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3784 |
/* <10> <label> [<comment>] |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3785 |
* |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3786 |
* B label The label to define |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3787 |
* V comment Optional comment - ignored */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3788 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
3789 |
if (!check_length(len, 1, "DefineGotoLabel")) return; |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3790 |
buf++; len--; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3791 |
|
6281 | 3792 |
GRFLabel *label = MallocT<GRFLabel>(1); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3793 |
label->label = grf_load_byte(&buf); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3794 |
label->nfo_line = _nfo_line; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3795 |
label->pos = FioGetPos(); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3796 |
label->next = NULL; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3797 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3798 |
/* Set up a linked list of goto targets which we will search in an Action 0x7/0x9 */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3799 |
if (_cur_grffile->label == NULL) { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3800 |
_cur_grffile->label = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3801 |
} else { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3802 |
/* Attach the label to the end of the list */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3803 |
GRFLabel *l; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3804 |
for (l = _cur_grffile->label; l->next != NULL; l = l->next); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3805 |
l->next = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3806 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3807 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3808 |
grfmsg(2, "DefineGotoLabel: GOTO target with label 0x%02X", label->label); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
3809 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3810 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3811 |
/* Action 0x11 */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3812 |
static void GRFSound(byte *buf, int len) |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3813 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3814 |
/* <11> <num> |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3815 |
* |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3816 |
* W num Number of sound files that follow */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3817 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
3818 |
if (!check_length(len, 1, "GRFSound")) return; |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3819 |
buf++; |
6281 | 3820 |
uint16 num = grf_load_word(&buf); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3821 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3822 |
_grf_data_blocks = num; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3823 |
_grf_data_type = GDT_SOUND; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3824 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3825 |
if (_cur_grffile->sound_offset == 0) _cur_grffile->sound_offset = GetNumSounds(); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3826 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3827 |
|
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3828 |
static void ImportGRFSound(byte *buf, int len) |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3829 |
{ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3830 |
const GRFFile *file; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3831 |
FileEntry *se = AllocateFileEntry(); |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3832 |
uint32 grfid = grf_load_dword(&buf); |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3833 |
uint16 sound = grf_load_word(&buf); |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3834 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3835 |
file = GetFileByGRFID(grfid); |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3836 |
if (file == NULL || file->sound_offset == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3837 |
grfmsg(1, "ImportGRFSound: Source file not available"); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3838 |
return; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3839 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3840 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3841 |
if (file->sound_offset + sound >= GetNumSounds()) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3842 |
grfmsg(1, "ImportGRFSound: Sound effect %d is invalid", sound); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3843 |
return; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3844 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3845 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3846 |
grfmsg(2, "ImportGRFSound: Copying sound %d (%d) from file %X", sound, file->sound_offset + sound, grfid); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3847 |
|
5024
5e98bf731469
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5011
diff
changeset
|
3848 |
*se = *GetSound(file->sound_offset + sound); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3849 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3850 |
/* Reset volume and priority, which TTDPatch doesn't copy */ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3851 |
se->volume = 128; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3852 |
se->priority = 0; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3853 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3854 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3855 |
/* 'Action 0xFE' */ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3856 |
static void GRFImportBlock(byte *buf, int len) |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3857 |
{ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3858 |
if (_grf_data_blocks == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3859 |
grfmsg(2, "GRFImportBlock: Unexpected import block, skipping"); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3860 |
return; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3861 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3862 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3863 |
buf++; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3864 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3865 |
_grf_data_blocks--; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3866 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3867 |
/* XXX 'Action 0xFE' isn't really specified. It is only mentioned for |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3868 |
* importing sounds, so this is probably all wrong... */ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3869 |
if (grf_load_byte(&buf) != _grf_data_type) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3870 |
grfmsg(1, "GRFImportBlock: Import type mismatch"); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3871 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3872 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3873 |
switch (_grf_data_type) { |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3874 |
case GDT_SOUND: ImportGRFSound(buf, len - 1); break; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3875 |
default: NOT_REACHED(); break; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3876 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3877 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3878 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3879 |
static void LoadGRFSound(byte *buf, int len) |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3880 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3881 |
byte *buf_start = buf; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3882 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3883 |
/* Allocate a sound entry. This is done even if the data is not loaded |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3884 |
* so that the indices used elsewhere are still correct. */ |
6281 | 3885 |
FileEntry *se = AllocateFileEntry(); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3886 |
|
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
3887 |
if (grf_load_dword(&buf) != BSWAP32('RIFF')) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3888 |
grfmsg(1, "LoadGRFSound: Missing RIFF header"); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3889 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3890 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3891 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3892 |
/* Size of file -- we ignore this */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3893 |
grf_load_dword(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3894 |
|
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
3895 |
if (grf_load_dword(&buf) != BSWAP32('WAVE')) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3896 |
grfmsg(1, "LoadGRFSound: Invalid RIFF type"); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3897 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3898 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3899 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3900 |
for (;;) { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3901 |
uint32 tag = grf_load_dword(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3902 |
uint32 size = grf_load_dword(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3903 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3904 |
switch (tag) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3905 |
case ' tmf': // 'fmt ' |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3906 |
/* Audio format, must be 1 (PCM) */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3907 |
if (grf_load_word(&buf) != 1) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3908 |
grfmsg(1, "LoadGRFSound: Invalid audio format"); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3909 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3910 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3911 |
se->channels = grf_load_word(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3912 |
se->rate = grf_load_dword(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3913 |
grf_load_dword(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3914 |
grf_load_word(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3915 |
se->bits_per_sample = grf_load_word(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3916 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3917 |
/* Consume any extra bytes */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3918 |
for (; size > 16; size--) grf_load_byte(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3919 |
break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3920 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3921 |
case 'atad': // 'data' |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3922 |
se->file_size = size; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3923 |
se->file_offset = FioGetPos() - (len - (buf - buf_start)) + 1; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3924 |
se->file_offset |= _file_index << 24; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3925 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3926 |
/* Set default volume and priority */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3927 |
se->volume = 0x80; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3928 |
se->priority = 0; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3929 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3930 |
grfmsg(2, "LoadGRFSound: channels %u, sample rate %u, bits per sample %u, length %u", se->channels, se->rate, se->bits_per_sample, size); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3931 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3932 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3933 |
default: |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3934 |
se->file_size = 0; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3935 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3936 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3937 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3938 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3939 |
|
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3940 |
/* Action 0x12 */ |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3941 |
static void LoadFontGlyph(byte *buf, int len) |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3942 |
{ |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3943 |
/* <12> <num_def> <font_size> <num_char> <base_char> |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3944 |
* |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3945 |
* B num_def Number of definitions |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3946 |
* B font_size Size of font (0 = normal, 1 = small, 2 = large) |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3947 |
* B num_char Number of consecutive glyphs |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3948 |
* W base_char First character index */ |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3949 |
|
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3950 |
buf++; len--; |
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
3951 |
if (!check_length(len, 1, "LoadFontGlyph")) return; |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3952 |
|
6281 | 3953 |
uint8 num_def = grf_load_byte(&buf); |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3954 |
|
5590
6a0c2739e124
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5587
diff
changeset
|
3955 |
if (!check_length(len, 1 + num_def * 4, "LoadFontGlyph")) return; |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3956 |
|
6281 | 3957 |
for (uint i = 0; i < num_def; i++) { |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
3958 |
FontSize size = (FontSize)grf_load_byte(&buf); |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3959 |
uint8 num_char = grf_load_byte(&buf); |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3960 |
uint16 base_char = grf_load_word(&buf); |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3961 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3962 |
grfmsg(7, "LoadFontGlyph: Loading %u glyph(s) at 0x%04X for size %u", num_char, base_char, size); |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3963 |
|
6281 | 3964 |
for (uint c = 0; c < num_char; c++) { |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3965 |
SetUnicodeGlyph(size, base_char + c, _cur_spriteid); |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3966 |
LoadNextSprite(_cur_spriteid++, _file_index); |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3967 |
_nfo_line++; |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3968 |
} |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3969 |
} |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3970 |
} |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
3971 |
|
6234
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3972 |
/* Action 0x13 */ |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3973 |
static void TranslateGRFStrings(byte *buf, int len) |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3974 |
{ |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3975 |
/* <13> <grfid> <num-ent> <offset> <text...> |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3976 |
* |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3977 |
* 4*B grfid The GRFID of the file whose texts are to be translated |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3978 |
* B num-ent Number of strings |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3979 |
* W offset First text ID |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3980 |
* S text... Zero-terminated strings */ |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3981 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3982 |
buf++; len--; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3983 |
if (!check_length(len, 7, "TranslateGRFString")) return; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3984 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3985 |
uint32 grfid = grf_load_dword(&buf); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3986 |
const GRFConfig *c = GetGRFConfig(grfid); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3987 |
if (c == NULL || (c->status != GCS_INITIALISED && c->status != GCS_ACTIVATED)) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3988 |
grfmsg(7, "TranslateGRFStrings: GRFID 0x%08x unknown, skipping action 13", BSWAP32(grfid)); |
6234
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3989 |
return; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3990 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3991 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3992 |
if (c->status == GCS_INITIALISED) { |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3993 |
/* If the file is not active but will be activated later, give an error |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3994 |
* and disable this file. */ |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3995 |
GRFError *error = CallocT<GRFError>(1); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3996 |
error->message = STR_NEWGRF_ERROR_LOAD_AFTER; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3997 |
error->data = STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3998 |
error->severity = STR_NEWGRF_ERROR_MSG_FATAL; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
3999 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4000 |
if (_cur_grfconfig->error != NULL) free(_cur_grfconfig->error); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4001 |
_cur_grfconfig->error = error; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4002 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4003 |
_cur_grfconfig->status = GCS_DISABLED; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4004 |
_skip_sprites = -1; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4005 |
return; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4006 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4007 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4008 |
byte num_strings = grf_load_byte(&buf); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4009 |
uint16 first_id = grf_load_word(&buf); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4010 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4011 |
if (!((first_id >= 0xD000 && first_id + num_strings <= 0xD3FF) || (first_id >= 0xDC00 && first_id + num_strings <= 0xDCFF))) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4012 |
grfmsg(7, "TranslateGRFStrings: Attempting to set out-of-range string IDs in action 13 (first: 0x%4X, number: 0x%2X)", first_id, num_strings); |
6234
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4013 |
return; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4014 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4015 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4016 |
len -= 7; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4017 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4018 |
for (uint i = 0; i < num_strings && len > 0; i++) { |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4019 |
const char *string = grf_load_string(&buf, len); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4020 |
size_t string_length = strlen(string) + 1; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4021 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4022 |
len -= (int)string_length; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4023 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4024 |
if (string_length == 1) { |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4025 |
grfmsg(7, "TranslateGRFString: Ignoring empty string."); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4026 |
continue; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4027 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4028 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4029 |
/* Since no language id is supplied this string has to be added as a |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4030 |
* generic string, thus the language id of 0x7F. For this to work |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4031 |
* new_scheme has to be true as well. A language id of 0x7F will be |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4032 |
* overridden by a non-generic id, so this will not change anything if |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4033 |
* a string has been provided specifically for this language. */ |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4034 |
AddGRFString(grfid, first_id + i, 0x7F, true, string, STR_UNDEFINED); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4035 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4036 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
4037 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4038 |
/* 'Action 0xFF' */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4039 |
static void GRFDataBlock(byte *buf, int len) |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4040 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4041 |
if (_grf_data_blocks == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4042 |
grfmsg(2, "GRFDataBlock: unexpected data block, skipping"); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4043 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4044 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4045 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4046 |
buf++; |
6281 | 4047 |
uint8 name_len = grf_load_byte(&buf); |
4048 |
const char *name = (const char *)buf; |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4049 |
buf += name_len + 1; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4050 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4051 |
grfmsg(2, "GRFDataBlock: block name '%s'...", name); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4052 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4053 |
_grf_data_blocks--; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4054 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4055 |
switch (_grf_data_type) { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4056 |
case GDT_SOUND: LoadGRFSound(buf, len - name_len - 2); break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4057 |
default: NOT_REACHED(); break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4058 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4059 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4060 |
|
5329
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
4061 |
|
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
4062 |
/* Used during safety scan on unsafe actions */ |
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
4063 |
static void GRFUnsafe(byte *buf, int len) |
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
4064 |
{ |
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
4065 |
SETBIT(_cur_grfconfig->flags, GCF_UNSAFE); |
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
4066 |
|
5502
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
4067 |
/* Skip remainder of GRF */ |
003b36599ff8
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5476
diff
changeset
|
4068 |
_skip_sprites = -1; |
5329
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
4069 |
} |
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
4070 |
|
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
4071 |
|
6247 | 4072 |
static void InitializeGRFSpecial() |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4073 |
{ |
4381
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4074 |
_ttdpatch_flags[0] = ((_patches.always_small_airport ? 1 : 0) << 0x0C) // keepsmallairport |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4075 |
| (1 << 0x0D) // newairports |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4076 |
| (1 << 0x0E) // largestations |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4077 |
| ((_patches.longbridges ? 1 : 0) << 0x0F) // longbridges |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4078 |
| (0 << 0x10) // loadtime |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4079 |
| (1 << 0x12) // presignals |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4080 |
| (1 << 0x13) // extpresignals |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4081 |
| ((_patches.never_expire_vehicles ? 1 : 0) << 0x16) // enginespersist |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4082 |
| (1 << 0x1B) // multihead |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4083 |
| (1 << 0x1D) // lowmemory |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4084 |
| (1 << 0x1E); // generalfixes |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4085 |
|
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4086 |
_ttdpatch_flags[1] = (0 << 0x07) // moreairports - based on units of noise |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4087 |
| ((_patches.mammoth_trains ? 1 : 0) << 0x08) // mammothtrains |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4088 |
| (1 << 0x09) // trainrefit |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4089 |
| (0 << 0x0B) // subsidiaries |
5550
ffed4fb7555d
(svn r7930) -Fix: [FS#520] Wrong GRF flag set for gradual loading (mart3p)
Darkvater
parents:
5525
diff
changeset
|
4090 |
| ((_patches.gradual_loading ? 1 : 0) << 0x0C) // gradualloading |
4381
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4091 |
| (1 << 0x12) // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4092 |
| (1 << 0x13) // unifiedmaglevmode - set bit 1 mode |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4093 |
| (1 << 0x14) // bridgespeedlimits |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4094 |
| (1 << 0x16) // eternalgame |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4095 |
| (1 << 0x17) // newtrains |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4096 |
| (1 << 0x18) // newrvs |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4097 |
| (1 << 0x19) // newships |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4098 |
| (1 << 0x1A) // newplanes |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4099 |
| ((_patches.signal_side ? 1 : 0) << 0x1B) // signalsontrafficside |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4100 |
| (1 << 0x1C); // electrifiedrailway |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4101 |
|
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4102 |
_ttdpatch_flags[2] = (1 << 0x01) // loadallgraphics - obsolote |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4103 |
| (1 << 0x03) // semaphores |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4104 |
| (0 << 0x0B) // enhancedgui |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4105 |
| (0 << 0x0C) // newagerating |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4106 |
| ((_patches.build_on_slopes ? 1 : 0) << 0x0D) // buildonslopes |
6507
ab8107a6c110
(svn r9690) -Codechange: Update another couple of NewGRF TTDPatch flags
peter1138
parents:
6503
diff
changeset
|
4107 |
| ((_patches.full_load_any ? 1 : 0) << 0x0E) // fullloadany |
4381
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4108 |
| (0 << 0x0F) // planespeed |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4109 |
| (0 << 0x10) // moreindustriesperclimate - obsolete |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4110 |
| (0 << 0x11) // moretoylandfeatures |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4111 |
| (1 << 0x12) // newstations |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4112 |
| (0 << 0x13) // tracktypecostdiff |
6503
892c9b941008
(svn r9686) -Codechange: Update a couple of NewGRF TTDPatch flags
peter1138
parents:
6492
diff
changeset
|
4113 |
| (1 << 0x14) // manualconvert |
4381
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4114 |
| ((_patches.build_on_slopes ? 1 : 0) << 0x15) // buildoncoasts |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4115 |
| (1 << 0x16) // canals |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4116 |
| (1 << 0x17) // newstartyear |
6503
892c9b941008
(svn r9686) -Codechange: Update a couple of NewGRF TTDPatch flags
peter1138
parents:
6492
diff
changeset
|
4117 |
| ((_patches.freight_trains > 1 ? 1 : 0) << 0x18) // freighttrains |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4118 |
| (1 << 0x19) // newhouses |
4381
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4119 |
| (1 << 0x1A) // newbridges |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4120 |
| (0 << 0x1B) // newtownnames |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4121 |
| (0 << 0x1C) // moreanimations |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4122 |
| ((_patches.wagon_speed_limits ? 1 : 0) << 0x1D) // wagonspeedlimits |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4123 |
| (1 << 0x1E) // newshistory |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4124 |
| (0 << 0x1F); // custombridgeheads |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4125 |
|
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4126 |
_ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4127 |
| (1 << 0x01) // windowsnap |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4128 |
| (0 << 0x02) // townbuildnoroad |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4129 |
| (0 << 0x03) // pathbasedsignalling. To enable if ever pbs is back |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4130 |
| (0 << 0x04) // aichoosechance |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4131 |
| (1 << 0x05) // resolutionwidth |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4132 |
| (1 << 0x06) // resolutionheight |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4133 |
| (0 << 0x07) // newindustries |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4134 |
| (0 << 0x08) // fifoloading |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4135 |
| (0 << 0x09) // townroadbranchprob |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4136 |
| (0 << 0x0A) // tempsnowline |
6463
e986fe39dfe7
(svn r9638) -Feature: Increase cargo types from 12 to 32 and enable newcargo flag in NewGRF loader.
peter1138
parents:
6461
diff
changeset
|
4137 |
| (1 << 0x0B) // newcargo |
4381
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4138 |
| (1 << 0x0C) // enhancemultiplayer |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4139 |
| (1 << 0x0D) // onewayroads |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4140 |
| ((_patches.nonuniform_stations ? 1 : 0) << 0x0E) // irregularstations |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4141 |
| (1 << 0x0F) // statistics |
4657
dfbc1d1e6fd0
(svn r6533) - Fix (r6532): Somebody forgot to add newsounds to the ttdpatch flags...
peter1138
parents:
4656
diff
changeset
|
4142 |
| (1 << 0x10) // newsounds |
4381
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4143 |
| (1 << 0x11) // autoreplace |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4144 |
| (1 << 0x12) // autoslope |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4145 |
| (0 << 0x13) // followvehicle |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4146 |
| (0 << 0x14) // trams |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4147 |
| (0 << 0x15) // enhancetunnels |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
4148 |
| (0 << 0x16) // shortrvs |
6507
ab8107a6c110
(svn r9690) -Codechange: Update another couple of NewGRF TTDPatch flags
peter1138
parents:
6503
diff
changeset
|
4149 |
| (0 << 0x17) // articulatedrvs |
ab8107a6c110
(svn r9690) -Codechange: Update another couple of NewGRF TTDPatch flags
peter1138
parents:
6503
diff
changeset
|
4150 |
| (1 << 0x1E); // variablerunningcosts |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4151 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4152 |
|
6247 | 4153 |
static void ResetCustomStations() |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
4154 |
{ |
6281 | 4155 |
for (GRFFile *file = _first_grffile; file != NULL; file = file->next) { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
4156 |
if (file->stations == NULL) continue; |
6281 | 4157 |
for (uint i = 0; i < MAX_STATIONS; i++) { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
4158 |
if (file->stations[i] == NULL) continue; |
6281 | 4159 |
StationSpec *statspec = file->stations[i]; |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
4160 |
|
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
4161 |
/* Release renderdata, if it wasn't copied from another custom station spec */ |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
4162 |
if (!statspec->copied_renderdata) { |
6281 | 4163 |
for (uint t = 0; t < statspec->tiles; t++) { |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
4164 |
free((void*)statspec->renderdata[t].seq); |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
4165 |
} |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
4166 |
free(statspec->renderdata); |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
4167 |
} |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
4168 |
|
5061
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
4169 |
/* Release platforms and layouts */ |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
4170 |
if (!statspec->copied_layouts) { |
6281 | 4171 |
for (uint l = 0; l < statspec->lengths; l++) { |
4172 |
for (uint p = 0; p < statspec->platforms[l]; p++) { |
|
5061
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
4173 |
free(statspec->layouts[l][p]); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
4174 |
} |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
4175 |
free(statspec->layouts[l]); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
4176 |
} |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
4177 |
free(statspec->layouts); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
4178 |
free(statspec->platforms); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
4179 |
} |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
4180 |
|
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
4181 |
/* Release this station */ |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
4182 |
free(statspec); |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
4183 |
} |
3501
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
4184 |
|
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
4185 |
/* Free and reset the station data */ |
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
4186 |
free(file->stations); |
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
4187 |
file->stations = NULL; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
4188 |
} |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
4189 |
} |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
4190 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4191 |
static void ResetCustomHouses() |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4192 |
{ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4193 |
GRFFile *file; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4194 |
uint i; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4195 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4196 |
for (file = _first_grffile; file != NULL; file = file->next) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4197 |
if (file->housespec == NULL) continue; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4198 |
for (i = 0; i < HOUSE_MAX; i++) free(file->housespec[i]); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4199 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4200 |
free(file->housespec); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4201 |
file->housespec = NULL; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4202 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4203 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4204 |
|
6247 | 4205 |
static void ResetNewGRF() |
4953
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4206 |
{ |
6281 | 4207 |
GRFFile *next; |
4208 |
||
4209 |
for (GRFFile *f = _first_grffile; f != NULL; f = next) { |
|
4953
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4210 |
next = f->next; |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4211 |
|
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4212 |
free(f->filename); |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4213 |
free(f); |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4214 |
} |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4215 |
|
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4216 |
_first_grffile = NULL; |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4217 |
_cur_grffile = NULL; |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4218 |
} |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4219 |
|
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
4220 |
/** |
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4221 |
* Reset all NewGRF loaded data |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4222 |
* TODO |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4223 |
*/ |
6247 | 4224 |
static void ResetNewGRFData() |
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4225 |
{ |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
4226 |
CleanUpStrings(); |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
4227 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4228 |
/* Copy/reset original engine info data */ |
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4229 |
memcpy(&_engine_info, &orig_engine_info, sizeof(orig_engine_info)); |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4230 |
memcpy(&_rail_vehicle_info, &orig_rail_vehicle_info, sizeof(orig_rail_vehicle_info)); |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4231 |
memcpy(&_ship_vehicle_info, &orig_ship_vehicle_info, sizeof(orig_ship_vehicle_info)); |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4232 |
memcpy(&_aircraft_vehicle_info, &orig_aircraft_vehicle_info, sizeof(orig_aircraft_vehicle_info)); |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4233 |
memcpy(&_road_vehicle_info, &orig_road_vehicle_info, sizeof(orig_road_vehicle_info)); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
4234 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4235 |
/* Copy/reset original bridge info data |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4236 |
* First, free sprite table data */ |
6281 | 4237 |
for (uint i = 0; i < MAX_BRIDGES; i++) { |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
4238 |
if (_bridge[i].sprite_table != NULL) { |
6281 | 4239 |
for (uint j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
4240 |
free(_bridge[i].sprite_table); |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
4241 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
4242 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
4243 |
memcpy(&_bridge, &orig_bridge, sizeof(_bridge)); |
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
4244 |
|
6349
908a23fd464f
(svn r9387) -Fix (r9385): termination of a comment forgotten.
rubidium
parents:
6348
diff
changeset
|
4245 |
/* Reset refit/cargo class data */ |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4246 |
memset(&cargo_allowed, 0, sizeof(cargo_allowed)); |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4247 |
memset(&cargo_disallowed, 0, sizeof(cargo_disallowed)); |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4248 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4249 |
/* Reset GRM reservations */ |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4250 |
memset(&_grm_engines, 0, sizeof(_grm_engines)); |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4251 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4252 |
/* Unload sprite group data */ |
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
4253 |
UnloadWagonOverrides(); |
3695
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
4254 |
UnloadRotorOverrideSprites(); |
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
4255 |
UnloadCustomEngineSprites(); |
2769
eab49a86038e
(svn r3316) - NewGRF: Unload engine names before loading grf files. This fixes names in climates where the engines don't get loaded. Renamed function to reflect its purpose.
peter1138
parents:
2766
diff
changeset
|
4256 |
UnloadCustomEngineNames(); |
2971
cae3a81e8674
(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
|
4257 |
ResetEngineListOrder(); |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
4258 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4259 |
/* Reset price base data */ |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
4260 |
ResetPriceBaseMultipliers(); |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
4261 |
|
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
4262 |
/* Reset the curencies array */ |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
4263 |
ResetCurrencies(); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
4264 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4265 |
/* Reset the house array */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4266 |
ResetCustomHouses(); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4267 |
ResetHouses(); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4268 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4269 |
/* Reset station classes */ |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
4270 |
ResetStationClasses(); |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
4271 |
ResetCustomStations(); |
2812
95102021c840
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
4272 |
|
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
4273 |
/* Reset the snowline table. */ |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
4274 |
ClearSnowLine(); |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
4275 |
|
4953
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4276 |
/* Reset NewGRF files */ |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4277 |
ResetNewGRF(); |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
4278 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4279 |
/* Add engine type to engine data. This is needed for the refit precalculation. */ |
2812
95102021c840
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
4280 |
AddTypeToEngines(); |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
4281 |
|
6091
c8827d9ae04a
(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:
6090
diff
changeset
|
4282 |
/* Set up the default cargo types */ |
c8827d9ae04a
(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:
6090
diff
changeset
|
4283 |
SetupCargoForClimate(_opt.landscape); |
c8827d9ae04a
(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:
6090
diff
changeset
|
4284 |
|
3845
af6eb0103fed
(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:
3825
diff
changeset
|
4285 |
/* Reset misc GRF features and train list display variables */ |
af6eb0103fed
(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:
3825
diff
changeset
|
4286 |
_misc_grf_features = 0; |
af6eb0103fed
(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:
3825
diff
changeset
|
4287 |
_traininfo_vehicle_pitch = 0; |
af6eb0103fed
(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:
3825
diff
changeset
|
4288 |
_traininfo_vehicle_width = 29; |
4742
d915db693186
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
4289 |
_have_2cc = false; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4290 |
_have_newhouses = false; |
5209
1b7a72191019
(svn r7324) -Codechange: reset newgrf signal location data
peter1138
parents:
5161
diff
changeset
|
4291 |
_signal_base = 0; |
5210
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
4292 |
_coast_base = 0; |
3845
af6eb0103fed
(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:
3825
diff
changeset
|
4293 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4294 |
InitializeSoundPool(); |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
4295 |
InitializeSpriteGroupPool(); |
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4296 |
} |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4297 |
|
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4298 |
/** Reset all NewGRFData that was used only while processing data */ |
6247 | 4299 |
static void ClearTemporaryNewGRFData() |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4300 |
{ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4301 |
/* Clear the GOTO labels used for GRF processing */ |
6281 | 4302 |
for (GRFLabel *l = _cur_grffile->label; l != NULL;) { |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4303 |
GRFLabel *l2 = l->next; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4304 |
free(l); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4305 |
l = l2; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4306 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4307 |
_cur_grffile->label = NULL; |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
4308 |
|
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
4309 |
/* Clear the list of spritegroups */ |
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
4310 |
free(_cur_grffile->spritegroups); |
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
4311 |
_cur_grffile->spritegroups = NULL; |
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
4312 |
_cur_grffile->spritegroups_count = 0; |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4313 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4314 |
|
6147
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4315 |
static void BuildCargoTranslationMap() |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4316 |
{ |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4317 |
memset(_cur_grffile->cargo_map, 0xFF, sizeof(_cur_grffile->cargo_map)); |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4318 |
|
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4319 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4320 |
const CargoSpec *cs = GetCargo(c); |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4321 |
if (!cs->IsValid()) continue; |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4322 |
|
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4323 |
if (_cur_grffile->cargo_max == 0) { |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4324 |
/* Default translation table, so just a straight mapping to bitnum */ |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4325 |
_cur_grffile->cargo_map[c] = cs->bitnum; |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4326 |
} else { |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4327 |
/* Check the translation table for this cargo's label */ |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4328 |
for (uint i = 0; i < _cur_grffile->cargo_max; i++) { |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4329 |
if (cs->label == _cur_grffile->cargo_list[i]) { |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4330 |
_cur_grffile->cargo_map[c] = i; |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4331 |
break; |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4332 |
} |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4333 |
} |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4334 |
} |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4335 |
} |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4336 |
} |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4337 |
|
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
4338 |
static void InitNewGRFFile(const GRFConfig *config, int sprite_offset) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4339 |
{ |
6281 | 4340 |
GRFFile *newfile = GetFileByFilename(config->filename); |
490
03e2d2abeec7
(svn r772) Whoops, I know. Do not consider pointer to be a boolean value. Sorry 'bout that, sirs.
pasky
parents:
489
diff
changeset
|
4341 |
if (newfile != NULL) { |
489
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
4342 |
/* We already loaded it once. */ |
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
4343 |
newfile->sprite_offset = sprite_offset; |
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
4344 |
_cur_grffile = newfile; |
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
4345 |
return; |
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
4346 |
} |
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
4347 |
|
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
4348 |
newfile = CallocT<GRFFile>(1); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4349 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
4350 |
if (newfile == NULL) error ("Out of memory"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4351 |
|
6424
d410d4c31d15
(svn r9560) -Codechange: add support for multiple 'base' directories for newgrf searching.
rubidium
parents:
6376
diff
changeset
|
4352 |
newfile->filename = strdup(config->full_path); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4353 |
newfile->sprite_offset = sprite_offset; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4354 |
|
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
4355 |
/* Copy the initial parameter list */ |
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
4356 |
assert(lengthof(newfile->param) == lengthof(config->param) && lengthof(config->param) == 0x80); |
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
4357 |
newfile->param_end = config->num_params; |
5430
7864a926dd4d
(svn r7636) -Cleanup: Remove unused window classes (sorry WC-mess) and use sizeof(array) instead
Darkvater
parents:
5413
diff
changeset
|
4358 |
memcpy(newfile->param, config->param, sizeof(newfile->param)); |
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
4359 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4360 |
if (_first_grffile == NULL) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4361 |
_cur_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4362 |
_first_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4363 |
} else { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4364 |
_cur_grffile->next = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4365 |
_cur_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4366 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4367 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4368 |
|
5037
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
4369 |
|
6145
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4370 |
/** List of what cargo labels are refittable for the given the vehicle-type. |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4371 |
* Only currently active labels are applied. */ |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4372 |
static const CargoLabel _default_refitmasks_rail[] = { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4373 |
'PASS', 'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4374 |
'IORE', 'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4375 |
'WATR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4376 |
'PLST', 'FZDR', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4377 |
0 }; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4378 |
|
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4379 |
static const CargoLabel _default_refitmasks_road[] = { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4380 |
0 }; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4381 |
|
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4382 |
static const CargoLabel _default_refitmasks_ships[] = { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4383 |
'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', 'IORE', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4384 |
'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', 'WATR', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4385 |
'RUBR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4386 |
'PLST', 'FZDR', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4387 |
0 }; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4388 |
|
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4389 |
static const CargoLabel _default_refitmasks_aircraft[] = { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4390 |
'PASS', 'MAIL', 'GOOD', 'VALU', 'GOLD', 'DIAM', 'FOOD', 'FRUT', 'SUGR', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4391 |
'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', 'PLST', 'FZDR', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4392 |
0 }; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4393 |
|
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4394 |
static const CargoLabel *_default_refitmasks[] = { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4395 |
_default_refitmasks_rail, |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4396 |
_default_refitmasks_road, |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4397 |
_default_refitmasks_ships, |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4398 |
_default_refitmasks_aircraft, |
5037
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
4399 |
}; |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
4400 |
|
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
4401 |
|
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4402 |
/** |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4403 |
* Precalculate refit masks from cargo classes for all vehicles. |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4404 |
*/ |
6247 | 4405 |
static void CalculateRefitMasks() |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4406 |
{ |
6281 | 4407 |
for (EngineID engine = 0; engine < TOTAL_NUM_ENGINES; engine++) { |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4408 |
uint32 mask = 0; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4409 |
uint32 not_mask = 0; |
6284
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4410 |
uint32 xor_mask = 0; |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4411 |
|
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4412 |
if (_engine_info[engine].refit_mask != 0) { |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4413 |
const GRFFile *file = GetEngineGRF(engine); |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4414 |
if (file != NULL && file->cargo_max != 0) { |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4415 |
/* Apply cargo translation table to the refit mask */ |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4416 |
uint num_cargo = min(32, file->cargo_max); |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4417 |
for (uint i = 0; i < num_cargo; i++) { |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4418 |
if (!HASBIT(_engine_info[engine].refit_mask, i)) continue; |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4419 |
|
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4420 |
CargoID c = GetCargoIDByLabel(file->cargo_list[i]); |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4421 |
if (c == CT_INVALID) continue; |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4422 |
|
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4423 |
SETBIT(xor_mask, c); |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4424 |
} |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4425 |
} else { |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4426 |
/* No cargo table, so use the cargo bitnum values */ |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4427 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4428 |
const CargoSpec *cs = GetCargo(c); |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4429 |
if (!cs->IsValid()) continue; |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4430 |
|
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4431 |
if (HASBIT(_engine_info[engine].refit_mask, cs->bitnum)) SETBIT(xor_mask, c); |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4432 |
} |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4433 |
} |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
4434 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4435 |
|
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4436 |
if (cargo_allowed[engine] != 0) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4437 |
/* Build up the list of cargo types from the set cargo classes. */ |
6281 | 4438 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
6113
a10ede03ac58
(svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents:
6107
diff
changeset
|
4439 |
const CargoSpec *cs = GetCargo(i); |
6148
5247b66aad19
(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:
6147
diff
changeset
|
4440 |
if (cargo_allowed[engine] & cs->classes) SETBIT(mask, i); |
5247b66aad19
(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:
6147
diff
changeset
|
4441 |
if (cargo_disallowed[engine] & cs->classes) SETBIT(not_mask, i); |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4442 |
} |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4443 |
} else { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4444 |
/* Don't apply default refit mask to wagons or engines with no capacity */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
4445 |
if (xor_mask == 0 && ( |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6248
diff
changeset
|
4446 |
GetEngine(engine)->type != VEH_TRAIN || ( |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
4447 |
RailVehInfo(engine)->capacity != 0 && |
5868
94430141c189
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
5855
diff
changeset
|
4448 |
RailVehInfo(engine)->railveh_type != RAILVEH_WAGON |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
4449 |
) |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
4450 |
)) { |
6145
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4451 |
const CargoLabel *cl = _default_refitmasks[GetEngine(engine)->type]; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4452 |
for (uint i = 0;; i++) { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4453 |
if (cl[i] == 0) break; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4454 |
|
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4455 |
CargoID cargo = GetCargoIDByLabel(cl[i]); |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4456 |
if (cargo == CT_INVALID) continue; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4457 |
|
6148
5247b66aad19
(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:
6147
diff
changeset
|
4458 |
SETBIT(xor_mask, cargo); |
6145
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
4459 |
} |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
4460 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4461 |
} |
6113
a10ede03ac58
(svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents:
6107
diff
changeset
|
4462 |
_engine_info[engine].refit_mask = ((mask & ~not_mask) ^ xor_mask) & _cargo_mask; |
6142
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4463 |
|
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4464 |
/* Check if this engine's cargo type is valid. If not, set to the first refittable |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4465 |
* cargo type. Apparently cargo_type isn't a common property... */ |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4466 |
switch (GetEngine(engine)->type) { |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6248
diff
changeset
|
4467 |
case VEH_TRAIN: { |
6142
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4468 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4469 |
if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine); |
6282
861f9a1108bb
(svn r9094) -Codechange: Don't set up refit masks for engine types not in the current climate, and exclude engine types if their cargo type is invalid and they have no refittable type.
peter1138
parents:
6281
diff
changeset
|
4470 |
if (rvi->cargo_type == CT_INVALID) _engine_info[engine].climates = 0; |
6142
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4471 |
break; |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4472 |
} |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6248
diff
changeset
|
4473 |
case VEH_ROAD: { |
6142
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4474 |
RoadVehicleInfo *rvi = &_road_vehicle_info[engine - ROAD_ENGINES_INDEX]; |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4475 |
if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine); |
6282
861f9a1108bb
(svn r9094) -Codechange: Don't set up refit masks for engine types not in the current climate, and exclude engine types if their cargo type is invalid and they have no refittable type.
peter1138
parents:
6281
diff
changeset
|
4476 |
if (rvi->cargo_type == CT_INVALID) _engine_info[engine].climates = 0; |
6142
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4477 |
break; |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4478 |
} |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6248
diff
changeset
|
4479 |
case VEH_SHIP: { |
6142
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4480 |
ShipVehicleInfo *svi = &_ship_vehicle_info[engine - SHIP_ENGINES_INDEX]; |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4481 |
if (svi->cargo_type == CT_INVALID) svi->cargo_type = FindFirstRefittableCargo(engine); |
6282
861f9a1108bb
(svn r9094) -Codechange: Don't set up refit masks for engine types not in the current climate, and exclude engine types if their cargo type is invalid and they have no refittable type.
peter1138
parents:
6281
diff
changeset
|
4482 |
if (svi->cargo_type == CT_INVALID) _engine_info[engine].climates = 0; |
6142
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4483 |
break; |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4484 |
} |
80f876e7bb9f
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6139
diff
changeset
|
4485 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4486 |
} |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4487 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4488 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4489 |
/** Add all new houses to the house array. House properties can be set at any |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4490 |
* time in the GRF file, so we can only add a house spec to the house array |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4491 |
* after the file has finished loading. We also need to check the dates, due to |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4492 |
* the TTDPatch behaviour described below that we need to emulate. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4493 |
static void FinaliseHouseArray() |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4494 |
{ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4495 |
/* If there are no houses with start dates before 1930, then all houses |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4496 |
* with start dates of 1930 have them reset to 0. This is in order to be |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4497 |
* compatible with TTDPatch, where if no houses have start dates before |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4498 |
* 1930 and the date is before 1930, the game pretends that this is 1930. |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4499 |
* If there have been any houses defined with start dates before 1930 then |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4500 |
* the dates are left alone. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4501 |
bool reset_dates = true; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4502 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4503 |
for (GRFFile *file = _first_grffile; file != NULL; file = file->next) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4504 |
if (file->housespec == NULL) continue; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4505 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4506 |
for (int i = 0; i < HOUSE_MAX; i++) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4507 |
HouseSpec *hs = file->housespec[i]; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4508 |
if (hs != NULL) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4509 |
SetHouseSpec(hs); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4510 |
if (hs->min_date < 1930) reset_dates = false; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4511 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4512 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4513 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4514 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4515 |
if (reset_dates) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4516 |
for (int i = NEW_HOUSE_OFFSET; i < HOUSE_MAX; i++) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4517 |
HouseSpec *hs = GetHouseSpecs(i); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4518 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4519 |
if (hs->enabled && hs->min_date == 1930) hs->min_date = 0; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4520 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4521 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4522 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4523 |
|
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4524 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4525 |
/** Each cargo string needs to be mapped from TTDPatch to OpenTTD string IDs. |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4526 |
* This is done after loading so that strings from Action 4 will be mapped |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4527 |
* properly. */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4528 |
static void MapNewCargoStrings() |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4529 |
{ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4530 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4531 |
CargoSpec *cs = &_cargo[c]; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4532 |
/* Don't map if the cargo is unavailable or not from NewGRF */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4533 |
if (!cs->IsValid() || cs->grfid == 0) continue; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4534 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4535 |
cs->name = MapGRFStringID(cs->grfid, cs->name); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4536 |
cs->name_plural = MapGRFStringID(cs->grfid, cs->name_plural); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4537 |
cs->units_volume = MapGRFStringID(cs->grfid, cs->units_volume); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4538 |
cs->quantifier = MapGRFStringID(cs->grfid, cs->quantifier); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4539 |
cs->abbrev = MapGRFStringID(cs->grfid, cs->abbrev); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4540 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4541 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4542 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4543 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4544 |
/* Here we perform initial decoding of some special sprites (as are they |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4545 |
* described at http://www.ttdpatch.net/src/newgrf.txt, but this is only a very |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4546 |
* partial implementation yet). */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4547 |
/* XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4548 |
* a crafted invalid GRF file. We should tell that to the user somehow, or |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4549 |
* better make this more robust in the future. */ |
5008
c2b96042d529
(svn r7027) - Codechange: Replace NewGRF loading stage masks with separate function lists. This will allow us to call different handlers depending on the current stage. Also enum-ize the stage.
peter1138
parents:
4993
diff
changeset
|
4550 |
static void DecodeSpecialSprite(uint num, GrfLoadingStage stage) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4551 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4552 |
/* XXX: There is a difference between staged loading in TTDPatch and |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4553 |
* here. In TTDPatch, for some reason actions 1 and 2 are carried out |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4554 |
* during stage 1, whilst action 3 is carried out during stage 2 (to |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4555 |
* "resolve" cargo IDs... wtf). This is a little problem, because cargo |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4556 |
* IDs are valid only within a given set (action 1) block, and may be |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4557 |
* overwritten after action 3 associates them. But overwriting happens |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4558 |
* in an earlier stage than associating, so... We just process actions |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4559 |
* 1 and 2 in stage 2 now, let's hope that won't get us into problems. |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4560 |
* --pasky */ |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4561 |
/* We need a pre-stage to set up GOTO labels of Action 0x10 because the grf |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4562 |
* is not in memory and scanning the file every time would be too expensive. |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4563 |
* In other stages we skip action 0x10 since it's already dealt with. */ |
5008
c2b96042d529
(svn r7027) - Codechange: Replace NewGRF loading stage masks with separate function lists. This will allow us to call different handlers depending on the current stage. Also enum-ize the stage.
peter1138
parents:
4993
diff
changeset
|
4564 |
static const SpecialSpriteHandler handlers[][GLS_END] = { |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4565 |
/* 0x00 */ { NULL, SafeChangeInfo, NULL, InitChangeInfo, ReserveChangeInfo, FeatureChangeInfo, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4566 |
/* 0x01 */ { NULL, GRFUnsafe, NULL, NULL, NULL, NewSpriteSet, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4567 |
/* 0x02 */ { NULL, GRFUnsafe, NULL, NULL, NULL, NewSpriteGroup, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4568 |
/* 0x03 */ { NULL, GRFUnsafe, NULL, NULL, NULL, FeatureMapSpriteGroup, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4569 |
/* 0x04 */ { NULL, NULL, NULL, NULL, NULL, FeatureNewName, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4570 |
/* 0x05 */ { NULL, NULL, NULL, NULL, NULL, GraphicsNew, }, |
6373
75654b0484cd
(svn r9436) -Fix (r9411): don't deactivate GRF in an action 7/9 during reservation (and loading of cargo data), and action 6 should be run also
peter1138
parents:
6365
diff
changeset
|
4571 |
/* 0x06 */ { NULL, NULL, NULL, CfgApply, CfgApply, CfgApply, }, |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4572 |
/* 0x07 */ { NULL, NULL, NULL, NULL, SkipIf, SkipIf, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4573 |
/* 0x08 */ { ScanInfo, NULL, NULL, GRFInfo, NULL, GRFInfo, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4574 |
/* 0x09 */ { NULL, NULL, NULL, SkipIf, SkipIf, SkipIf, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4575 |
/* 0x0A */ { NULL, NULL, NULL, NULL, NULL, SpriteReplace, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4576 |
/* 0x0B */ { NULL, NULL, NULL, GRFLoadError, GRFLoadError, GRFLoadError, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4577 |
/* 0x0C */ { NULL, NULL, NULL, GRFComment, NULL, GRFComment, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4578 |
/* 0x0D */ { NULL, SafeParamSet, NULL, ParamSet, ParamSet, ParamSet, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4579 |
/* 0x0E */ { NULL, SafeGRFInhibit, NULL, GRFInhibit, GRFInhibit, GRFInhibit, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4580 |
/* 0x0F */ { NULL, NULL, NULL, NULL, NULL, NULL, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4581 |
/* 0x10 */ { NULL, NULL, DefineGotoLabel, NULL, NULL, NULL, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4582 |
/* 0x11 */ { NULL, GRFUnsafe, NULL, NULL, NULL, GRFSound, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4583 |
/* 0x12 */ { NULL, NULL, NULL, NULL, NULL, LoadFontGlyph, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4584 |
/* 0x13 */ { NULL, NULL, NULL, NULL, NULL, TranslateGRFStrings, }, |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4585 |
}; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4586 |
|
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4587 |
byte* buf; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4588 |
|
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4589 |
if (_preload_sprite == NULL) { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4590 |
/* No preloaded sprite to work with; allocate and read the |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4591 |
* pseudo sprite content. */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
4592 |
buf = MallocT<byte>(num); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4593 |
if (buf == NULL) error("DecodeSpecialSprite: Could not allocate memory"); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4594 |
FioReadBlock(buf, num); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4595 |
} else { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4596 |
/* Use the preloaded sprite data. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4597 |
buf = _preload_sprite; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4598 |
_preload_sprite = NULL; |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4599 |
grfmsg(7, "DecodeSpecialSprite: Using preloaded pseudo sprite data"); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4600 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4601 |
/* Skip the real (original) content of this action. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4602 |
FioSeekTo(num, SEEK_CUR); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4603 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
4604 |
|
6281 | 4605 |
byte action = buf[0]; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4606 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4607 |
if (action == 0xFF) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4608 |
grfmsg(7, "DecodeSpecialSprite: Handling data block in stage %d", stage); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4609 |
GRFDataBlock(buf, num); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4610 |
} else if (action == 0xFE) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4611 |
grfmsg(7, "DecodeSpecialSprite: andling import block in stage %d", stage); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4612 |
GRFImportBlock(buf, num); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4613 |
} else if (action >= lengthof(handlers)) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4614 |
grfmsg(7, "DecodeSpecialSprite: Skipping unknown action 0x%02X", action); |
5008
c2b96042d529
(svn r7027) - Codechange: Replace NewGRF loading stage masks with separate function lists. This will allow us to call different handlers depending on the current stage. Also enum-ize the stage.
peter1138
parents:
4993
diff
changeset
|
4615 |
} else if (handlers[action][stage] == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4616 |
grfmsg(7, "DecodeSpecialSprite: Skipping action 0x%02X in stage %d", action, stage); |
2645
841087328e0e
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
4617 |
} else { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4618 |
grfmsg(7, "DecodeSpecialSprite: Handling action 0x%02X in stage %d", action, stage); |
5008
c2b96042d529
(svn r7027) - Codechange: Replace NewGRF loading stage masks with separate function lists. This will allow us to call different handlers depending on the current stage. Also enum-ize the stage.
peter1138
parents:
4993
diff
changeset
|
4619 |
handlers[action][stage](buf, num); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4620 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4621 |
free(buf); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4622 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4623 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4624 |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4625 |
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage) |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4626 |
{ |
6424
d410d4c31d15
(svn r9560) -Codechange: add support for multiple 'base' directories for newgrf searching.
rubidium
parents:
6376
diff
changeset
|
4627 |
const char *filename = config->full_path; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4628 |
uint16 num; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4629 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4630 |
/* A .grf file is activated only if it was active when the game was |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4631 |
* started. If a game is loaded, only its active .grfs will be |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4632 |
* reactivated, unless "loadallgraphics on" is used. A .grf file is |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4633 |
* considered active if its action 8 has been processed, i.e. its |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4634 |
* action 8 hasn't been skipped using an action 7. |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4635 |
* |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4636 |
* During activation, only actions 0, 1, 2, 3, 4, 5, 7, 8, 9, 0A and 0B are |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4637 |
* carried out. All others are ignored, because they only need to be |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4638 |
* processed once at initialization. */ |
5329
9c5e8061ea0f
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
4639 |
if (stage != GLS_FILESCAN && stage != GLS_SAFETYSCAN && stage != GLS_LABELSCAN) { |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4640 |
_cur_grffile = GetFileByFilename(filename); |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4641 |
if (_cur_grffile == NULL) error("File '%s' lost in cache.\n", filename); |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
4642 |
if (stage == GLS_ACTIVATION && config->status != GCS_INITIALISED) return; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4643 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4644 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4645 |
FioOpenFile(file_index, filename); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4646 |
_file_index = file_index; // XXX |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4647 |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4648 |
_cur_grfconfig = config; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4649 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4650 |
DEBUG(grf, 2, "LoadNewGRFFile: Reading NewGRF-file '%s'", filename); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4651 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4652 |
/* Skip the first sprite; we don't care about how many sprites this |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4653 |
* does contain; newest TTDPatches and George's longvehicles don't |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4654 |
* neither, apparently. */ |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4655 |
if (FioReadWord() == 4 && FioReadByte() == 0xFF) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4656 |
FioReadDword(); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4657 |
} else { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4658 |
DEBUG(grf, 7, "LoadNewGRFFile: Custom .grf has invalid format"); |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4659 |
return; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4660 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4661 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4662 |
_skip_sprites = 0; // XXX |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
4663 |
_nfo_line = 0; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4664 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4665 |
while ((num = FioReadWord()) != 0) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4666 |
byte type = FioReadByte(); |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
4667 |
_nfo_line++; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4668 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4669 |
if (type == 0xFF) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4670 |
if (_skip_sprites == 0) { |
2958
ac0a9673b522
(svn r3520) Remove unused parameters from some functions
tron
parents:
2935
diff
changeset
|
4671 |
DecodeSpecialSprite(num, stage); |
5011
0b0003ba213e
(svn r7031) -Codechange: Use _skip_sprites to skip the rest of the NewGRF when disabled by GRM, and add a shortcut so that the rest of the file isn't scanned.
peter1138
parents:
5008
diff
changeset
|
4672 |
|
0b0003ba213e
(svn r7031) -Codechange: Use _skip_sprites to skip the rest of the NewGRF when disabled by GRM, and add a shortcut so that the rest of the file isn't scanned.
peter1138
parents:
5008
diff
changeset
|
4673 |
/* Stop all processing if we are to skip the remaining sprites */ |
0b0003ba213e
(svn r7031) -Codechange: Use _skip_sprites to skip the rest of the NewGRF when disabled by GRM, and add a shortcut so that the rest of the file isn't scanned.
peter1138
parents:
5008
diff
changeset
|
4674 |
if (_skip_sprites == -1) break; |
0b0003ba213e
(svn r7031) -Codechange: Use _skip_sprites to skip the rest of the NewGRF when disabled by GRM, and add a shortcut so that the rest of the file isn't scanned.
peter1138
parents:
5008
diff
changeset
|
4675 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4676 |
continue; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4677 |
} else { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4678 |
FioSkipBytes(num); |
1611 | 4679 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4680 |
} else { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4681 |
if (_skip_sprites == 0) grfmsg(7, "LoadNewGRFFile: Skipping unexpected sprite"); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4682 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4683 |
FioSkipBytes(7); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4684 |
num -= 8; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4685 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4686 |
if (type & 2) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4687 |
FioSkipBytes(num); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4688 |
} else { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4689 |
while (num > 0) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4690 |
int8 i = FioReadByte(); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4691 |
if (i >= 0) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4692 |
num -= i; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4693 |
FioSkipBytes(i); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4694 |
} else { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4695 |
i = -(i >> 3); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4696 |
num -= i; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4697 |
FioReadByte(); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4698 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4699 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4700 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4701 |
} |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4702 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4703 |
if (_skip_sprites > 0) _skip_sprites--; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4704 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4705 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4706 |
|
6247 | 4707 |
void InitDepotWindowBlockSizes(); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4708 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4709 |
static void AfterLoadGRFs() |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4710 |
{ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4711 |
/* Pre-calculate all refit masks after loading GRF files. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4712 |
CalculateRefitMasks(); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4713 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4714 |
/* Set the block size in the depot windows based on vehicle sprite sizes */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4715 |
InitDepotWindowBlockSizes(); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4716 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4717 |
/* Add all new houses to the house array. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4718 |
FinaliseHouseArray(); |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4719 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4720 |
/* Map cargo strings. This is a separate step because cargos are |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4721 |
* loaded before strings... */ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
4722 |
MapNewCargoStrings(); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4723 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4724 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4725 |
void LoadNewGRF(uint load_index, uint file_index) |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4726 |
{ |
2930
99088d4aba31
(svn r3486) - NewGRF fix: Always reinitialize the ttdpatch flags as patch settings may have changed.
peter1138
parents:
2895
diff
changeset
|
4727 |
InitializeGRFSpecial(); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4728 |
|
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4729 |
ResetNewGRFData(); |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
4730 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4731 |
/* Load newgrf sprites |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4732 |
* in each loading stage, (try to) open each file specified in the config |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4733 |
* and load information from it. */ |
6281 | 4734 |
for (GrfLoadingStage stage = GLS_LABELSCAN; stage <= GLS_ACTIVATION; stage++) { |
2400
2b258097156f
(svn r2926) -Fix: Use the same file slots in both initialisation stages when loading a patch grf
tron
parents:
2346
diff
changeset
|
4735 |
uint slot = file_index; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4736 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4737 |
_cur_stage = stage; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4738 |
_cur_spriteid = load_index; |
6281 | 4739 |
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
4740 |
if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND) continue; |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4741 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4742 |
/* @todo usererror() */ |
6424
d410d4c31d15
(svn r9560) -Codechange: add support for multiple 'base' directories for newgrf searching.
rubidium
parents:
6376
diff
changeset
|
4743 |
if (!FileExists(c->full_path)) error("NewGRF file is missing '%s'", c->filename); |
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
4744 |
|
5008
c2b96042d529
(svn r7027) - Codechange: Replace NewGRF loading stage masks with separate function lists. This will allow us to call different handlers depending on the current stage. Also enum-ize the stage.
peter1138
parents:
4993
diff
changeset
|
4745 |
if (stage == GLS_LABELSCAN) InitNewGRFFile(c, _cur_spriteid); |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4746 |
LoadNewGRFFile(c, slot++, stage); |
5476
fa6583f537ce
(svn r7760) -Codechange: Debug messages for newgrf showed the starting sprite, not the current sprite index. Also only output the debug message during activation, when sprites are loaded.
peter1138
parents:
5475
diff
changeset
|
4747 |
if (stage == GLS_ACTIVATION) { |
fa6583f537ce
(svn r7760) -Codechange: Debug messages for newgrf showed the starting sprite, not the current sprite index. Also only output the debug message during activation, when sprites are loaded.
peter1138
parents:
5475
diff
changeset
|
4748 |
ClearTemporaryNewGRFData(); |
6147
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
4749 |
BuildCargoTranslationMap(); |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4750 |
DEBUG(sprite, 2, "LoadNewGRF: Currently %i sprites are loaded", _cur_spriteid); |
5476
fa6583f537ce
(svn r7760) -Codechange: Debug messages for newgrf showed the starting sprite, not the current sprite index. Also only output the debug message during activation, when sprites are loaded.
peter1138
parents:
5475
diff
changeset
|
4751 |
} |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4752 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4753 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
4754 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4755 |
/* Call any functions that should be run after GRFs have been loaded. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
4756 |
AfterLoadGRFs(); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4757 |
} |