author | rubidium |
Thu, 01 Feb 2007 15:49:12 +0000 | |
changeset 5893 | 7e431a4abebb |
parent 5889 | 461a9fbf58da |
child 5903 | 2bb5b340115b |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3 |
#include "stdafx.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5 |
#include <stdarg.h> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
6 |
|
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1883
diff
changeset
|
7 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1183
diff
changeset
|
8 |
#include "debug.h" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
9 |
#include "gfx.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
10 |
#include "fileio.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
11 |
#include "functions.h" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
12 |
#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
|
13 |
#include "spritecache.h" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
14 |
#include "station.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
15 |
#include "sprite.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
16 |
#include "newgrf.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2013
diff
changeset
|
17 |
#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
|
18 |
#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
|
19 |
#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
|
20 |
#include "bridge.h" |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
21 |
#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
|
22 |
#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
|
23 |
#include "vehicle.h" |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
24 |
#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
|
25 |
#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
|
26 |
#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
|
27 |
#include "date.h" |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
28 |
#include "currency.h" |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
29 |
#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
|
30 |
#include "newgrf_config.h" |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
31 |
#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
|
32 |
#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
|
33 |
#include "helpers.hpp" |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
34 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
35 |
/* TTDPatch extended GRF format codec |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
36 |
* (c) Petr Baudis 2004 (GPL'd) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
37 |
* 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
|
38 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
39 |
* Contains portions of documentation by TTDPatch team. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
40 |
* 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
|
41 |
* 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
|
42 |
* 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
|
43 |
|
455 | 44 |
|
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
|
45 |
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
|
46 |
static uint _file_index; // XXX |
5209
1b7a72191019
(svn r7324) -Codechange: reset newgrf signal location data
peter1138
parents:
5161
diff
changeset
|
47 |
SpriteID _signal_base; |
5210
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
48 |
SpriteID _coast_base; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
49 |
|
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
|
50 |
static GRFFile *_cur_grffile; |
1477 | 51 |
GRFFile *_first_grffile; |
3707
7dc7e4d2487e
(svn r4650) - NewGRF: use the correct type for _cur_spriteid
peter1138
parents:
3704
diff
changeset
|
52 |
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
|
53 |
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
|
54 |
static uint32 _nfo_line; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
55 |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
56 |
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
|
57 |
|
3814
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
58 |
/* 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
|
59 |
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
|
60 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
61 |
/* 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
|
62 |
static uint32 _ttdpatch_flags[8]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
63 |
|
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
64 |
/* 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
|
65 |
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
|
66 |
|
4742
d915db693186
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
67 |
/* 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
|
68 |
bool _have_2cc = false; |
d915db693186
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
69 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
70 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
71 |
typedef enum GrfDataType { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
72 |
GDT_SOUND, |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
73 |
} GrfDataType; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
74 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
75 |
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
|
76 |
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
|
77 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
78 |
|
1477 | 79 |
typedef enum grfspec_feature { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
80 |
GSF_TRAIN, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
81 |
GSF_ROAD, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
82 |
GSF_SHIP, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
83 |
GSF_AIRCRAFT, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
84 |
GSF_STATION, |
2438
f0bf4adbd620
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
85 |
GSF_CANAL, |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
86 |
GSF_BRIDGE, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
87 |
GSF_TOWNHOUSE, |
3620
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
88 |
GSF_GLOBALVAR, |
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
89 |
GSF_INDUSTRYTILES, |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
90 |
GSF_INDUSTRIES, |
3620
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
91 |
GSF_CARGOS, |
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
92 |
GSF_SOUNDFX, |
1477 | 93 |
} grfspec_feature; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
94 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
95 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
96 |
typedef void (*SpecialSpriteHandler)(byte *buf, int len); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
97 |
|
4964
fd058c9cd46a
(svn r6963) - Fix (r6960): signed/unsigned complaints from MSVC
peter1138
parents:
4961
diff
changeset
|
98 |
static const int _vehcounts[4] = { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
99 |
/* GSF_TRAIN */ NUM_TRAIN_ENGINES, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
100 |
/* GSF_ROAD */ NUM_ROAD_ENGINES, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
101 |
/* GSF_SHIP */ NUM_SHIP_ENGINES, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
102 |
/* GSF_AIRCRAFT */ NUM_AIRCRAFT_ENGINES |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
103 |
}; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
104 |
|
4964
fd058c9cd46a
(svn r6963) - Fix (r6960): signed/unsigned complaints from MSVC
peter1138
parents:
4961
diff
changeset
|
105 |
static const int _vehshifts[4] = { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
106 |
/* GSF_TRAIN */ 0, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
107 |
/* GSF_ROAD */ ROAD_ENGINES_INDEX, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
108 |
/* GSF_SHIP */ SHIP_ENGINES_INDEX, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
109 |
/* GSF_AIRCRAFT */ AIRCRAFT_ENGINES_INDEX, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
110 |
}; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
111 |
|
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
|
112 |
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
|
113 |
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
|
114 |
}; |
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
|
115 |
|
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
116 |
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
|
117 |
static uint16 cargo_disallowed[TOTAL_NUM_ENGINES]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
118 |
|
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
119 |
/* 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
|
120 |
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
|
121 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
122 |
/** 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
|
123 |
* 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
|
124 |
* 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
|
125 |
* 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
|
126 |
* 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
|
127 |
* 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
|
128 |
* @param severity debugging severity level, see debug.h |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
129 |
* @param debugging message in printf() format */ |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
130 |
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
|
131 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
132 |
char buf[1024]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
133 |
va_list va; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
134 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
135 |
va_start(va, str); |
1477 | 136 |
vsnprintf(buf, sizeof(buf), str, va); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
137 |
va_end(va); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
138 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
139 |
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
|
140 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
141 |
|
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
|
142 |
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
|
143 |
{ |
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
|
144 |
if (real >= wanted) return true; |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
145 |
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
|
146 |
return false; |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
147 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
148 |
|
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
490
diff
changeset
|
149 |
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
|
150 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
151 |
return *(*buf)++; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
152 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
153 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
154 |
static uint16 grf_load_word(byte **buf) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
155 |
{ |
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
|
156 |
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
|
157 |
return val | (grf_load_byte(buf) << 8); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
158 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
159 |
|
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
160 |
static uint16 grf_load_extended(byte** buf) |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
161 |
{ |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
162 |
uint16 val; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
163 |
val = grf_load_byte(buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
164 |
if (val == 0xFF) val = grf_load_word(buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
165 |
return val; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
166 |
} |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
167 |
|
2324 | 168 |
static uint32 grf_load_dword(byte **buf) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
169 |
{ |
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
|
170 |
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
|
171 |
return val | (grf_load_word(buf) << 16); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
172 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
173 |
|
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
|
174 |
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
|
175 |
{ |
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
|
176 |
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
|
177 |
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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
} |
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 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
185 |
|
1477 | 186 |
static GRFFile *GetFileByGRFID(uint32 grfid) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
187 |
{ |
1477 | 188 |
GRFFile *file; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
189 |
|
1477 | 190 |
for (file = _first_grffile; file != NULL; file = file->next) { |
191 |
if (file->grfid == grfid) break; |
|
192 |
} |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
193 |
return file; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
194 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
195 |
|
1477 | 196 |
static GRFFile *GetFileByFilename(const char *filename) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
197 |
{ |
1477 | 198 |
GRFFile *file; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
199 |
|
1477 | 200 |
for (file = _first_grffile; file != NULL; file = file->next) { |
201 |
if (strcmp(file->filename, filename) == 0) break; |
|
202 |
} |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
203 |
return file; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
204 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
205 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
206 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
207 |
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
|
208 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
209 |
#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
|
210 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
211 |
static void dewagonize(int condition, int engine) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
212 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
213 |
EngineInfo *ei = &_engine_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
214 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
215 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
216 |
if (condition != 0) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
217 |
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
|
218 |
rvi->railveh_type = RAILVEH_SINGLEHEAD; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
219 |
} else { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
220 |
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
|
221 |
rvi->railveh_type = RAILVEH_WAGON; |
452
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 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
224 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
225 |
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
|
226 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
227 |
EngineInfo *ei = &_engine_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
228 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
229 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
230 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
231 |
bool ret = false; |
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 |
switch (prop) { |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
234 |
case 0x05: /* Track type */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
235 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
236 |
uint8 tracktype = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
237 |
|
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
|
238 |
switch (tracktype) { |
5763 | 239 |
case 0: rvi[i].railtype = rvi[i].engclass == 2 ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; break; |
240 |
case 1: rvi[i].railtype = RAILTYPE_MONO; break; |
|
241 |
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
|
242 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
243 |
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
|
244 |
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
|
245 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
246 |
} |
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
|
247 |
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
|
248 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
249 |
case 0x08: /* AI passenger service */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
250 |
/* TODO */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
251 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
252 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
253 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
254 |
|
3488
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
255 |
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
|
256 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
257 |
uint16 speed = grf_load_word(&buf); |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
258 |
if (speed == 0xFFFF) speed = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
259 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
260 |
rvi[i].max_speed = speed; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
261 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
262 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
263 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
264 |
case 0x0B: /* Power */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
265 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
266 |
uint16 power = grf_load_word(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
267 |
|
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
|
268 |
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
|
269 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
270 |
rvi[i].power = power; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
271 |
dewagonize(power, engine + i); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
272 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
273 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
274 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
275 |
case 0x0D: /* Running cost factor */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
276 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
277 |
uint8 runcostfact = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
278 |
|
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
|
279 |
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
|
280 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
281 |
rvi[i].running_cost_base = runcostfact; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
282 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
283 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
284 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
285 |
case 0x0E: /* Running cost base */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
286 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
287 |
uint32 base = grf_load_dword(&buf); |
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 |
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
|
290 |
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
|
291 |
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
|
292 |
case 0x4C3C: rvi[i].running_cost_class = 2; break; |
5324
d5b8b676aee9
(svn r7485) -Codechange: [NewGRF] Add debug warning for unsupported running cost bases for rail vehicles.
peter1138
parents:
5317
diff
changeset
|
293 |
case 0: break; /* Used by wagons */ |
d5b8b676aee9
(svn r7485) -Codechange: [NewGRF] Add debug warning for unsupported running cost bases for rail vehicles.
peter1138
parents:
5317
diff
changeset
|
294 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
295 |
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
|
296 |
break; |
452
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 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
299 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
300 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
301 |
case 0x12: /* Sprite ID */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
302 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
303 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
304 |
|
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
|
305 |
/* 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
|
306 |
* 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
|
307 |
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
|
308 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
309 |
rvi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
310 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
311 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
312 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
313 |
case 0x13: /* Dual-headed */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
314 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
315 |
uint8 dual = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
316 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
317 |
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
|
318 |
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
|
319 |
// 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
|
320 |
rvi[i].power /= 2; |
2836
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
321 |
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
|
322 |
} |
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
|
323 |
rvi[i].railveh_type = RAILVEH_MULTIHEAD; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
324 |
} 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
|
325 |
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
|
326 |
// 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
|
327 |
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
|
328 |
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
|
329 |
} |
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
|
330 |
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
|
331 |
RAILVEH_WAGON : RAILVEH_SINGLEHEAD; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
332 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
333 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
334 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
335 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
336 |
case 0x14: /* Cargo capacity */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
337 |
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
|
338 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
339 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
340 |
case 0x15: /* Cargo type */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
341 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
342 |
uint8 ctype = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
343 |
|
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
|
344 |
if (ctype < NUM_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
|
345 |
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
|
346 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
347 |
grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, ignoring", 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
|
348 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
349 |
} |
3023
d651099f7b18
(svn r3603) - NewGRF: Support loading of AI rank data
peter1138
parents:
3006
diff
changeset
|
350 |
break; |
d651099f7b18
(svn r3603) - NewGRF: Support loading of AI rank data
peter1138
parents:
3006
diff
changeset
|
351 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
352 |
case 0x16: /* Weight */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
353 |
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
|
354 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
355 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
356 |
case 0x17: /* Cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
357 |
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
|
358 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
359 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
360 |
case 0x18: /* AI rank */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
361 |
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
|
362 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
363 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
364 |
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
|
365 |
/* 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
|
366 |
* 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
|
367 |
* 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
|
368 |
* 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
|
369 |
* 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
|
370 |
* 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
|
371 |
*/ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
372 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
373 |
uint8 traction = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
374 |
int engclass; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
375 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
376 |
if (traction <= 0x07) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
377 |
engclass = 0; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
378 |
} else if (traction <= 0x27) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
379 |
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
|
380 |
} 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
|
381 |
engclass = 2; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
382 |
} else if (traction <= 0x41) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
383 |
engclass = 2; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
384 |
} else { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
385 |
break; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
386 |
} |
5763 | 387 |
if (rvi[i].railtype == RAILTYPE_RAIL && engclass == 2) rvi[i].railtype = RAILTYPE_ELECTRIC; |
388 |
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
|
389 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
390 |
rvi[i].engclass = engclass; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
391 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
392 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
393 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
394 |
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
|
395 |
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
|
396 |
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
|
397 |
|
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
|
398 |
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
|
399 |
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
|
400 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
401 |
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
|
402 |
} |
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
|
403 |
} |
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
|
404 |
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
|
405 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
406 |
case 0x1B: /* Powered wagons power bonus */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
407 |
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
|
408 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
409 |
|
3997
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
410 |
case 0x1C: /* Refit cost */ |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
411 |
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
|
412 |
break; |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
413 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
414 |
case 0x1D: /* Refit cargo */ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
415 |
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
|
416 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
417 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
418 |
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
|
419 |
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
|
420 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
421 |
|
5400
bba42ad3223b
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5382
diff
changeset
|
422 |
case 0x1F: /* Tractive effort coefficient */ |
bba42ad3223b
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5382
diff
changeset
|
423 |
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
|
424 |
break; |
bba42ad3223b
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5382
diff
changeset
|
425 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
426 |
case 0x21: /* Shorter vehicle */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
427 |
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
|
428 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
429 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
430 |
case 0x22: /* Visual effect */ |
1908
2fa391fed79a
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
431 |
// 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
|
432 |
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
|
433 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
434 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
435 |
case 0x23: /* Powered wagons weight bonus */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
436 |
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
|
437 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
438 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
439 |
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
|
440 |
FOR_EACH_OBJECT { |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
441 |
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
|
442 |
|
2545
aa71b3d576ce
(svn r3074) -NewGrf: Fix stupid typo in weight setting.
peter1138
parents:
2542
diff
changeset
|
443 |
if (weight > 4) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
444 |
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
|
445 |
} else { |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
446 |
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
|
447 |
} |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
448 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
449 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
450 |
|
3862
fe7b57944a39
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
peter1138
parents:
3845
diff
changeset
|
451 |
case 0x25: /* User-defined bit mask to set when checking veh. var. 42 */ |
fe7b57944a39
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
peter1138
parents:
3845
diff
changeset
|
452 |
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
|
453 |
break; |
fe7b57944a39
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
peter1138
parents:
3845
diff
changeset
|
454 |
|
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
455 |
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
|
456 |
FOR_EACH_OBJECT { |
d915db693186
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
457 |
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
|
458 |
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
|
459 |
} |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
460 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
461 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
462 |
case 0x28: /* Cargo classes allowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
463 |
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
|
464 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
465 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
466 |
case 0x29: /* Cargo classes disallowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
467 |
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
|
468 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
469 |
|
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
|
470 |
case 0x2A: /* Long format introduction date (days since year 0) */ |
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
|
471 |
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
|
472 |
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
|
473 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
474 |
/* TODO */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
475 |
/* Fall-through for unimplemented one byte long properties. */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
476 |
case 0x20: /* Air drag */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
477 |
case 0x26: /* Retire vehicle early */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
478 |
/* TODO */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
479 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
480 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
481 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
482 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
483 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
484 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
485 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
486 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
487 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
488 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
489 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
490 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
491 |
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
|
492 |
{ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
493 |
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
|
494 |
RoadVehicleInfo *rvi = &_road_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
495 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
496 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
497 |
bool ret = false; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
498 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
499 |
switch (prop) { |
3488
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
500 |
case 0x08: /* Speed (1 unit is 0.5 kmh) */ |
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
501 |
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
|
502 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
503 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
504 |
case 0x09: /* Running cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
505 |
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
|
506 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
507 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
508 |
case 0x0A: /* Running cost base */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
509 |
/* TODO: I have no idea. --pasky */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
510 |
FOR_EACH_OBJECT grf_load_dword(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
511 |
ret = true; |
3089
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 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
514 |
case 0x0E: /* Sprite ID */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
515 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
516 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
517 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
518 |
// cars have different custom id in the GRF file |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
519 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
520 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
521 |
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
|
522 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
523 |
rvi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
524 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
525 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
526 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
527 |
case 0x0F: /* Cargo capacity */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
528 |
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
|
529 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
530 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
531 |
case 0x10: /* Cargo type */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
532 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
533 |
uint8 cargo = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
534 |
|
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
|
535 |
if (cargo < NUM_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
|
536 |
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
|
537 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
538 |
grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, ignoring", 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
|
539 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
540 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
541 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
542 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
543 |
case 0x11: /* Cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
544 |
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
|
545 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
546 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
547 |
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
|
548 |
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
|
549 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
550 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
551 |
case 0x13: /* Power in 10hp */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
552 |
case 0x14: /* Weight in 1/4 tons */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
553 |
case 0x15: /* Speed in mph*0.8 */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
554 |
/* TODO: Support for road vehicles realistic power |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
555 |
* computations (called rvpower in TTDPatch) is just |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
556 |
* missing in OTTD yet. --pasky */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
557 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
558 |
ret = true; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
559 |
break; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
560 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
561 |
case 0x16: /* Cargos available for refitting */ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
562 |
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
|
563 |
break; |
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
564 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
565 |
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
|
566 |
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
|
567 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
568 |
|
3997
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
569 |
case 0x1A: /* Refit cost */ |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
570 |
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
|
571 |
break; |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
572 |
|
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
573 |
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
|
574 |
FOR_EACH_OBJECT { |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
575 |
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
|
576 |
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
|
577 |
} |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
578 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
579 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
580 |
case 0x1D: /* Cargo classes allowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
581 |
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
|
582 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
583 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
584 |
case 0x1E: /* Cargo classes disallowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
585 |
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
|
586 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
587 |
|
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
|
588 |
case 0x1F: /* Long format introduction date (days since year 0) */ |
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
|
589 |
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
|
590 |
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
|
591 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
592 |
case 0x18: /* Tractive effort */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
593 |
case 0x19: /* Air drag */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
594 |
case 0x1B: /* Retire vehicle early */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
595 |
/* TODO */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
596 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
597 |
ret = true; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
598 |
break; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
599 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
600 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
601 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
602 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
603 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
604 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
605 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
606 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
607 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
608 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
609 |
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
|
610 |
{ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
611 |
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
|
612 |
ShipVehicleInfo *svi = &_ship_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
613 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
614 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
615 |
bool ret = false; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
616 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
617 |
//printf("e %x prop %x?\n", engine, prop); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
618 |
switch (prop) { |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
619 |
case 0x08: /* Sprite ID */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
620 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
621 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
622 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
623 |
// ships have different custom id in the GRF file |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
624 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
625 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
626 |
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
|
627 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
628 |
svi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
629 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
630 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
631 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
632 |
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
|
633 |
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
|
634 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
635 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
636 |
case 0x0A: /* Cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
637 |
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
|
638 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
639 |
|
3488
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
640 |
case 0x0B: /* Speed (1 unit is 0.5 kmh) */ |
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
641 |
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
|
642 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
643 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
644 |
case 0x0C: /* Cargo type */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
645 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
646 |
uint8 cargo = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
647 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
648 |
// XXX: Need to consult this with patchman yet. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
649 |
#if 0 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
650 |
// Documentation claims this is already the |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
651 |
// per-landscape cargo type id, but newships.grf |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
652 |
// assume otherwise. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
653 |
cargo = local_cargo_id_ctype[cargo]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
654 |
#endif |
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
|
655 |
if (cargo < NUM_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
|
656 |
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
|
657 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
658 |
grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, ignoring", 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
|
659 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
660 |
} |
3006
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
661 |
break; |
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
662 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
663 |
case 0x0D: /* Cargo capacity */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
664 |
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
|
665 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
666 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
667 |
case 0x0F: /* Running cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
668 |
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
|
669 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
670 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
671 |
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
|
672 |
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
|
673 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
674 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
675 |
case 0x11: /* Cargos available for refitting */ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
676 |
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
|
677 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
678 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
679 |
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
|
680 |
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
|
681 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
682 |
|
3997
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
683 |
case 0x13: /* Refit cost */ |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
684 |
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
|
685 |
break; |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
686 |
|
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
687 |
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
|
688 |
FOR_EACH_OBJECT { |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
689 |
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
|
690 |
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
|
691 |
} |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
692 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
693 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
694 |
case 0x18: /* Cargo classes allowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
695 |
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
|
696 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
697 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
698 |
case 0x19: /* Cargo classes disallowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
699 |
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
|
700 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
701 |
|
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
|
702 |
case 0x1A: /* Long format introduction date (days since year 0) */ |
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
|
703 |
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
|
704 |
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
|
705 |
|
1872
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
706 |
case 0x14: /* Ocean speed fraction */ |
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
707 |
case 0x15: /* Canal speed fraction */ |
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
708 |
case 0x16: /* Retire vehicle early */ |
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
709 |
/* TODO */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
710 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
711 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
712 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
713 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
714 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
715 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
716 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
717 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
718 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
719 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
720 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
721 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
722 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
723 |
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
|
724 |
{ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
725 |
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
|
726 |
AircraftVehicleInfo *avi = &_aircraft_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
727 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
728 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
729 |
bool ret = false; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
730 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
731 |
//printf("e %x prop %x?\n", engine, prop); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
732 |
switch (prop) { |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
733 |
case 0x08: /* Sprite ID */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
734 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
735 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
736 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
737 |
// aircraft have different custom id in the GRF file |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
738 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
739 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
740 |
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
|
741 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
742 |
avi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
743 |
} |
3006
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
744 |
break; |
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
745 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
746 |
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
|
747 |
FOR_EACH_OBJECT { |
4b2f470a4355
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
748 |
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
|
749 |
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
|
750 |
} 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
|
751 |
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
|
752 |
} |
4b2f470a4355
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
753 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
754 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
755 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
756 |
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
|
757 |
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
|
758 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
759 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
760 |
case 0x0B: /* Cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
761 |
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
|
762 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
763 |
|
3488
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
764 |
case 0x0C: /* Speed (1 unit is 8 mph) */ |
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
765 |
FOR_EACH_OBJECT avi[i].max_speed = grf_load_byte(&buf); |
3089
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 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
768 |
case 0x0D: /* Acceleration */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
769 |
FOR_EACH_OBJECT avi[i].acceleration = grf_load_byte(&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 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
772 |
case 0x0E: /* Running cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
773 |
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
|
774 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
775 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
776 |
case 0x0F: /* Passenger capacity */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
777 |
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
|
778 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
779 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
780 |
case 0x11: /* Mail capacity */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
781 |
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
|
782 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
783 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
784 |
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
|
785 |
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
|
786 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
787 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
788 |
case 0x13: /* Cargos available for refitting */ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
789 |
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
|
790 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
791 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
792 |
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
|
793 |
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
|
794 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
795 |
|
3997
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
796 |
case 0x15: /* Refit cost */ |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
797 |
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
|
798 |
break; |
8a997effbcec
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
799 |
|
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
800 |
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
|
801 |
FOR_EACH_OBJECT { |
9c45131d0657
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
802 |
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
|
803 |
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
|
804 |
} |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
805 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
806 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
807 |
case 0x18: /* Cargo classes allowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
808 |
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
|
809 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
810 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
811 |
case 0x19: /* Cargo classes disallowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
812 |
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
|
813 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
814 |
|
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
|
815 |
case 0x1A: /* Long format introduction date (days since year 0) */ |
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
|
816 |
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
|
817 |
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
|
818 |
|
1872
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
819 |
case 0x16: /* Retire vehicle early */ |
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
820 |
/* TODO */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
821 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
822 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
823 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
824 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
825 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
826 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
827 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
828 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
829 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
830 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
831 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
832 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
833 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
834 |
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
|
835 |
{ |
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
|
836 |
StationSpec **statspec; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
837 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
838 |
int i; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
839 |
bool ret = false; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
840 |
|
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
|
841 |
if (stid + numinfo > MAX_STATIONS) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
842 |
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
|
843 |
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
|
844 |
} |
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
|
845 |
|
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
|
846 |
/* 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
|
847 |
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
|
848 |
|
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
|
849 |
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
|
850 |
|
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
|
851 |
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
|
852 |
/* 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
|
853 |
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
|
854 |
if (statspec[i] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
855 |
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
|
856 |
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
|
857 |
} |
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
|
858 |
} |
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
|
859 |
} |
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
|
860 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
861 |
switch (prop) { |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
862 |
case 0x08: /* Class ID */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
863 |
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
|
864 |
uint32 classid; |
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
|
865 |
|
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
|
866 |
/* 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
|
867 |
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
|
868 |
|
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
|
869 |
/* Swap classid because we read it in BE meaning WAYP or DFLT */ |
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
|
870 |
classid = grf_load_dword(&buf); |
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
|
871 |
statspec[i]->sclass = AllocateStationClass(BSWAP32(classid)); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
872 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
873 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
874 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
875 |
case 0x09: /* Define sprite layout */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
876 |
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
|
877 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
3570
707f93772b0a
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
878 |
uint t; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
879 |
|
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
880 |
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
|
881 |
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
|
882 |
statspec->copied_renderdata = false; |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
883 |
|
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
884 |
for (t = 0; t < statspec->tiles; t++) { |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
885 |
DrawTileSprites *dts = &statspec->renderdata[t]; |
3570
707f93772b0a
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
886 |
uint seq_count = 0; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
887 |
|
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
|
888 |
dts->seq = NULL; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
889 |
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
|
890 |
dts->ground_pal = grf_load_word(&buf); |
3775
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
891 |
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
|
892 |
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
|
893 |
CLRBIT(dts->ground_pal, 15); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
894 |
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
|
895 |
} |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
896 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
897 |
while (buf < *bufp + len) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
898 |
DrawTileSeqStruct *dtss; |
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 |
// 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
|
901 |
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
|
902 |
dtss = (DrawTileSeqStruct*) &dts->seq[seq_count - 1]; |
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 |
dtss->delta_x = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
905 |
if ((byte) dtss->delta_x == 0x80) break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
906 |
dtss->delta_y = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
907 |
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
|
908 |
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
|
909 |
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
|
910 |
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
|
911 |
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
|
912 |
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
|
913 |
|
3775
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
914 |
/* 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
|
915 |
if (HASBIT(dtss->pal, 15)) { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
916 |
CLRBIT(dtss->pal, 15); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
917 |
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
|
918 |
} |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
919 |
|
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
920 |
if (HASBIT(dtss->image, 15)) { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
921 |
CLRBIT(dtss->image, 15); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
922 |
SETBIT(dtss->image, PALETTE_MODIFIER_COLOR); |
3775
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
923 |
} |
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
|
924 |
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
|
925 |
CLRBIT(dtss->image, 14); |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
926 |
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
|
927 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
928 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
929 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
930 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
931 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
932 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
933 |
case 0x0A: /* Copy sprite layout */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
934 |
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
|
935 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
936 |
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
|
937 |
const StationSpec *srcstatspec = _cur_grffile->stations[srcid]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
938 |
|
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
939 |
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
|
940 |
statspec->renderdata = srcstatspec->renderdata; |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
941 |
statspec->copied_renderdata = true; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
942 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
943 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
944 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
945 |
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
|
946 |
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
|
947 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
948 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
949 |
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
|
950 |
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
|
951 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
952 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
953 |
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
|
954 |
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
|
955 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
956 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
957 |
case 0x0E: /* Define custom layout */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
958 |
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
|
959 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
960 |
|
5060
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
961 |
statspec->copied_layouts = false; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
962 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
963 |
while (buf < *bufp + len) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
964 |
byte length = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
965 |
byte number = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
966 |
StationLayout layout; |
3570
707f93772b0a
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
967 |
uint l, p; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
968 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
969 |
if (length == 0 || number == 0) break; |
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 |
//debug("l %d > %d ?", length, stat->lengths); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
972 |
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
|
973 |
statspec->platforms = ReallocT(statspec->platforms, length); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
974 |
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
|
975 |
|
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
|
976 |
statspec->layouts = ReallocT(statspec->layouts, length); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
977 |
memset(statspec->layouts + statspec->lengths, 0, |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
978 |
(length - statspec->lengths) * sizeof(*statspec->layouts)); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
979 |
|
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
980 |
statspec->lengths = length; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
981 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
982 |
l = length - 1; // index is zero-based |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
983 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
984 |
//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
|
985 |
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
|
986 |
statspec->layouts[l] = ReallocT(statspec->layouts[l], number); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
987 |
// 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
|
988 |
memset(statspec->layouts[l] + statspec->platforms[l], 0, |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
989 |
(number - statspec->platforms[l]) * sizeof(**statspec->layouts)); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
990 |
|
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
991 |
statspec->platforms[l] = number; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
992 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
993 |
|
542 | 994 |
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
|
995 |
layout = MallocT<byte>(length * number); |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
996 |
for (l = 0; l < length; l++) { |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
997 |
for (p = 0; p < number; p++) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
998 |
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
|
999 |
} |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1000 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1001 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1002 |
l--; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1003 |
p--; |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1004 |
free(statspec->layouts[l][p]); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1005 |
statspec->layouts[l][p] = layout; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1006 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1007 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1008 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1009 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1010 |
case 0x0F: /* Copy custom layout */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1011 |
FOR_EACH_OBJECT { |
5060
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1012 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1013 |
byte srcid = grf_load_byte(&buf); |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1014 |
const StationSpec *srcstatspec = _cur_grffile->stations[srcid]; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1015 |
|
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1016 |
statspec->lengths = srcstatspec->lengths; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1017 |
statspec->platforms = srcstatspec->platforms; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1018 |
statspec->layouts = srcstatspec->layouts; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1019 |
statspec->copied_layouts = true; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1020 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1021 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1022 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1023 |
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
|
1024 |
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
|
1025 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1026 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1027 |
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
|
1028 |
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
|
1029 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1030 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1031 |
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
|
1032 |
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
|
1033 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1034 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1035 |
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
|
1036 |
FOR_EACH_OBJECT statspec[i]->flags = grf_load_byte(&buf); |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1037 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1038 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1039 |
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
|
1040 |
FOR_EACH_OBJECT statspec[i]->wires = grf_load_byte(&buf); |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1041 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1042 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1043 |
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
|
1044 |
FOR_EACH_OBJECT statspec[i]->blocked = grf_load_byte(&buf); |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1045 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1046 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1047 |
default: |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1048 |
ret = true; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1049 |
break; |
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 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1052 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1053 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1054 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1055 |
|
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
|
1056 |
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
|
1057 |
{ |
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
|
1058 |
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
|
1059 |
int i; |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1060 |
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
|
1061 |
|
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
|
1062 |
switch (prop) { |
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
|
1063 |
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
|
1064 |
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
|
1065 |
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
|
1066 |
|
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
|
1067 |
case 0x09: /* Minimum length */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1068 |
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
|
1069 |
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
|
1070 |
|
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
|
1071 |
case 0x0A: /* Maximum length */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1072 |
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
|
1073 |
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
|
1074 |
|
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
|
1075 |
case 0x0B: /* Cost factor */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1076 |
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
|
1077 |
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
|
1078 |
|
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
|
1079 |
case 0x0C: /* Maximum speed */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1080 |
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
|
1081 |
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
|
1082 |
|
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
|
1083 |
case 0x0D: /* Bridge sprite tables */ |
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
|
1084 |
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
|
1085 |
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
|
1086 |
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
|
1087 |
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
|
1088 |
|
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
|
1089 |
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
|
1090 |
/* 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
|
1091 |
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
|
1092 |
} |
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
|
1093 |
|
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
|
1094 |
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
|
1095 |
byte sprite; |
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
|
1096 |
|
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
|
1097 |
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
|
1098 |
grfmsg(1, "BridgeChangeInfo: Table %d >= 7, skipping", tableid); |
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
|
1099 |
for (sprite = 0; sprite < 32; sprite++) grf_load_dword(&buf); |
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
|
1100 |
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
|
1101 |
} |
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
|
1102 |
|
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
|
1103 |
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
|
1104 |
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
|
1105 |
} |
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
|
1106 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1107 |
for (sprite = 0; sprite < 32; sprite++) { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1108 |
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
|
1109 |
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
|
1110 |
|
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1111 |
if (HASBIT(pal, 15)) { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1112 |
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1113 |
} |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1114 |
|
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1115 |
/* Clear old color modifer bit */ |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1116 |
CLRBIT(image, 15); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1117 |
|
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1118 |
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
|
1119 |
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
|
1120 |
} |
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
|
1121 |
} |
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
|
1122 |
} |
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
|
1123 |
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
|
1124 |
|
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
|
1125 |
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
|
1126 |
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
|
1127 |
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
|
1128 |
|
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
|
1129 |
case 0x0F: /* Long format year of availability (year since year 0) */ |
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
|
1130 |
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
|
1131 |
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
|
1132 |
|
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
|
1133 |
default: |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1134 |
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
|
1135 |
} |
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
|
1136 |
|
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
|
1137 |
*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
|
1138 |
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
|
1139 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1140 |
|
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1141 |
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
|
1142 |
{ |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1143 |
byte *buf = *bufp; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1144 |
int i; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1145 |
bool ret = false; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1146 |
|
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1147 |
switch (prop) { |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1148 |
case 0x08: /* Cost base factor */ |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1149 |
FOR_EACH_OBJECT { |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1150 |
byte factor = grf_load_byte(&buf); |
2508
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1151 |
uint price = gvid + i; |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1152 |
|
2508
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1153 |
if (price < NUM_PRICES) { |
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1154 |
SetPriceBaseMultiplier(price, factor); |
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1155 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1156 |
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
|
1157 |
} |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1158 |
} |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1159 |
break; |
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1160 |
|
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1161 |
case 0x0A: // Currency display names |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1162 |
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
|
1163 |
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
|
1164 |
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
|
1165 |
|
4504
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1166 |
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
|
1167 |
_currency_specs[curidx].name = newone; |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1168 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1169 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1170 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1171 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1172 |
case 0x0B: // Currency multipliers |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1173 |
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
|
1174 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1175 |
uint32 rate = grf_load_dword(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1176 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1177 |
if (curidx < NUM_CURRENCY) { |
4602
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1178 |
/* 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
|
1179 |
* 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
|
1180 |
* to be compatible */ |
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1181 |
_currency_specs[curidx].rate = rate / 1000; |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1182 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1183 |
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
|
1184 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1185 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1186 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1187 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1188 |
case 0x0C: // Currency options |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1189 |
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
|
1190 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1191 |
uint16 options = grf_load_word(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1192 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1193 |
if (curidx < NUM_CURRENCY) { |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1194 |
_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
|
1195 |
/* 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
|
1196 |
* 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
|
1197 |
_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
|
1198 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1199 |
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
|
1200 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1201 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1202 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1203 |
|
4602
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1204 |
case 0x0D: // Currency prefix symbol |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1205 |
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
|
1206 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1207 |
uint32 tempfix = grf_load_dword(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1208 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1209 |
if (curidx < NUM_CURRENCY) { |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1210 |
memcpy(_currency_specs[curidx].prefix,&tempfix,4); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1211 |
_currency_specs[curidx].prefix[4] = 0; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1212 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1213 |
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
|
1214 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1215 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1216 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1217 |
|
4602
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1218 |
case 0x0E: // Currency suffix symbol |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1219 |
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
|
1220 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1221 |
uint32 tempfix = grf_load_dword(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1222 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1223 |
if (curidx < NUM_CURRENCY) { |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1224 |
memcpy(&_currency_specs[curidx].suffix,&tempfix,4); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1225 |
_currency_specs[curidx].suffix[4] = 0; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1226 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1227 |
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
|
1228 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1229 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1230 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1231 |
|
4504
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1232 |
case 0x0F: // Euro introduction dates |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1233 |
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
|
1234 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1235 |
Year year_euro = grf_load_word(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1236 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1237 |
if (curidx < NUM_CURRENCY) { |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1238 |
_currency_specs[curidx].to_euro = year_euro; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1239 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1240 |
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
|
1241 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1242 |
} |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1243 |
break; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1244 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1245 |
case 0x09: // Cargo translation table |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1246 |
case 0x10: // 12 * 32 * B Snow line height table |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1247 |
default: |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1248 |
ret = true; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1249 |
} |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1250 |
|
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1251 |
*bufp = buf; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1252 |
return ret; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1253 |
} |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1254 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1255 |
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
|
1256 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1257 |
byte *buf = *bufp; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1258 |
int i; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1259 |
bool ret = false; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1260 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1261 |
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
|
1262 |
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
|
1263 |
return false; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1264 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1265 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1266 |
switch (prop) { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1267 |
case 0x08: /* Relative volume */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1268 |
FOR_EACH_OBJECT { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1269 |
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
|
1270 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1271 |
if (sound >= GetNumSounds()) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1272 |
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
|
1273 |
} else { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1274 |
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
|
1275 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1276 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1277 |
break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1278 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1279 |
case 0x09: /* Priority */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1280 |
FOR_EACH_OBJECT { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1281 |
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
|
1282 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1283 |
if (sound >= GetNumSounds()) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1284 |
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
|
1285 |
} else { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1286 |
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
|
1287 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1288 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1289 |
break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1290 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1291 |
case 0x0A: /* Override old sound */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1292 |
FOR_EACH_OBJECT { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1293 |
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
|
1294 |
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
|
1295 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1296 |
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
|
1297 |
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
|
1298 |
} else { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1299 |
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
|
1300 |
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
|
1301 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1302 |
/* 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
|
1303 |
*oldfe = *newfe; |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1304 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1305 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1306 |
break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1307 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1308 |
default: |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1309 |
ret = true; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1310 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1311 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1312 |
*bufp = buf; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1313 |
return ret; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1314 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1315 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1316 |
/* Action 0x00 */ |
3879
cfa3cf4731d2
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1317 |
static void FeatureChangeInfo(byte *buf, int len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1318 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1319 |
byte *bufend = buf + len; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1320 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1321 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1322 |
/* <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
|
1323 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1324 |
* 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
|
1325 |
* 4 for defining new train station sets |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1326 |
* 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
|
1327 |
* 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
|
1328 |
* 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
|
1329 |
* greater than one, this one and the following |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1330 |
* vehicles/stations will be changed |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1331 |
* 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
|
1332 |
* 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
|
1333 |
/* TODO: Bridges, town houses. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1334 |
|
2438
f0bf4adbd620
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
1335 |
static const VCI_Handler handler[] = { |
3825 | 1336 |
/* GSF_TRAIN */ RailVehicleChangeInfo, |
1337 |
/* GSF_ROAD */ RoadVehicleChangeInfo, |
|
1338 |
/* GSF_SHIP */ ShipVehicleChangeInfo, |
|
1339 |
/* GSF_AIRCRAFT */ AircraftVehicleChangeInfo, |
|
1340 |
/* GSF_STATION */ StationChangeInfo, |
|
1341 |
/* GSF_CANAL */ NULL, |
|
1342 |
/* GSF_BRIDGE */ BridgeChangeInfo, |
|
1343 |
/* GSF_TOWNHOUSE */ NULL, |
|
1344 |
/* GSF_GLOBALVAR */ GlobalVarChangeInfo, |
|
1345 |
/* GSF_INDUSTRYTILES */NULL, |
|
1346 |
/* GSF_INDUSTRIES */ NULL, |
|
4138
8640f25e2510
(svn r5496) -CodeChange: Removed two compiler warnings
belugas
parents:
4077
diff
changeset
|
1347 |
/* GSF_CARGOS */ NULL, |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1348 |
/* GSF_SOUNDFX */ SoundEffectChangeInfo, |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1349 |
}; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1350 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1351 |
uint8 feature; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1352 |
uint8 numprops; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1353 |
uint8 numinfo; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1354 |
byte engine; |
542 | 1355 |
EngineInfo *ei = NULL; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1356 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1357 |
if (len == 1) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1358 |
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
|
1359 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1360 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1361 |
|
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
|
1362 |
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
|
1363 |
buf++; |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1364 |
feature = grf_load_byte(&buf); |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1365 |
numprops = grf_load_byte(&buf); |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1366 |
numinfo = grf_load_byte(&buf); |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1367 |
engine = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1368 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1369 |
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
|
1370 |
feature, numprops, engine, numinfo); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1371 |
|
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
|
1372 |
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
|
1373 |
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
|
1374 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1375 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1376 |
|
2439
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1377 |
if (feature <= GSF_AIRCRAFT) { |
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1378 |
if (engine + numinfo > _vehcounts[feature]) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1379 |
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
|
1380 |
return; |
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1381 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1382 |
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
|
1383 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1384 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1385 |
while (numprops-- && buf < bufend) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1386 |
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
|
1387 |
bool ignoring = false; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1388 |
|
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1389 |
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
|
1390 |
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
|
1391 |
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
|
1392 |
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
|
1393 |
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
|
1394 |
/* 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
|
1395 |
switch (prop) { |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1396 |
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
|
1397 |
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
|
1398 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1399 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1400 |
case 0x02: /* Decay speed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1401 |
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
|
1402 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1403 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1404 |
case 0x03: /* Vehicle life */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1405 |
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
|
1406 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1407 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1408 |
case 0x04: /* Model life */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1409 |
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
|
1410 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1411 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1412 |
case 0x06: /* Climates available */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1413 |
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
|
1414 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1415 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1416 |
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
|
1417 |
/* 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
|
1418 |
* 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
|
1419 |
* credit ;-). --pasky */ |
5211
fb4dc0ca975d
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents:
5210
diff
changeset
|
1420 |
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
|
1421 |
break; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1422 |
|
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1423 |
default: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1424 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1425 |
ignoring = true; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1426 |
break; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1427 |
} |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1428 |
break; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1429 |
|
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1430 |
default: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1431 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1432 |
ignoring = true; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1433 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1434 |
} |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1435 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1436 |
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
|
1437 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1438 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1439 |
|
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
|
1440 |
/* 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
|
1441 |
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
|
1442 |
{ |
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
|
1443 |
uint8 feature; |
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
|
1444 |
uint8 numprops; |
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
|
1445 |
uint8 numinfo; |
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
|
1446 |
uint8 index; |
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
|
1447 |
|
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
|
1448 |
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
|
1449 |
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
|
1450 |
feature = 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
|
1451 |
numprops = 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
|
1452 |
numinfo = 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
|
1453 |
index = 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
|
1454 |
|
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
|
1455 |
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
|
1456 |
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
|
1457 |
/* 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
|
1458 |
* 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
|
1459 |
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
|
1460 |
} |
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
|
1461 |
|
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
|
1462 |
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
|
1463 |
|
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
|
1464 |
/* 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
|
1465 |
_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
|
1466 |
} |
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
|
1467 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1468 |
#undef FOR_EACH_OBJECT |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1469 |
|
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1470 |
/** |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1471 |
* Creates a spritegroup representing a callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1472 |
* @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
|
1473 |
* @return A spritegroup representing that callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1474 |
*/ |
4893
000692659d8c
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
1475 |
static const SpriteGroup* NewCallBackResultSpriteGroup(uint16 value) |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1476 |
{ |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
1477 |
SpriteGroup *group = AllocateSpriteGroup(); |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1478 |
|
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1479 |
group->type = SGT_CALLBACK; |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1480 |
|
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1481 |
// Old style callback results have the highest byte 0xFF so signify it is a callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1482 |
// 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
|
1483 |
if ((value >> 8) == 0xFF) { |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1484 |
value &= ~0xFF00; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1485 |
} else { |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1486 |
value &= ~0x8000; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1487 |
} |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1488 |
|
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1489 |
group->g.callback.result = value; |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1490 |
|
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1491 |
return group; |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1492 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1493 |
|
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
|
1494 |
/** |
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
|
1495 |
* Creates a spritegroup representing a 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
|
1496 |
* @param value The sprite number. |
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
|
1497 |
* @param sprites The number of sprites per set. |
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
|
1498 |
* @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
|
1499 |
*/ |
4893
000692659d8c
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
1500 |
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
|
1501 |
{ |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
1502 |
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
|
1503 |
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
|
1504 |
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
|
1505 |
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
|
1506 |
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
|
1507 |
} |
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
|
1508 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1509 |
/* Action 0x01 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1510 |
static void NewSpriteSet(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1511 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1512 |
/* <01> <feature> <num-sets> <num-ent> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1513 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1514 |
* B feature feature to define sprites for |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1515 |
* 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
|
1516 |
* B num-sets number of sprite sets |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1517 |
* 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
|
1518 |
* For vehicles, this is the number of different |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1519 |
* vehicle directions in each sprite set |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1520 |
* 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
|
1521 |
* In that case, use num-dirs=4. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1522 |
* For stations, must be 12 (hex) for the eighteen |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1523 |
* different sprites that make up a station */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1524 |
/* TODO: No stations support. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1525 |
uint8 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
|
1526 |
uint 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
|
1527 |
uint 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
|
1528 |
uint i; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1529 |
|
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
|
1530 |
if (!check_length(len, 4, "NewSpriteSet")) return; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1531 |
buf++; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1532 |
feature = grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1533 |
num_sets = grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1534 |
num_ents = grf_load_extended(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1535 |
|
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
|
1536 |
_cur_grffile->spriteset_start = _cur_spriteid; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1537 |
_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
|
1538 |
_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
|
1539 |
_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
|
1540 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1541 |
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
|
1542 |
_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
|
1543 |
); |
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
|
1544 |
|
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
|
1545 |
for (i = 0; i < num_sets * num_ents; 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
|
1546 |
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
|
1547 |
_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
|
1548 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1549 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1550 |
|
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
|
1551 |
/* 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
|
1552 |
* defined spritegroup. */ |
4893
000692659d8c
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
1553 |
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
|
1554 |
{ |
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
|
1555 |
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
|
1556 |
|
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
|
1557 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1558 |
grfmsg(1, "NewSpriteGroup(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
|
1559 |
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
|
1560 |
} |
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
|
1561 |
|
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
|
1562 |
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
|
1563 |
} |
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
|
1564 |
|
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
|
1565 |
/* 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
|
1566 |
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
|
1567 |
{ |
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
|
1568 |
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
|
1569 |
|
3667
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1570 |
if (spriteid >= _cur_grffile->spriteset_numsets) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1571 |
grfmsg(1, "NewSpriteGroup(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
|
1572 |
return NULL; |
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1573 |
} |
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1574 |
|
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
|
1575 |
/* 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
|
1576 |
* 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
|
1577 |
* 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
|
1578 |
if (_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites > _cur_spriteid) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1579 |
grfmsg(1, "NewSpriteGroup(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
|
1580 |
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
|
1581 |
_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
|
1582 |
_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
|
1583 |
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
|
1584 |
} |
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
|
1585 |
|
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1586 |
if (feature != _cur_grffile->spriteset_feature) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1587 |
grfmsg(1, "NewSpriteGroup(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
|
1588 |
_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
|
1589 |
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
|
1590 |
} |
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1591 |
|
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
|
1592 |
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
|
1593 |
} |
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
|
1594 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1595 |
/* Action 0x02 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1596 |
static void NewSpriteGroup(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1597 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1598 |
/* <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
|
1599 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1600 |
* B feature see action 1 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1601 |
* B set-id ID of this particular definition |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1602 |
* B type/num-entries |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1603 |
* 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
|
1604 |
* list definition, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1605 |
* 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
|
1606 |
* meaning depends on the feature |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1607 |
* V feature-specific-data (huge mess, don't even look it up --pasky) */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1608 |
uint8 feature; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1609 |
uint8 setid; |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1610 |
uint8 type; |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1611 |
SpriteGroup *group = NULL; |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1612 |
byte *bufend = buf + len; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1613 |
|
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
|
1614 |
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
|
1615 |
buf++; |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1616 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1617 |
feature = grf_load_byte(&buf); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1618 |
setid = grf_load_byte(&buf); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1619 |
type = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1620 |
|
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
|
1621 |
if (setid >= _cur_grffile->spritegroups_count) { |
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1622 |
// 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
|
1623 |
_cur_grffile->spritegroups = ReallocT(_cur_grffile->spritegroups, setid + 1); |
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1624 |
// Initialise new space to NULL |
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1625 |
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
|
1626 |
_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
|
1627 |
} |
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
|
1628 |
|
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1629 |
switch (type) { |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1630 |
/* Deterministic Sprite Group */ |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1631 |
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
|
1632 |
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
|
1633 |
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
|
1634 |
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
|
1635 |
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
|
1636 |
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
|
1637 |
{ |
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
|
1638 |
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
|
1639 |
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
|
1640 |
uint i; |
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
|
1641 |
|
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
|
1642 |
/* 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
|
1643 |
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
|
1644 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1645 |
group = AllocateSpriteGroup(); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1646 |
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
|
1647 |
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
|
1648 |
|
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
|
1649 |
switch (GB(type, 2, 2)) { |
3672
f626ea3c9994
(svn r4588) - NewGRF: silence a false compiler warning
peter1138
parents:
3668
diff
changeset
|
1650 |
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
|
1651 |
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
|
1652 |
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
|
1653 |
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
|
1654 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1655 |
|
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
|
1656 |
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
|
1657 |
|
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
|
1658 |
/* 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
|
1659 |
* 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
|
1660 |
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
|
1661 |
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
|
1662 |
|
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
|
1663 |
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
|
1664 |
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
|
1665 |
} |
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
|
1666 |
|
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
|
1667 |
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
|
1668 |
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
|
1669 |
|
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
|
1670 |
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
|
1671 |
|
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
|
1672 |
/* 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
|
1673 |
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
|
1674 |
adjust->variable = grf_load_byte(&buf); |
5617
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
1675 |
if (adjust->variable == 0x7E) { |
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
1676 |
/* Link subroutine group */ |
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
1677 |
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
|
1678 |
} else { |
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
1679 |
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
|
1680 |
} |
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
|
1681 |
|
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
|
1682 |
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
|
1683 |
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
|
1684 |
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
|
1685 |
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
|
1686 |
|
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
|
1687 |
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
|
1688 |
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
|
1689 |
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
|
1690 |
} 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
|
1691 |
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
|
1692 |
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
|
1693 |
} |
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
|
1694 |
|
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
|
1695 |
/* 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
|
1696 |
} 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
|
1697 |
|
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
|
1698 |
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
|
1699 |
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
|
1700 |
|
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
|
1701 |
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
|
1702 |
|
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
|
1703 |
for (i = 0; i < group->g.determ.num_ranges; i++) { |
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
|
1704 |
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
|
1705 |
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
|
1706 |
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
|
1707 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1708 |
|
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
|
1709 |
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
|
1710 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1711 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1712 |
|
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1713 |
/* Randomized Sprite Group */ |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1714 |
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
|
1715 |
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
|
1716 |
{ |
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
|
1717 |
byte triggers; |
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
|
1718 |
uint i; |
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
|
1719 |
|
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
|
1720 |
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
|
1721 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1722 |
group = AllocateSpriteGroup(); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1723 |
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
|
1724 |
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
|
1725 |
|
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
|
1726 |
triggers = 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
|
1727 |
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
|
1728 |
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
|
1729 |
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
|
1730 |
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
|
1731 |
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
|
1732 |
|
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
|
1733 |
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
|
1734 |
|
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
|
1735 |
for (i = 0; i < group->g.random.num_groups; i++) { |
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
|
1736 |
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
|
1737 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1738 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1739 |
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
|
1740 |
} |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1741 |
|
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
|
1742 |
/* 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
|
1743 |
default: |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1744 |
{ |
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1745 |
|
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1746 |
|
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
|
1747 |
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
|
1748 |
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
|
1749 |
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
|
1750 |
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
|
1751 |
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
|
1752 |
case GSF_STATION: |
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
|
1753 |
{ |
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
|
1754 |
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
|
1755 |
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
|
1756 |
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
|
1757 |
uint i; |
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
|
1758 |
|
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
|
1759 |
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
|
1760 |
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
|
1761 |
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
|
1762 |
} |
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
|
1763 |
|
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
|
1764 |
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
|
1765 |
|
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
|
1766 |
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
|
1767 |
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
|
1768 |
|
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
|
1769 |
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
|
1770 |
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
|
1771 |
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
|
1772 |
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
|
1773 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1774 |
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
|
1775 |
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
|
1776 |
|
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
|
1777 |
for (i = 0; i < num_loaded; i++) { |
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
|
1778 |
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
|
1779 |
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
|
1780 |
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
|
1781 |
} |
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
|
1782 |
|
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
|
1783 |
for (i = 0; i < num_loading; i++) { |
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
|
1784 |
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
|
1785 |
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
|
1786 |
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
|
1787 |
} |
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
|
1788 |
|
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
|
1789 |
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
|
1790 |
} |
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
|
1791 |
|
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
|
1792 |
/* 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
|
1793 |
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
|
1794 |
} |
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
|
1795 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1796 |
} |
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
|
1797 |
|
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
|
1798 |
_cur_grffile->spritegroups[setid] = group; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1799 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1800 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1801 |
/* Action 0x03 */ |
3879
cfa3cf4731d2
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1802 |
static void FeatureMapSpriteGroup(byte *buf, int len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1803 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1804 |
/* <03> <feature> <n-id> <ids>... <num-cid> [<cargo-type> <cid>]... <def-cid> |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4381
diff
changeset
|
1805 |
* id-list := [<id>] [id-list] |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4381
diff
changeset
|
1806 |
* cargo-list := <cargo-type> <cid> [cargo-list] |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1807 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1808 |
* B feature see action 0 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1809 |
* B n-id bits 0-6: how many IDs this definition applies to |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1810 |
* bit 7: if set, this is a wagon override definition (see below) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1811 |
* B ids the IDs for which this definition applies |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1812 |
* B num-cid number of cargo IDs (sprite group IDs) in this definition |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1813 |
* can be zero, in that case the def-cid is used always |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1814 |
* B cargo-type type of this cargo type (e.g. mail=2, wood=7, see below) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1815 |
* W cid cargo ID (sprite group ID) for this type of cargo |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1816 |
* W def-cid default cargo ID (sprite group ID) */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1817 |
/* TODO: Bridges, town houses. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1818 |
/* TODO: Multiple cargo support could be useful even for trains/cars - |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1819 |
* cargo id 0xff is used for showing images in the build train list. */ |
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 |
static byte *last_engines; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1822 |
static int last_engines_count; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1823 |
uint8 feature; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1824 |
uint8 idcount; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1825 |
bool wagover; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1826 |
uint8 cidcount; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1827 |
int c, i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1828 |
|
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
|
1829 |
if (!check_length(len, 6, "FeatureMapSpriteGroup")) return; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1830 |
feature = buf[1]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1831 |
idcount = buf[2] & 0x7F; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1832 |
wagover = (buf[2] & 0x80) == 0x80; |
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
|
1833 |
if (!check_length(len, 3 + idcount, "FeatureMapSpriteGroup")) return; |
3783
0199c4b70cc2
(svn r4777) - NewGRF: moving warning message about feature callbacks above station code and change minimum length for action 3 from 7 to 6 bytes.
peter1138
parents:
3777
diff
changeset
|
1834 |
|
0199c4b70cc2
(svn r4777) - NewGRF: moving warning message about feature callbacks above station code and change minimum length for action 3 from 7 to 6 bytes.
peter1138
parents:
3777
diff
changeset
|
1835 |
/* If ``n-id'' (or ``idcount'') is zero, this is a ``feature |
0199c4b70cc2
(svn r4777) - NewGRF: moving warning message about feature callbacks above station code and change minimum length for action 3 from 7 to 6 bytes.
peter1138
parents:
3777
diff
changeset
|
1836 |
* callback''. */ |
0199c4b70cc2
(svn r4777) - NewGRF: moving warning message about feature callbacks above station code and change minimum length for action 3 from 7 to 6 bytes.
peter1138
parents:
3777
diff
changeset
|
1837 |
if (idcount == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1838 |
grfmsg(2, "FeatureMapSpriteGroup: Feature callbacks not implemented yet"); |
3783
0199c4b70cc2
(svn r4777) - NewGRF: moving warning message about feature callbacks above station code and change minimum length for action 3 from 7 to 6 bytes.
peter1138
parents:
3777
diff
changeset
|
1839 |
return; |
0199c4b70cc2
(svn r4777) - NewGRF: moving warning message about feature callbacks above station code and change minimum length for action 3 from 7 to 6 bytes.
peter1138
parents:
3777
diff
changeset
|
1840 |
} |
0199c4b70cc2
(svn r4777) - NewGRF: moving warning message about feature callbacks above station code and change minimum length for action 3 from 7 to 6 bytes.
peter1138
parents:
3777
diff
changeset
|
1841 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1842 |
cidcount = buf[3 + idcount]; |
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
|
1843 |
if (!check_length(len, 4 + idcount + cidcount * 3, "FeatureMapSpriteGroup")) return; |
3879
cfa3cf4731d2
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1844 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1845 |
grfmsg(6, "FeatureMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1846 |
feature, idcount, cidcount, wagover); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1847 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1848 |
if (feature > GSF_STATION) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1849 |
grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature %d, skipping", feature); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1850 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1851 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1852 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1853 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1854 |
if (feature == GSF_STATION) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1855 |
// We do things differently for stations. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1856 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1857 |
for (i = 0; i < idcount; i++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1858 |
uint8 stid = buf[3 + 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
|
1859 |
StationSpec *statspec = _cur_grffile->stations[stid]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1860 |
byte *bp = &buf[4 + idcount]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1861 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1862 |
for (c = 0; c < cidcount; c++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1863 |
uint8 ctype = grf_load_byte(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1864 |
uint16 groupid = grf_load_word(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1865 |
|
2516
4659ceee4dcb
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1866 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1867 |
grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1868 |
groupid, _cur_grffile->spritegroups_count); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1869 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1870 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1871 |
|
3750
ffe5ba5de494
(svn r4738) - Newstations: attach all sprite group cargo types, not just the default and purchase pseudo types, to a station spec.
peter1138
parents:
3740
diff
changeset
|
1872 |
if (ctype == 0xFE) ctype = GC_DEFAULT_NA; |
ffe5ba5de494
(svn r4738) - Newstations: attach all sprite group cargo types, not just the default and purchase pseudo types, to a station spec.
peter1138
parents:
3740
diff
changeset
|
1873 |
if (ctype == 0xFF) ctype = GC_PURCHASE; |
ffe5ba5de494
(svn r4738) - Newstations: attach all sprite group cargo types, not just the default and purchase pseudo types, to a station spec.
peter1138
parents:
3740
diff
changeset
|
1874 |
|
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
|
1875 |
if (ctype >= NUM_GLOBAL_CID) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1876 |
grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); |
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
|
1877 |
continue; |
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
|
1878 |
} |
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
|
1879 |
|
3750
ffe5ba5de494
(svn r4738) - Newstations: attach all sprite group cargo types, not just the default and purchase pseudo types, to a station spec.
peter1138
parents:
3740
diff
changeset
|
1880 |
statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1881 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1882 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1883 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1884 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1885 |
byte *bp = buf + 4 + idcount + cidcount * 3; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1886 |
uint16 groupid = grf_load_word(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1887 |
|
2516
4659ceee4dcb
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1888 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1889 |
grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1890 |
groupid, _cur_grffile->spritegroups_count); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1891 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1892 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1893 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1894 |
for (i = 0; i < idcount; i++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1895 |
uint8 stid = buf[3 + 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
|
1896 |
StationSpec *statspec = _cur_grffile->stations[stid]; |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1897 |
|
3750
ffe5ba5de494
(svn r4738) - Newstations: attach all sprite group cargo types, not just the default and purchase pseudo types, to a station spec.
peter1138
parents:
3740
diff
changeset
|
1898 |
statspec->spritegroup[GC_DEFAULT] = _cur_grffile->spritegroups[groupid]; |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1899 |
statspec->grfid = _cur_grffile->grfid; |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1900 |
statspec->localidx = stid; |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1901 |
SetCustomStationSpec(statspec); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1902 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1903 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1904 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1905 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1906 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1907 |
// FIXME: Tropicset contains things like: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1908 |
// 03 00 01 19 01 00 00 00 00 - this is missing one 00 at the end, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1909 |
// what should we exactly do with that? --pasky |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1910 |
|
3635
26da0c860a64
(svn r4540) - NewGRF: don't treat integer values as boolean.
peter1138
parents:
3634
diff
changeset
|
1911 |
if (_cur_grffile->spriteset_start == 0 || _cur_grffile->spritegroups == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1912 |
grfmsg(1, "FeatureMapSpriteGroup: No sprite set to work on! Skipping"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1913 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1914 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1915 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1916 |
if (!wagover && last_engines_count != idcount) { |
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
|
1917 |
last_engines = ReallocT(last_engines, idcount); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1918 |
last_engines_count = idcount; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1919 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1920 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1921 |
if (wagover) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1922 |
if (last_engines_count == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1923 |
grfmsg(0, "FeatureMapSpriteGroup: WagonOverride: No engine to do override with"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1924 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1925 |
} |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1926 |
grfmsg(6, "FeatureMapSpriteGroup: WagonOverride: %u engines, %u wagons", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1927 |
last_engines_count, idcount); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1928 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1929 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1930 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1931 |
for (i = 0; i < idcount; i++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1932 |
uint8 engine_id = buf[3 + i]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1933 |
uint8 engine = engine_id + _vehshifts[feature]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1934 |
byte *bp = &buf[4 + idcount]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1935 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1936 |
if (engine_id > _vehcounts[feature]) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1937 |
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
|
1938 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1939 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1940 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1941 |
grfmsg(7, "FeatureMapSpriteGroup: [%d] Engine %d...", i, engine); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1942 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1943 |
for (c = 0; c < cidcount; c++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1944 |
uint8 ctype = grf_load_byte(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1945 |
uint16 groupid = grf_load_word(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1946 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1947 |
grfmsg(8, "FeatureMapSpriteGroup: * [%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
|
1948 |
|
2516
4659ceee4dcb
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1949 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1950 |
grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1951 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1952 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1953 |
|
1802
da61740cc1e7
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1611
diff
changeset
|
1954 |
if (ctype == GC_INVALID) ctype = GC_PURCHASE; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1955 |
|
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
|
1956 |
if (ctype >= NUM_GLOBAL_CID) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1957 |
grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); |
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
|
1958 |
continue; |
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
|
1959 |
} |
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
|
1960 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1961 |
if (wagover) { |
4869
3a75d9b3b5ea
(svn r6795) - NewGRF: Add support for cargo-specific wagon overrides.
peter1138
parents:
4818
diff
changeset
|
1962 |
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
|
1963 |
} 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
|
1964 |
SetCustomEngineSprites(engine, ctype, _cur_grffile->spritegroups[groupid]); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1965 |
last_engines[i] = engine; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1966 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1967 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1968 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1969 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1970 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1971 |
byte *bp = buf + 4 + idcount + cidcount * 3; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1972 |
uint16 groupid = grf_load_word(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1973 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1974 |
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
|
1975 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1976 |
for (i = 0; i < idcount; i++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1977 |
uint8 engine = buf[3 + i] + _vehshifts[feature]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1978 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1979 |
// 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
|
1980 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1981 |
grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1982 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1983 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1984 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1985 |
if (wagover) { |
3695
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1986 |
/* If the ID for this action 3 is the same as the vehicle ID, |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1987 |
* this indicates we have a helicopter rotor override. */ |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1988 |
if (feature == GSF_AIRCRAFT && engine == last_engines[i]) { |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1989 |
SetRotorOverrideSprites(engine, _cur_grffile->spritegroups[groupid]); |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1990 |
} else { |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1991 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
4869
3a75d9b3b5ea
(svn r6795) - NewGRF: Add support for cargo-specific wagon overrides.
peter1138
parents:
4818
diff
changeset
|
1992 |
SetWagonOverrideSprites(engine, GC_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
|
1993 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1994 |
} 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
|
1995 |
SetCustomEngineSprites(engine, GC_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
|
1996 |
SetEngineGRF(engine, _cur_grffile); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1997 |
last_engines[i] = engine; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1998 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1999 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2000 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2001 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2002 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2003 |
/* Action 0x04 */ |
3879
cfa3cf4731d2
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
2004 |
static void FeatureNewName(byte *buf, int len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2005 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2006 |
/* <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
|
2007 |
* |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2008 |
* B veh-type see action 0 (as 00..07, + 0A |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2009 |
* But IF veh-type = 48, then generic text |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2010 |
* 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
|
2011 |
with up to 64 language. |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2012 |
Otherwise, it is a mapping where set bits have meaning |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2013 |
0 = american, 1 = english, 2 = german, 3 = french, 4 = spanish |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2014 |
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
|
2015 |
* 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
|
2016 |
* 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
|
2017 |
* Byte : ID of vehicle to change |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2018 |
* Word : ID of string to change/add |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2019 |
* 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
|
2020 |
* which the next name begins. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2021 |
/* TODO: No support for changing non-vehicle text. Perhaps we shouldn't |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2022 |
* implement it at all, but it could be useful for some "modpacks" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2023 |
* (completely new scenarios changing all graphics and logically also |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2024 |
* factory names etc). We should then also support all languages (by |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2025 |
* name), not only the original four ones. --pasky |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2026 |
* All of the above are coming. In Time. Some sooner than others :)*/ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2027 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2028 |
uint8 feature; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2029 |
uint8 lang; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2030 |
uint8 num; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2031 |
uint16 id; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2032 |
uint16 endid; |
1329 | 2033 |
const char* name; |
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
|
2034 |
bool new_scheme = _cur_grffile->grf_version >= 7; |
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
|
2035 |
bool generic; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2036 |
|
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
|
2037 |
if (!check_length(len, 6, "FeatureNewName")) return; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2038 |
buf++; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2039 |
feature = grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2040 |
lang = grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2041 |
num = 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
|
2042 |
generic = HASBIT(lang, 7); |
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
|
2043 |
id = generic ? grf_load_word(&buf) : grf_load_byte(&buf); |
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
|
2044 |
|
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
|
2045 |
CLRBIT(lang, 7); |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2046 |
|
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
|
2047 |
if (feature <= GSF_AIRCRAFT && id < _vehcounts[feature]) { |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2048 |
id += _vehshifts[feature]; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2049 |
} |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2050 |
endid = id + num; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2051 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2052 |
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
|
2053 |
id, endid, feature, lang); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2054 |
|
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2055 |
name = (const char*)buf; /*transfer read value*/ |
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
|
2056 |
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
|
2057 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2058 |
for (; id < endid && len > 0; id++) { |
2458
dbaf5dffbb28
(svn r2984) Use adequate types, this should aid portability a bit
tron
parents:
2456
diff
changeset
|
2059 |
size_t ofs = strlen(name) + 1; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2060 |
|
4711
28fbbec5f258
(svn r6623) - Codechange: When adding a NewGRF string, check to see if it can replace an existing string. Also remove string length check on load which was a quickfix for some grfs.
peter1138
parents:
4657
diff
changeset
|
2061 |
if (ofs < 128) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2062 |
grfmsg(8, "FeatureNewName: %d <- %s", id, name); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2063 |
|
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2064 |
switch (feature) { |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2065 |
case GSF_TRAIN: |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2066 |
case GSF_ROAD: |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2067 |
case GSF_SHIP: |
3614 | 2068 |
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
|
2069 |
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
|
2070 |
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
|
2071 |
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
|
2072 |
} 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
|
2073 |
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
|
2074 |
} |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2075 |
break; |
3614 | 2076 |
} |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2077 |
|
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
|
2078 |
default: |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2079 |
switch (GB(id, 8, 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
|
2080 |
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
|
2081 |
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
|
2082 |
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
|
2083 |
} 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
|
2084 |
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
|
2085 |
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
|
2086 |
} |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2087 |
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
|
2088 |
|
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
|
2089 |
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
|
2090 |
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
|
2091 |
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
|
2092 |
} 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
|
2093 |
_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
|
2094 |
} |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2095 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2096 |
|
4504
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2097 |
case 0xC9: |
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2098 |
case 0xD0: |
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2099 |
case 0xDC: |
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2100 |
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
|
2101 |
break; |
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2102 |
|
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2103 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2104 |
grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2105 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2106 |
} |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2107 |
break; |
3642
8da309b5fd2b
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
2108 |
|
8da309b5fd2b
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
2109 |
#if 0 |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2110 |
case GSF_CANAL : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2111 |
case GSF_BRIDGE : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2112 |
case GSF_TOWNHOUSE : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2113 |
AddGRFString(_cur_spriteid, id, lang, name); |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2114 |
switch (GB(id, 8,8)) { |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2115 |
case 0xC9: /* House name */ |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2116 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2117 |
grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2118 |
} |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2119 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2120 |
|
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2121 |
case GSF_INDUSTRIES : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2122 |
case 0x48 : /* for generic strings */ |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2123 |
AddGRFString(_cur_spriteid, id, lang, name); |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2124 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2125 |
default : |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2126 |
grfmsg(7, "FeatureNewName: Unsupported feature (0x%02X)", feature); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2127 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2128 |
#endif |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2129 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2130 |
} else { |
3863
d1738224e7ec
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
peter1138
parents:
3862
diff
changeset
|
2131 |
/* ofs is the string length + 1, so if the string is empty, ofs |
d1738224e7ec
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
peter1138
parents:
3862
diff
changeset
|
2132 |
* is 1 */ |
d1738224e7ec
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
peter1138
parents:
3862
diff
changeset
|
2133 |
if (ofs == 1) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2134 |
grfmsg(7, "FeatureNewName: Can't add empty name"); |
3863
d1738224e7ec
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
peter1138
parents:
3862
diff
changeset
|
2135 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2136 |
grfmsg(7, "FeatureNewName: Too long a name (%d)", ofs); |
3863
d1738224e7ec
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
peter1138
parents:
3862
diff
changeset
|
2137 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2138 |
} |
1329 | 2139 |
name += ofs; |
4321
958a8e9c012b
(svn r5974) -Codechange: added casts all around the place to make Windows 64bit happy (michi_cc)
truelight
parents:
4297
diff
changeset
|
2140 |
len -= (int)ofs; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2141 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2142 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2143 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2144 |
/* Action 0x05 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2145 |
static void GraphicsNew(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2146 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2147 |
/* <05> <graphics-type> <num-sprites> <other data...> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2148 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2149 |
* 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
|
2150 |
* 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
|
2151 |
* 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
|
2152 |
/* TODO */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2153 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2154 |
uint8 type; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2155 |
uint16 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
|
2156 |
SpriteID replace = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
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(len, 2, "GraphicsNew")) return; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2159 |
buf++; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2160 |
type = grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2161 |
num = grf_load_extended(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2162 |
|
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
|
2163 |
switch (type) { |
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
|
2164 |
case 0x04: /* Signal graphics */ |
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
|
2165 |
if (num != 112 && num != 240) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2166 |
grfmsg(1, "GraphicsNews: 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
|
2167 |
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
|
2168 |
} |
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
|
2169 |
_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
|
2170 |
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
|
2171 |
|
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
|
2172 |
case 0x05: /* Catenary graphics */ |
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
|
2173 |
if (num != 48) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2174 |
grfmsg(1, "GraphicsNews: 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
|
2175 |
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
|
2176 |
} |
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
|
2177 |
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
|
2178 |
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
|
2179 |
|
3709
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2180 |
case 0x06: /* Foundations */ |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2181 |
if (num != 74) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2182 |
grfmsg(1, "GraphicsNews: 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
|
2183 |
return; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2184 |
} |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2185 |
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
|
2186 |
break; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2187 |
|
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2188 |
case 0x08: /* Canal graphics */ |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2189 |
if (num != 65) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2190 |
grfmsg(1, "GraphicsNews: 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
|
2191 |
return; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2192 |
} |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2193 |
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
|
2194 |
break; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2195 |
|
5210
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2196 |
case 0x0D: /* Coast graphics */ |
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2197 |
if (num != 16) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2198 |
grfmsg(1, "GraphicsNews: 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
|
2199 |
return; |
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2200 |
} |
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2201 |
_coast_base = _cur_spriteid; |
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2202 |
break; |
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2203 |
|
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
|
2204 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2205 |
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
|
2206 |
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
|
2207 |
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
|
2208 |
} |
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
|
2209 |
|
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
|
2210 |
if (replace == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2211 |
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
|
2212 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2213 |
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
|
2214 |
} |
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
|
2215 |
|
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
|
2216 |
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
|
2217 |
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
|
2218 |
_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
|
2219 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2220 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2221 |
|
3806 | 2222 |
static uint32 GetParamVal(byte param, uint32 *cond_val) |
2223 |
{ |
|
2224 |
switch (param) { |
|
5340
8e534cd781cc
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5338
diff
changeset
|
2225 |
case 0x81: /* current year */ |
8e534cd781cc
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5338
diff
changeset
|
2226 |
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
|
2227 |
|
3806 | 2228 |
case 0x83: /* current climate, 0=temp, 1=arctic, 2=trop, 3=toyland */ |
2229 |
return _opt.landscape; |
|
2230 |
||
5161
e5ba90f4da6f
(svn r7266) -Codechange: Make the NewGRF loading stage look like ttdpatch to NewGRFs
peter1138
parents:
5115
diff
changeset
|
2231 |
case 0x84: /* GRF loading stage */ |
e5ba90f4da6f
(svn r7266) -Codechange: Make the NewGRF loading stage look like ttdpatch to NewGRFs
peter1138
parents:
5115
diff
changeset
|
2232 |
return (_cur_stage > GLS_INIT) | ((_cur_stage == GLS_ACTIVATION) << 9); |
3806 | 2233 |
|
3811
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2234 |
case 0x85: /* TTDPatch flags, only for bit tests */ |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2235 |
if (cond_val == NULL) { |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2236 |
/* Supported in Action 0x07 and 0x09, not 0x0D */ |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2237 |
return 0; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2238 |
} else { |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2239 |
uint32 param_val = _ttdpatch_flags[*cond_val / 0x20]; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2240 |
*cond_val %= 0x20; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2241 |
return param_val; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2242 |
} |
3806 | 2243 |
|
2244 |
case 0x86: /* road traffic side, bit 4 clear=left, set=right */ |
|
2245 |
return _opt.road_side << 4; |
|
2246 |
||
2247 |
case 0x88: /* GRF ID check */ |
|
2248 |
return 0; |
|
2249 |
||
2250 |
case 0x8B: { /* TTDPatch version */ |
|
2251 |
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
|
2252 |
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
|
2253 |
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
|
2254 |
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
|
2255 |
return (major << 24) | (minor << 20) | (revision << 16) | build; |
3806 | 2256 |
} |
2257 |
||
2258 |
case 0x8D: /* TTD Version, 00=DOS, 01=Windows */ |
|
2259 |
return !_use_dos_palette; |
|
2260 |
||
2261 |
case 0x8E: /* Y-offset for train sprites */ |
|
2262 |
return _traininfo_vehicle_pitch; |
|
2263 |
||
2264 |
case 0x92: /* Game mode */ |
|
2265 |
return _game_mode; |
|
2266 |
||
5287
917cc6407bda
(svn r7436) -Codechange: Add action7/9/D variable 0x9A (-1)
peter1138
parents:
5234
diff
changeset
|
2267 |
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
|
2268 |
return UINT_MAX; |
5287
917cc6407bda
(svn r7436) -Codechange: Add action7/9/D variable 0x9A (-1)
peter1138
parents:
5234
diff
changeset
|
2269 |
|
3806 | 2270 |
case 0x9D: /* TTD Platform, 00=TTDPatch, 01=OpenTTD */ |
2271 |
return 1; |
|
2272 |
||
3814
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2273 |
case 0x9E: /* Miscellaneous GRF features */ |
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2274 |
return _misc_grf_features; |
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2275 |
|
3806 | 2276 |
default: |
2277 |
/* GRF Parameter */ |
|
2278 |
if (param < 0x80) return _cur_grffile->param[param]; |
|
2279 |
||
2280 |
/* In-game variable. */ |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2281 |
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
|
2282 |
return UINT_MAX; |
3806 | 2283 |
} |
2284 |
} |
|
2285 |
||
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2286 |
/* Action 0x06 */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2287 |
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
|
2288 |
{ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2289 |
/* <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
|
2290 |
* |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2291 |
* 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
|
2292 |
* 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
|
2293 |
* 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
|
2294 |
* 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
|
2295 |
* 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
|
2296 |
* were specified. |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2297 |
* 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
|
2298 |
* 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
|
2299 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2300 |
/* Preload the next sprite */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2301 |
uint32 pos = FioGetPos(); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2302 |
uint16 num = FioReadWord(); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2303 |
uint8 type = FioReadByte(); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2304 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2305 |
/* 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
|
2306 |
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
|
2307 |
_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
|
2308 |
FioReadBlock(_preload_sprite, num); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2309 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2310 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2311 |
/* 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
|
2312 |
FioSeekTo(pos, SEEK_SET); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2313 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2314 |
if (type != 0xFF) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2315 |
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
|
2316 |
return; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2317 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2318 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2319 |
/* 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
|
2320 |
buf++; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2321 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2322 |
for (;;) { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2323 |
uint i; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2324 |
uint param_num; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2325 |
uint param_size; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2326 |
uint offset; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2327 |
bool add_value; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2328 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2329 |
/* 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
|
2330 |
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
|
2331 |
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
|
2332 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2333 |
/* 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
|
2334 |
* 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
|
2335 |
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
|
2336 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2337 |
/* 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
|
2338 |
* instead of replacing it. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2339 |
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
|
2340 |
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
|
2341 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2342 |
/* 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
|
2343 |
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
|
2344 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2345 |
/* 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
|
2346 |
* 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
|
2347 |
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
|
2348 |
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
|
2349 |
break; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2350 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2351 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2352 |
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
|
2353 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2354 |
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
|
2355 |
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
|
2356 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2357 |
if (add_value) { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2358 |
_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
|
2359 |
} else { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2360 |
_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
|
2361 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2362 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2363 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2364 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2365 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2366 |
/* Action 0x07 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2367 |
/* Action 0x09 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2368 |
static void SkipIf(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2369 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2370 |
/* <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
|
2371 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2372 |
* B param-num |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2373 |
* B param-size |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2374 |
* B condition-type |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2375 |
* V value |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2376 |
* B num-sprites */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2377 |
/* TODO: More params. More condition types. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2378 |
uint8 param; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2379 |
uint8 paramsize; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2380 |
uint8 condtype; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2381 |
uint8 numsprites; |
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
|
2382 |
uint32 param_val = 0; |
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
|
2383 |
uint32 cond_val = 0; |
3806 | 2384 |
uint32 mask = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2385 |
bool result; |
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
|
2386 |
GRFLabel *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
|
2387 |
GRFLabel *choice = NULL; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2388 |
|
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
|
2389 |
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
|
2390 |
buf++; |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
2391 |
param = grf_load_byte(&buf); |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
2392 |
paramsize = grf_load_byte(&buf); |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
2393 |
condtype = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2394 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2395 |
if (condtype < 2) { |
1611 | 2396 |
/* 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
|
2397 |
paramsize = 1; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2398 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2399 |
|
1611 | 2400 |
switch (paramsize) { |
3806 | 2401 |
case 4: cond_val = grf_load_dword(&buf); mask = 0xFFFFFFFF; break; |
2402 |
case 2: cond_val = grf_load_word(&buf); mask = 0x0000FFFF; break; |
|
2403 |
case 1: cond_val = grf_load_byte(&buf); mask = 0x000000FF; break; |
|
1611 | 2404 |
default: break; |
2405 |
} |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2406 |
|
3806 | 2407 |
if (param < 0x80 && _cur_grffile->param_end <= param) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2408 |
grfmsg(7, "Param %d undefined, skipping test", param); |
3806 | 2409 |
return; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2410 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2411 |
|
3806 | 2412 |
param_val = GetParamVal(param, &cond_val); |
2413 |
||
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2414 |
grfmsg(7, "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
|
2415 |
|
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
|
2416 |
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
|
2417 |
/* 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
|
2418 |
|
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
|
2419 |
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
|
2420 |
|
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
|
2421 |
if (condtype != 10 && c == NULL) { |
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
|
2422 |
grfmsg(7, "GRFID 0x%08X unknown, skipping test", BSWAP32(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
|
2423 |
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
|
2424 |
} |
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
|
2425 |
|
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
|
2426 |
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
|
2427 |
/* Tests 6 to 10 are only for param 0x88, GRFID 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
|
2428 |
case 6: /* Is GRFID active? */ |
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
|
2429 |
result = HASBIT(c->flags, GCF_ACTIVATED); |
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
|
2430 |
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
|
2431 |
|
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
|
2432 |
case 7: /* Is GRFID non-active? */ |
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
|
2433 |
result = !HASBIT(c->flags, GCF_ACTIVATED); |
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
|
2434 |
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
|
2435 |
|
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
|
2436 |
case 8: /* GRFID is not but will be active? */ |
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
|
2437 |
result = !HASBIT(c->flags, GCF_ACTIVATED) && !HASBIT(c->flags, GCF_DISABLED); |
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
|
2438 |
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
|
2439 |
|
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
|
2440 |
case 9: /* GRFID is or will be active? */ |
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
|
2441 |
result = !HASBIT(c->flags, GCF_NOT_FOUND) && !HASBIT(c->flags, GCF_DISABLED); |
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
|
2442 |
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
|
2443 |
|
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
|
2444 |
case 10: /* GRFID is not nor will be active */ |
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
|
2445 |
/* This is the only condtype that doesn't get ignored if the GRFID is not found */ |
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
|
2446 |
result = c == NULL || HASBIT(c->flags, GCF_DISABLED) || HASBIT(c->flags, GCF_NOT_FOUND); |
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
|
2447 |
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
|
2448 |
|
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
|
2449 |
default: grfmsg(1, "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
|
2450 |
} |
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
|
2451 |
} 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
|
2452 |
/* 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
|
2453 |
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
|
2454 |
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
|
2455 |
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
|
2456 |
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
|
2457 |
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
|
2458 |
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
|
2459 |
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
|
2460 |
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
|
2461 |
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
|
2462 |
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
|
2463 |
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
|
2464 |
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
|
2465 |
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
|
2466 |
|
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
|
2467 |
default: grfmsg(1, "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
|
2468 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2469 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2470 |
|
1607
fd027776f222
(svn r2111) So, result is bool therefore no need for this horrible == 0 thing.
pasky
parents:
1606
diff
changeset
|
2471 |
if (!result) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2472 |
grfmsg(2, "Not skipping sprites, test was false"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2473 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2474 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2475 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2476 |
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
|
2477 |
|
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
|
2478 |
/* 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
|
2479 |
* 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
|
2480 |
* 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
|
2481 |
* label in the file is used. */ |
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
|
2482 |
for (label = _cur_grffile->label; label != NULL; label = label->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
|
2483 |
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
|
2484 |
|
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
|
2485 |
/* 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
|
2486 |
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
|
2487 |
/* 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
|
2488 |
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
|
2489 |
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
|
2490 |
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
|
2491 |
} |
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
|
2492 |
} |
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
|
2493 |
|
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
|
2494 |
if (choice != NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2495 |
grfmsg(2, "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
|
2496 |
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
|
2497 |
_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
|
2498 |
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
|
2499 |
} |
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
|
2500 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2501 |
grfmsg(2, "Skipping %d sprites, test was true", numsprites); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2502 |
_skip_sprites = numsprites; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2503 |
if (_skip_sprites == 0) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2504 |
/* 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
|
2505 |
* we use -1 to indicate that all further |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2506 |
* sprites should be skipped. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2507 |
_skip_sprites = -1; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2508 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2509 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2510 |
|
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2511 |
|
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
|
2512 |
/* 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
|
2513 |
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
|
2514 |
{ |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2515 |
uint8 version; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2516 |
uint32 grfid; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2517 |
const char *name; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2518 |
const char *info; |
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2519 |
int name_len; |
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2520 |
int info_len; |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2521 |
|
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
|
2522 |
if (!check_length(len, 8, "Info")) return; buf++; |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2523 |
version = grf_load_byte(&buf); |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2524 |
grfid = grf_load_dword(&buf); |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2525 |
|
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2526 |
_cur_grfconfig->grfid = grfid; |
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2527 |
|
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
|
2528 |
/* 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
|
2529 |
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
|
2530 |
|
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2531 |
len -= 6; |
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2532 |
name = (const char*)buf; |
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2533 |
name_len = ttd_strnlen(name, len); |
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2534 |
|
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2535 |
if (name_len < len) { |
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2536 |
_cur_grfconfig->name = TranslateTTDPatchCodes(name); |
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2537 |
|
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2538 |
len -= name_len + 1; |
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2539 |
info = name + name_len + 1; |
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2540 |
info_len = ttd_strnlen(info, len); |
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2541 |
|
5413 | 2542 |
if (info_len < len) _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
|
2543 |
} |
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
|
2544 |
|
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
|
2545 |
/* 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
|
2546 |
_skip_sprites = -1; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2547 |
} |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2548 |
|
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2549 |
/* Action 0x08 */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2550 |
static void GRFInfo(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2551 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2552 |
/* <08> <version> <grf-id> <name> <info> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2553 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2554 |
* B version newgrf version, currently 06 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2555 |
* 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
|
2556 |
* S name name of this .grf set |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2557 |
* S info string describing the set, and e.g. author and copyright */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2558 |
/* TODO: Check version. (We should have own versioning done somehow.) */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2559 |
uint8 version; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2560 |
uint32 grfid; |
1329 | 2561 |
const char *name; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2562 |
|
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
|
2563 |
if (!check_length(len, 8, "GRFInfo")) return; buf++; |
3712
0ad6fed91f3c
(svn r4655) - Fix [NewGRF r4654]: /me bangs head against the wall....gaah
Darkvater
parents:
3711
diff
changeset
|
2564 |
version = grf_load_byte(&buf); |
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
|
2565 |
grfid = grf_load_dword(&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
|
2566 |
name = (const char*)buf; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2567 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2568 |
_cur_grffile->grfid = grfid; |
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2569 |
_cur_grffile->grf_version = version; |
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
|
2570 |
SETBIT(_cur_grfconfig->flags, GCF_ACTIVATED); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2571 |
|
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
|
2572 |
/* Do swap the GRFID for displaying purposes since people expect that */ |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2573 |
DEBUG(grf, 1, "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
|
2574 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2575 |
|
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2576 |
/* Action 0x0A */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2577 |
static void SpriteReplace(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2578 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2579 |
/* <0A> <num-sets> <set1> [<set2> ...] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2580 |
* <set>: <num-sprites> <first-sprite> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2581 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2582 |
* 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
|
2583 |
* Each set: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2584 |
* 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
|
2585 |
* W first-sprite First sprite number to replace */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2586 |
uint8 num_sets; |
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
|
2587 |
uint i; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2588 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2589 |
buf++; /* skip action byte */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2590 |
num_sets = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2591 |
|
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
|
2592 |
for (i = 0; i < num_sets; 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
|
2593 |
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
|
2594 |
uint16 first_sprite = grf_load_word(&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
|
2595 |
uint j; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2596 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2597 |
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
|
2598 |
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
|
2599 |
); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2600 |
|
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
|
2601 |
for (j = 0; j < num_sprites; j++) { |
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
|
2602 |
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
|
2603 |
_nfo_line++; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2604 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2605 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2606 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2607 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2608 |
/* Action 0x0B */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2609 |
static void GRFError(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2610 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2611 |
/* <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
|
2612 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2613 |
* B severity 00: notice, contine loading grf file |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2614 |
* 01: warning, continue loading grf file |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2615 |
* 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
|
2616 |
* 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
|
2617 |
* 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
|
2618 |
* the future (only when restarting the patch) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2619 |
* 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
|
2620 |
* B message-id message to show, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2621 |
* 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
|
2622 |
* not present for built-in messages. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2623 |
* V data additional data for built-in (or custom) messages |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2624 |
* B parnum see action 6, only used with built-in message 03 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2625 |
/* TODO: For now we just show the message, sometimes incomplete and never translated. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2626 |
|
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2627 |
static const char *const msgstr[] = { |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2628 |
"%sRequires at least pseudo-TTDPatch version %s", |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2629 |
"%sThis file is for %s version of TTD", |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2630 |
"%sDesigned to be used with %s", |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2631 |
"%sInvalid parameter %s", |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2632 |
"%sMust be loaded before %s", |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2633 |
"%sMust be loaded after %s", |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2634 |
"%s%s" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2635 |
}; |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2636 |
|
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2637 |
static const char *const sevstr[] = { |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2638 |
"", |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2639 |
"Warning: ", |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2640 |
"Error: ", |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2641 |
"Fatal: ", |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2642 |
}; |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2643 |
uint8 sevid; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2644 |
uint8 msgid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2645 |
|
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
|
2646 |
if (!check_length(len, 6, "GRFError")) return; |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2647 |
sevid = buf[1]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2648 |
msgid = buf[3]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2649 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2650 |
// Undocumented TTDPatch feature. |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2651 |
if (!HASBIT(sevid, 7) && _cur_stage < GLS_ACTIVATION) { |
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2652 |
grfmsg(7, "Skipping non-fatal GRFError in stage 1"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2653 |
return; |
3588
69817310ddf8
(svn r4474) - NewGRF: Skip non-fatal errors when not in stage 2.
peter1138
parents:
3577
diff
changeset
|
2654 |
} |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2655 |
|
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
2656 |
sevid = GB(sevid, 0, 2); |
5382
7afff50b3497
(svn r7568) -Fix [r7564]: buf+4 is the same as &buf[4], not buf[4] for a char*.
Darkvater
parents:
5380
diff
changeset
|
2657 |
grfmsg(0, msgstr[(msgid == 0xFF) ? lengthof(msgstr) - 1 : msgid], sevstr[sevid], &buf[4]); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2658 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2659 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2660 |
/* Action 0x0C */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2661 |
static void GRFComment(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2662 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2663 |
/* <0C> [<ignored...>] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2664 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2665 |
* 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
|
2666 |
|
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
|
2667 |
static char comment[256]; |
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
|
2668 |
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
|
2669 |
|
3571 | 2670 |
ttd_strlcpy(comment, (char*)(buf + 1), minu(sizeof(comment), len)); |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2671 |
grfmsg(2, "GRFComment: %s", comment); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2672 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2673 |
|
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
|
2674 |
/* 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
|
2675 |
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
|
2676 |
{ |
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
|
2677 |
uint8 target; |
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
|
2678 |
|
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
|
2679 |
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
|
2680 |
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
|
2681 |
target = 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
|
2682 |
|
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
|
2683 |
/* 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
|
2684 |
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
|
2685 |
|
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
|
2686 |
/* 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
|
2687 |
* 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
|
2688 |
* 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
|
2689 |
* 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
|
2690 |
|
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
|
2691 |
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
|
2692 |
|
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
|
2693 |
/* 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
|
2694 |
_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
|
2695 |
} |
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
|
2696 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2697 |
/* Action 0x0D */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2698 |
static void ParamSet(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2699 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2700 |
/* <0D> <target> <operation> <source1> <source2> [<data>] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2701 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2702 |
* B target parameter number where result is stored |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2703 |
* B operation operation to perform, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2704 |
* B source1 first source operand |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2705 |
* B source2 second source operand |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2706 |
* 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
|
2707 |
* 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
|
2708 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2709 |
* Operations |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2710 |
* 00 Set parameter equal to source1 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2711 |
* 01 Addition, source1 + source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2712 |
* 02 Subtraction, source1 - source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2713 |
* 03 Unsigned multiplication, source1 * source2 (both unsigned) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2714 |
* 04 Signed multiplication, source1 * source2 (both signed) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2715 |
* 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
|
2716 |
* 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
|
2717 |
* negative, source1 is unsigned) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2718 |
* 06 Signed bit shift, source1 by source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2719 |
* (source2 like in 05, and source1 as well) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2720 |
*/ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2721 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2722 |
byte target; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2723 |
byte oper; |
2345 | 2724 |
uint32 src1; |
2725 |
uint32 src2; |
|
2726 |
uint32 data = 0; |
|
2727 |
uint32 res; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2728 |
|
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
|
2729 |
if (!check_length(len, 5, "ParamSet")) return; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2730 |
buf++; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2731 |
target = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2732 |
oper = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2733 |
src1 = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2734 |
src2 = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2735 |
|
2345 | 2736 |
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
|
2737 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2738 |
/* 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
|
2739 |
* 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
|
2740 |
* defined if any of the following applies: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2741 |
* - 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
|
2742 |
* - 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
|
2743 |
* an earlier action D */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2744 |
if (oper & 0x80) { |
3807
736ea84b3cf4
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
2745 |
if (target < 0x80 && target < _cur_grffile->param_end) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2746 |
grfmsg(7, "Param %u already defined, skipping", target); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2747 |
return; |
3807
736ea84b3cf4
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
2748 |
} |
736ea84b3cf4
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
2749 |
|
736ea84b3cf4
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
2750 |
oper &= 0x7F; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2751 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2752 |
|
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
|
2753 |
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
|
2754 |
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
|
2755 |
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
|
2756 |
/* Patch variables */ |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2757 |
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
|
2758 |
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
|
2759 |
} 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
|
2760 |
/* 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
|
2761 |
if (_cur_stage != GLS_ACTIVATION) { |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2762 |
/* Ignore GRM during initialization */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2763 |
src1 = 0; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2764 |
} else { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2765 |
uint8 op = src1; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2766 |
uint8 feature = GB(data, 8, 8); |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2767 |
uint16 count = GB(data, 16, 16); |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2768 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2769 |
switch (feature) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2770 |
case 0x00: /* Trains */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2771 |
case 0x01: /* Road Vehicles */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2772 |
case 0x02: /* Ships */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2773 |
case 0x03: /* Aircraft */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2774 |
{ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2775 |
uint start = 0; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2776 |
uint size = 0; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2777 |
uint shift = _vehshifts[feature]; |
4964
fd058c9cd46a
(svn r6963) - Fix (r6960): signed/unsigned complaints from MSVC
peter1138
parents:
4961
diff
changeset
|
2778 |
int i; |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2779 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2780 |
if (op == 6) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2781 |
/* 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
|
2782 |
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
|
2783 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2784 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2785 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2786 |
/* 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
|
2787 |
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
|
2788 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2789 |
for (i = start; i < _vehcounts[feature]; i++) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2790 |
if (_grm_engines[shift + i] == 0) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2791 |
size++; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2792 |
} else { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2793 |
if (op == 2 || op == 3) break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2794 |
start = i + 1; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2795 |
size = 0; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2796 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2797 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2798 |
if (size == count) break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2799 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2800 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2801 |
if (size == count) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2802 |
/* Got the slot... */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2803 |
if (op == 0 || op == 3) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2804 |
grfmsg(2, "GRM: Reserving %d vehicles at %d", count, start); |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2805 |
for (i = 0; i < count; i++) _grm_engines[shift + start + i] = _cur_grffile->grfid; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2806 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2807 |
src1 = start; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2808 |
} else { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2809 |
/* Unable to allocate */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2810 |
if (op != 4 && op != 5) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2811 |
/* Deactivate GRF */ |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2812 |
grfmsg(0, "GRM: Unable to allocate %d vehicles, deactivating", count); |
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
|
2813 |
SETBIT(_cur_grfconfig->flags, GCF_DISABLED); |
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
|
2814 |
CLRBIT(_cur_grfconfig->flags, GCF_ACTIVATED); |
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
|
2815 |
|
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
|
2816 |
_skip_sprites = -1; |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2817 |
return; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2818 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2819 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2820 |
grfmsg(1, "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
|
2821 |
src1 = UINT_MAX; |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2822 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2823 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2824 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2825 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2826 |
case 0x08: /* General sprites */ |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2827 |
switch (op) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2828 |
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
|
2829 |
/* 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
|
2830 |
if (_cur_spriteid + count >= 16384) { |
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
|
2831 |
grfmsg(0, "GRM: Unable to allocate %d sprites; try changing NewGRF order", count); |
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
|
2832 |
SETBIT(_cur_grfconfig->flags, GCF_DISABLED); |
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
|
2833 |
CLRBIT(_cur_grfconfig->flags, GCF_ACTIVATED); |
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
|
2834 |
|
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
|
2835 |
_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
|
2836 |
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
|
2837 |
} |
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
|
2838 |
|
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2839 |
/* '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
|
2840 |
src1 = _cur_spriteid; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2841 |
_cur_spriteid += count; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2842 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2843 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2844 |
case 1: |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2845 |
src1 = _cur_spriteid; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2846 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2847 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2848 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2849 |
grfmsg(1, "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
|
2850 |
return; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2851 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2852 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2853 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2854 |
default: grfmsg(1, "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
|
2855 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2856 |
} |
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
|
2857 |
} |
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
|
2858 |
} 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
|
2859 |
/* 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
|
2860 |
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
|
2861 |
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
|
2862 |
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
|
2863 |
} 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
|
2864 |
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
|
2865 |
} |
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
|
2866 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2867 |
} 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
|
2868 |
/* 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
|
2869 |
* 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
|
2870 |
* 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
|
2871 |
* 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
|
2872 |
* of 0 is used instead. */ |
3811
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2873 |
src1 = (src1 == 0xFF) ? data : GetParamVal(src1, NULL); |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2874 |
src2 = (src2 == 0xFF) ? data : GetParamVal(src2, NULL); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2875 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2876 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2877 |
/* 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
|
2878 |
* 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
|
2879 |
* 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
|
2880 |
* 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
|
2881 |
* instead. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2882 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2883 |
switch (oper) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2884 |
case 0x00: |
2345 | 2885 |
res = src1; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2886 |
break; |
2345 | 2887 |
|
2888 |
case 0x01: |
|
2889 |
res = src1 + src2; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2890 |
break; |
2345 | 2891 |
|
2892 |
case 0x02: |
|
2893 |
res = src1 - src2; |
|
2894 |
break; |
|
2895 |
||
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2896 |
case 0x03: |
2345 | 2897 |
res = src1 * src2; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2898 |
break; |
2345 | 2899 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2900 |
case 0x04: |
2345 | 2901 |
res = (int32)src1 * (int32)src2; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2902 |
break; |
2345 | 2903 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2904 |
case 0x05: |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2905 |
if ((int32)src2 < 0) { |
2345 | 2906 |
res = src1 >> -(int32)src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2907 |
} else { |
2345 | 2908 |
res = src1 << src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2909 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2910 |
break; |
2345 | 2911 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2912 |
case 0x06: |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2913 |
if ((int32)src2 < 0) { |
2345 | 2914 |
res = (int32)src1 >> -(int32)src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2915 |
} else { |
2345 | 2916 |
res = (int32)src1 << src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2917 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2918 |
break; |
2345 | 2919 |
|
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2920 |
case 0x07: /* Bitwise AND */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2921 |
res = src1 & src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2922 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2923 |
|
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2924 |
case 0x08: /* Bitwise OR */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2925 |
res = src1 | src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2926 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2927 |
|
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2928 |
case 0x09: /* Unsigned division */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2929 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2930 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2931 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2932 |
res = src1 / src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2933 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2934 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2935 |
|
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2936 |
case 0x0A: /* Signed divison */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2937 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2938 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2939 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2940 |
res = (int32)src1 / (int32)src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2941 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2942 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2943 |
|
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2944 |
case 0x0B: /* Unsigned modulo */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2945 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2946 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2947 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2948 |
res = src1 % src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2949 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2950 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2951 |
|
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2952 |
case 0x0C: /* Signed modulo */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2953 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2954 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2955 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2956 |
res = (int32)src1 % (int32)src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2957 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2958 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2959 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2960 |
default: grfmsg(0, "ParamSet: Unknown operation %d, skipping", oper); return; |
2345 | 2961 |
} |
2962 |
||
2963 |
switch (target) { |
|
2964 |
case 0x8E: // Y-Offset for train sprites |
|
2965 |
_traininfo_vehicle_pitch = res; |
|
2966 |
break; |
|
2967 |
||
2968 |
// TODO implement |
|
2969 |
case 0x8F: // Rail track type cost factors |
|
2970 |
case 0x93: // Tile refresh offset to left |
|
2971 |
case 0x94: // Tile refresh offset to right |
|
2972 |
case 0x95: // Tile refresh offset upwards |
|
2973 |
case 0x96: // Tile refresh offset downwards |
|
2974 |
case 0x97: // Snow line height |
|
2975 |
case 0x99: // Global ID offset |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2976 |
grfmsg(7, "ParamSet: Skipping unimplemented target 0x%02X", target); |
2345 | 2977 |
break; |
2978 |
||
3814
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2979 |
case 0x9E: /* Miscellaneous GRF features */ |
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2980 |
_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
|
2981 |
/* 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
|
2982 |
_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
|
2983 |
break; |
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2984 |
|
2345 | 2985 |
default: |
2986 |
if (target < 0x80) { |
|
2987 |
_cur_grffile->param[target] = res; |
|
2988 |
if (target + 1U > _cur_grffile->param_end) _cur_grffile->param_end = target + 1; |
|
2989 |
} else { |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2990 |
grfmsg(7, "ParamSet: Skipping unknown target 0x%02X", target); |
2345 | 2991 |
} |
2992 |
break; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2993 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2994 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2995 |
|
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
|
2996 |
/* 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
|
2997 |
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
|
2998 |
{ |
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
|
2999 |
/* <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
|
3000 |
* |
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
|
3001 |
* 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
|
3002 |
* 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
|
3003 |
|
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
|
3004 |
byte num; |
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
|
3005 |
int i; |
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
|
3006 |
|
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
|
3007 |
if (!check_length(len, 1, "GRFInhibit")) return; |
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
|
3008 |
buf++, 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
|
3009 |
num = grf_load_byte(&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
|
3010 |
if (!check_length(len, 4 * num, "GRFInhibit")) return; |
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
|
3011 |
|
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
|
3012 |
for (i = 0; i < num; i++) { |
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
|
3013 |
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
|
3014 |
|
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
|
3015 |
/* 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
|
3016 |
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
|
3017 |
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
|
3018 |
|
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
|
3019 |
/* 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
|
3020 |
_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
|
3021 |
|
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
|
3022 |
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
|
3023 |
} |
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
|
3024 |
} |
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
|
3025 |
} |
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
|
3026 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
3027 |
/* Action 0x0E */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3028 |
static void GRFInhibit(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3029 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3030 |
/* <0E> <num> <grfids...> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3031 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3032 |
* B num Number of GRFIDs that follow |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3033 |
* D grfids GRFIDs of the files to deactivate */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3034 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3035 |
byte num; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3036 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3037 |
|
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
|
3038 |
if (!check_length(len, 1, "GRFInhibit")) return; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3039 |
buf++, len--; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3040 |
num = grf_load_byte(&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
|
3041 |
if (!check_length(len, 4 * num, "GRFInhibit")) return; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3042 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3043 |
for (i = 0; i < num; i++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3044 |
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
|
3045 |
GRFConfig *file = GetGRFConfig(grfid); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3046 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3047 |
/* 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
|
3048 |
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
|
3049 |
grfmsg(2, "GRFInhibit: Deactivating file '%s'", file->filename); |
5333
dedf1f6de6d3
(svn r7495) -Fix (r7354): [NewGRF] Deactivate the target GRF, not the current GRF.
peter1138
parents:
5329
diff
changeset
|
3050 |
SETBIT(file->flags, GCF_DISABLED); |
dedf1f6de6d3
(svn r7495) -Fix (r7354): [NewGRF] Deactivate the target GRF, not the current GRF.
peter1138
parents:
5329
diff
changeset
|
3051 |
CLRBIT(file->flags, GCF_ACTIVATED); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3052 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3053 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3054 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3055 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
3056 |
/* 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
|
3057 |
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
|
3058 |
{ |
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
|
3059 |
/* <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
|
3060 |
* |
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
|
3061 |
* 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
|
3062 |
* 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
|
3063 |
|
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
|
3064 |
GRFLabel *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
|
3065 |
|
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
|
3066 |
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
|
3067 |
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
|
3068 |
|
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
|
3069 |
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
|
3070 |
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
|
3071 |
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
|
3072 |
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
|
3073 |
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
|
3074 |
|
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
|
3075 |
/* 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
|
3076 |
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
|
3077 |
_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
|
3078 |
} 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
|
3079 |
/* 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
|
3080 |
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
|
3081 |
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
|
3082 |
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
|
3083 |
} |
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
|
3084 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3085 |
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
|
3086 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3087 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3088 |
/* Action 0x11 */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3089 |
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
|
3090 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3091 |
/* <11> <num> |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3092 |
* |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3093 |
* 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
|
3094 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3095 |
uint16 num; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3096 |
|
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
|
3097 |
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
|
3098 |
buf++; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3099 |
num = 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
|
3100 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3101 |
_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
|
3102 |
_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
|
3103 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3104 |
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
|
3105 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3106 |
|
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3107 |
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
|
3108 |
{ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3109 |
const GRFFile *file; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3110 |
FileEntry *se = AllocateFileEntry(); |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3111 |
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
|
3112 |
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
|
3113 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3114 |
file = GetFileByGRFID(grfid); |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3115 |
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
|
3116 |
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
|
3117 |
return; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3118 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3119 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3120 |
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
|
3121 |
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
|
3122 |
return; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3123 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3124 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3125 |
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
|
3126 |
|
5024
5e98bf731469
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5011
diff
changeset
|
3127 |
*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
|
3128 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3129 |
/* 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
|
3130 |
se->volume = 128; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3131 |
se->priority = 0; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3132 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3133 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3134 |
/* 'Action 0xFE' */ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3135 |
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
|
3136 |
{ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3137 |
if (_grf_data_blocks == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3138 |
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
|
3139 |
return; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3140 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3141 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3142 |
buf++; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3143 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3144 |
_grf_data_blocks--; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3145 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3146 |
/* 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
|
3147 |
* 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
|
3148 |
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
|
3149 |
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
|
3150 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3151 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3152 |
switch (_grf_data_type) { |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3153 |
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
|
3154 |
default: NOT_REACHED(); break; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3155 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3156 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3157 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3158 |
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
|
3159 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3160 |
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
|
3161 |
FileEntry *se; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3162 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3163 |
/* 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
|
3164 |
* so that the indices used elsewhere are still correct. */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3165 |
se = AllocateFileEntry(); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3166 |
|
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
3167 |
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
|
3168 |
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
|
3169 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3170 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3171 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3172 |
/* 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
|
3173 |
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
|
3174 |
|
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
3175 |
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
|
3176 |
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
|
3177 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3178 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3179 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3180 |
for (;;) { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3181 |
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
|
3182 |
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
|
3183 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3184 |
switch (tag) { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3185 |
case ' tmf': /* 'fmt ' */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3186 |
/* 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
|
3187 |
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
|
3188 |
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
|
3189 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3190 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3191 |
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
|
3192 |
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
|
3193 |
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
|
3194 |
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
|
3195 |
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
|
3196 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3197 |
/* 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
|
3198 |
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
|
3199 |
break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3200 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3201 |
case 'atad': /* 'data' */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3202 |
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
|
3203 |
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
|
3204 |
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
|
3205 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3206 |
/* 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
|
3207 |
se->volume = 0x80; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3208 |
se->priority = 0; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3209 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3210 |
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
|
3211 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3212 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3213 |
default: |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3214 |
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
|
3215 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3216 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3217 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3218 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3219 |
|
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
|
3220 |
/* 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
|
3221 |
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
|
3222 |
{ |
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
|
3223 |
/* <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
|
3224 |
* |
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
|
3225 |
* 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
|
3226 |
* 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
|
3227 |
* 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
|
3228 |
* 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
|
3229 |
|
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
|
3230 |
uint8 num_def; |
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
|
3231 |
uint i; |
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
|
3232 |
|
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
|
3233 |
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
|
3234 |
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
|
3235 |
|
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
|
3236 |
num_def = 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
|
3237 |
|
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
|
3238 |
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
|
3239 |
|
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
|
3240 |
for (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
|
3241 |
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
|
3242 |
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
|
3243 |
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
|
3244 |
uint c; |
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
|
3245 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3246 |
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
|
3247 |
|
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
|
3248 |
for (c = 0; c < num_char; c++) { |
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
|
3249 |
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
|
3250 |
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
|
3251 |
_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
|
3252 |
} |
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
|
3253 |
} |
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
|
3254 |
} |
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
|
3255 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3256 |
/* 'Action 0xFF' */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3257 |
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
|
3258 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3259 |
byte name_len; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3260 |
const char *name; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3261 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3262 |
if (_grf_data_blocks == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3263 |
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
|
3264 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3265 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3266 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3267 |
buf++; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3268 |
name_len = 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
|
3269 |
name = (const char *)buf; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3270 |
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
|
3271 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3272 |
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
|
3273 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3274 |
_grf_data_blocks--; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3275 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3276 |
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
|
3277 |
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
|
3278 |
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
|
3279 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3280 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3281 |
|
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
|
3282 |
|
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
|
3283 |
/* 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
|
3284 |
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
|
3285 |
{ |
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
|
3286 |
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
|
3287 |
|
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
|
3288 |
/* 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
|
3289 |
_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
|
3290 |
} |
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
|
3291 |
|
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
|
3292 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3293 |
static void InitializeGRFSpecial(void) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3294 |
{ |
4381
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3295 |
_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
|
3296 |
| (1 << 0x0D) // newairports |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3297 |
| (1 << 0x0E) // largestations |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3298 |
| ((_patches.longbridges ? 1 : 0) << 0x0F) // longbridges |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3299 |
| (0 << 0x10) // loadtime |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3300 |
| (1 << 0x12) // presignals |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3301 |
| (1 << 0x13) // extpresignals |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3302 |
| ((_patches.never_expire_vehicles ? 1 : 0) << 0x16) // enginespersist |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3303 |
| (1 << 0x1B) // multihead |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3304 |
| (1 << 0x1D) // lowmemory |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3305 |
| (1 << 0x1E); // generalfixes |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3306 |
|
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3307 |
_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
|
3308 |
| ((_patches.mammoth_trains ? 1 : 0) << 0x08) // mammothtrains |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3309 |
| (1 << 0x09) // trainrefit |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3310 |
| (0 << 0x0B) // subsidiaries |
5550
ffed4fb7555d
(svn r7930) -Fix: [FS#520] Wrong GRF flag set for gradual loading (mart3p)
Darkvater
parents:
5525
diff
changeset
|
3311 |
| ((_patches.gradual_loading ? 1 : 0) << 0x0C) // gradualloading |
4381
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3312 |
| (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
|
3313 |
| (1 << 0x13) // unifiedmaglevmode - set bit 1 mode |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3314 |
| (1 << 0x14) // bridgespeedlimits |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3315 |
| (1 << 0x16) // eternalgame |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3316 |
| (1 << 0x17) // newtrains |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3317 |
| (1 << 0x18) // newrvs |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3318 |
| (1 << 0x19) // newships |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3319 |
| (1 << 0x1A) // newplanes |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3320 |
| ((_patches.signal_side ? 1 : 0) << 0x1B) // signalsontrafficside |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3321 |
| (1 << 0x1C); // electrifiedrailway |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3322 |
|
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3323 |
_ttdpatch_flags[2] = (1 << 0x01) // loadallgraphics - obsolote |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3324 |
| (1 << 0x03) // semaphores |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3325 |
| (0 << 0x0B) // enhancedgui |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3326 |
| (0 << 0x0C) // newagerating |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3327 |
| ((_patches.build_on_slopes ? 1 : 0) << 0x0D) // buildonslopes |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3328 |
| (0 << 0x0F) // planespeed |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3329 |
| (0 << 0x10) // moreindustriesperclimate - obsolete |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3330 |
| (0 << 0x11) // moretoylandfeatures |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3331 |
| (1 << 0x12) // newstations |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3332 |
| (0 << 0x13) // tracktypecostdiff |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3333 |
| (0 << 0x14) // manualconvert |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3334 |
| ((_patches.build_on_slopes ? 1 : 0) << 0x15) // buildoncoasts |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3335 |
| (1 << 0x16) // canals |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3336 |
| (1 << 0x17) // newstartyear |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3337 |
| (0 << 0x18) // freighttrains |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3338 |
| (0 << 0x19) // newhouses |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3339 |
| (1 << 0x1A) // newbridges |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3340 |
| (0 << 0x1B) // newtownnames |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3341 |
| (0 << 0x1C) // moreanimations |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3342 |
| ((_patches.wagon_speed_limits ? 1 : 0) << 0x1D) // wagonspeedlimits |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3343 |
| (1 << 0x1E) // newshistory |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3344 |
| (0 << 0x1F); // custombridgeheads |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3345 |
|
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3346 |
_ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3347 |
| (1 << 0x01) // windowsnap |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3348 |
| (0 << 0x02) // townbuildnoroad |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3349 |
| (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
|
3350 |
| (0 << 0x04) // aichoosechance |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3351 |
| (1 << 0x05) // resolutionwidth |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3352 |
| (1 << 0x06) // resolutionheight |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3353 |
| (0 << 0x07) // newindustries |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3354 |
| (0 << 0x08) // fifoloading |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3355 |
| (0 << 0x09) // townroadbranchprob |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3356 |
| (0 << 0x0A) // tempsnowline |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3357 |
| (0 << 0x0B) // newcargo |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3358 |
| (1 << 0x0C) // enhancemultiplayer |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3359 |
| (1 << 0x0D) // onewayroads |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3360 |
| ((_patches.nonuniform_stations ? 1 : 0) << 0x0E) // irregularstations |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3361 |
| (1 << 0x0F) // statistics |
4657
dfbc1d1e6fd0
(svn r6533) - Fix (r6532): Somebody forgot to add newsounds to the ttdpatch flags...
peter1138
parents:
4656
diff
changeset
|
3362 |
| (1 << 0x10) // newsounds |
4381
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3363 |
| (1 << 0x11) // autoreplace |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3364 |
| (1 << 0x12) // autoslope |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3365 |
| (0 << 0x13) // followvehicle |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3366 |
| (0 << 0x14) // trams |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3367 |
| (0 << 0x15) // enhancetunnels |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3368 |
| (0 << 0x16) // shortrvs |
c97b8f5119ad
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3369 |
| (0 << 0x17); // articulatedrvs |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3370 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3371 |
|
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3372 |
static void ResetCustomStations(void) |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3373 |
{ |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3374 |
StationSpec *statspec; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3375 |
GRFFile *file; |
2627
7a29af37b416
(svn r3169) Little bit of coding style fixing, and change from value to lengthof()
peter1138
parents:
2625
diff
changeset
|
3376 |
uint i; |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3377 |
uint t; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3378 |
|
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3379 |
for (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
|
3380 |
if (file->stations == NULL) continue; |
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
|
3381 |
for (i = 0; i < MAX_STATIONS; i++) { |
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
|
3382 |
if (file->stations[i] == NULL) continue; |
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
|
3383 |
statspec = file->stations[i]; |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3384 |
|
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3385 |
/* 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
|
3386 |
if (!statspec->copied_renderdata) { |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3387 |
for (t = 0; t < statspec->tiles; t++) { |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3388 |
free((void*)statspec->renderdata[t].seq); |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3389 |
} |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3390 |
free(statspec->renderdata); |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3391 |
} |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3392 |
|
5061
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3393 |
/* Release platforms and layouts */ |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3394 |
if (!statspec->copied_layouts) { |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3395 |
uint l, p; |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3396 |
for (l = 0; l < statspec->lengths; l++) { |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3397 |
for (p = 0; p < statspec->platforms[l]; p++) { |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3398 |
free(statspec->layouts[l][p]); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3399 |
} |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3400 |
free(statspec->layouts[l]); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3401 |
} |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3402 |
free(statspec->layouts); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3403 |
free(statspec->platforms); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3404 |
} |
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
|
3405 |
|
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
|
3406 |
/* 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
|
3407 |
free(statspec); |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3408 |
} |
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
|
3409 |
|
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
|
3410 |
/* 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
|
3411 |
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
|
3412 |
file->stations = NULL; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3413 |
} |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3414 |
} |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3415 |
|
4953
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3416 |
static void ResetNewGRF(void) |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3417 |
{ |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3418 |
GRFFile *f, *next; |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3419 |
|
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3420 |
for (f = _first_grffile; f != NULL; f = next) { |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3421 |
next = f->next; |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3422 |
|
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3423 |
free(f->filename); |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3424 |
free(f); |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3425 |
} |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3426 |
|
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3427 |
_first_grffile = NULL; |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3428 |
_cur_grffile = NULL; |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3429 |
} |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3430 |
|
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
3431 |
/** |
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
|
3432 |
* 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
|
3433 |
* 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
|
3434 |
*/ |
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
|
3435 |
static void ResetNewGRFData(void) |
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
|
3436 |
{ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3437 |
uint 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
|
3438 |
|
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3439 |
CleanUpStrings(); |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3440 |
|
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
|
3441 |
// Copy/reset original engine info 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
|
3442 |
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
|
3443 |
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
|
3444 |
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
|
3445 |
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
|
3446 |
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
|
3447 |
|
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
|
3448 |
// Copy/reset original bridge info data |
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
|
3449 |
// First, free sprite table data |
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
|
3450 |
for (i = 0; i < MAX_BRIDGES; 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
|
3451 |
if (_bridge[i].sprite_table != NULL) { |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3452 |
uint j; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3453 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3454 |
for (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
|
3455 |
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
|
3456 |
} |
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
|
3457 |
} |
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
|
3458 |
memcpy(&_bridge, &orig_bridge, sizeof(_bridge)); |
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
3459 |
|
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3460 |
// Reset refit/cargo class data |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3461 |
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
|
3462 |
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
|
3463 |
|
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3464 |
// Reset GRM reservations |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3465 |
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
|
3466 |
|
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
3467 |
// Unload sprite group data |
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
3468 |
UnloadWagonOverrides(); |
3695
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
3469 |
UnloadRotorOverrideSprites(); |
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
3470 |
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
|
3471 |
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
|
3472 |
ResetEngineListOrder(); |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
3473 |
|
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
3474 |
// Reset price base data |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
3475 |
ResetPriceBaseMultipliers(); |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3476 |
|
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
3477 |
/* Reset the curencies array */ |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
3478 |
ResetCurrencies(); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
3479 |
|
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3480 |
// Reset station classes |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3481 |
ResetStationClasses(); |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3482 |
ResetCustomStations(); |
2812
95102021c840
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
3483 |
|
4953
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3484 |
/* Reset NewGRF files */ |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3485 |
ResetNewGRF(); |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3486 |
|
2812
95102021c840
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
3487 |
// Add engine type to engine data. This is needed for the refit precalculation. |
95102021c840
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
3488 |
AddTypeToEngines(); |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3489 |
|
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
|
3490 |
/* 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
|
3491 |
_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
|
3492 |
_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
|
3493 |
_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
|
3494 |
_have_2cc = false; |
5209
1b7a72191019
(svn r7324) -Codechange: reset newgrf signal location data
peter1138
parents:
5161
diff
changeset
|
3495 |
_signal_base = 0; |
5210
3415ef43c70a
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
3496 |
_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
|
3497 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3498 |
InitializeSoundPool(); |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3499 |
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
|
3500 |
} |
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
|
3501 |
|
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
|
3502 |
/** Reset all NewGRFData that was used only while processing data */ |
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
|
3503 |
static void ClearTemporaryNewGRFData(void) |
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
|
3504 |
{ |
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
|
3505 |
/* Clear the GOTO labels used for GRF processing */ |
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
|
3506 |
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
|
3507 |
for (l = _cur_grffile->label; l != 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
|
3508 |
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
|
3509 |
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
|
3510 |
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
|
3511 |
} |
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
|
3512 |
_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
|
3513 |
|
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3514 |
/* 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
|
3515 |
free(_cur_grffile->spritegroups); |
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3516 |
_cur_grffile->spritegroups = NULL; |
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3517 |
_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
|
3518 |
} |
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
|
3519 |
|
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
|
3520 |
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
|
3521 |
{ |
1477 | 3522 |
GRFFile *newfile; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3523 |
|
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
|
3524 |
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
|
3525 |
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
|
3526 |
/* 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
|
3527 |
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
|
3528 |
_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
|
3529 |
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
|
3530 |
} |
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
|
3531 |
|
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
|
3532 |
newfile = CallocT<GRFFile>(1); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3533 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3534 |
if (newfile == NULL) error ("Out of memory"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3535 |
|
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
|
3536 |
newfile->filename = strdup(config->filename); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3537 |
newfile->sprite_offset = sprite_offset; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3538 |
|
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
|
3539 |
/* 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
|
3540 |
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
|
3541 |
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
|
3542 |
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
|
3543 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3544 |
if (_first_grffile == NULL) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3545 |
_cur_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3546 |
_first_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3547 |
} else { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3548 |
_cur_grffile->next = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3549 |
_cur_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3550 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3551 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3552 |
|
5037
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3553 |
|
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3554 |
/** Bitmasked values of what type of cargo is refittable for the given vehicle-type. |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3555 |
* This coupled with the landscape information (_landscape_global_cargo_mask) gives |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3556 |
* us exactly what is refittable and what is not */ |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3557 |
#define MC(cargo) (1 << cargo) |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3558 |
static const uint32 _default_refitmasks[NUM_VEHICLE_TYPES] = { |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3559 |
/* Trains */ |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3560 |
MC(GC_PASSENGERS) | MC(GC_COAL) | MC(GC_MAIL) | MC(GC_LIVESTOCK) | MC(GC_GOODS) | MC(GC_GRAIN) | MC(GC_WOOD) | MC(GC_IRON_ORE) | |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3561 |
MC(GC_STEEL) | MC(GC_VALUABLES) | MC(GC_PAPER) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_COPPER_ORE) | MC(GC_WATER) | MC(GC_SUGAR) | |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3562 |
MC(GC_TOYS) | MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS), |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3563 |
/* Road vehicles (not refittable by default) */ |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3564 |
0, |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3565 |
/* Ships */ |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3566 |
MC(GC_COAL) | MC(GC_MAIL) | MC(GC_LIVESTOCK) | MC(GC_GOODS) | MC(GC_GRAIN) | MC(GC_WOOD) | MC(GC_IRON_ORE) | MC(GC_STEEL) | MC(GC_VALUABLES) | |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3567 |
MC(GC_PAPER) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_COPPER_ORE) | MC(GC_WATER) | MC(GC_RUBBER) | MC(GC_SUGAR) | MC(GC_TOYS) | MC(GC_BATTERIES) | |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3568 |
MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS), |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3569 |
/* Aircraft */ |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3570 |
MC(GC_PASSENGERS) | MC(GC_MAIL) | MC(GC_GOODS) | MC(GC_VALUABLES) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_SUGAR) | MC(GC_TOYS) | |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3571 |
MC(GC_BATTERIES) | MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS), |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3572 |
/* Special/Disaster */ |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3573 |
0,0 |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3574 |
}; |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3575 |
#undef MC |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3576 |
|
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3577 |
|
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3578 |
/** |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3579 |
* 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
|
3580 |
*/ |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3581 |
static void CalculateRefitMasks(void) |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3582 |
{ |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3583 |
EngineID engine; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3584 |
|
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3585 |
for (engine = 0; engine < TOTAL_NUM_ENGINES; engine++) { |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3586 |
uint32 mask = 0; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3587 |
uint32 not_mask = 0; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3588 |
uint32 xor_mask = _engine_info[engine].refit_mask; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3589 |
byte i; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3590 |
|
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3591 |
if (cargo_allowed[engine] != 0) { |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3592 |
// Build up the list of cargo types from the set cargo classes. |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3593 |
for (i = 0; i < lengthof(cargo_classes); i++) { |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3594 |
if (HASBIT(cargo_allowed[engine], i)) mask |= cargo_classes[i]; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3595 |
if (HASBIT(cargo_disallowed[engine], i)) not_mask |= cargo_classes[i]; |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3596 |
} |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3597 |
} else { |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3598 |
// 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
|
3599 |
if (xor_mask == 0 && ( |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3600 |
GetEngine(engine)->type != VEH_Train || ( |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3601 |
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
|
3602 |
RailVehInfo(engine)->railveh_type != RAILVEH_WAGON |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3603 |
) |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3604 |
)) { |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3605 |
xor_mask = _default_refitmasks[GetEngine(engine)->type - VEH_Train]; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3606 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3607 |
} |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3608 |
_engine_info[engine].refit_mask = ((mask & ~not_mask) ^ xor_mask) & _landscape_global_cargo_mask[_opt.landscape]; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3609 |
} |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3610 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3611 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3612 |
/* 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
|
3613 |
* 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
|
3614 |
* partial implementation yet). */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3615 |
/* 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
|
3616 |
* 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
|
3617 |
* 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
|
3618 |
static void DecodeSpecialSprite(uint num, GrfLoadingStage stage) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3619 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3620 |
/* 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
|
3621 |
* 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
|
3622 |
* 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
|
3623 |
* "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
|
3624 |
* 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
|
3625 |
* 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
|
3626 |
* 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
|
3627 |
* 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
|
3628 |
* --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
|
3629 |
/* 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
|
3630 |
* 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
|
3631 |
* 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
|
3632 |
static const SpecialSpriteHandler handlers[][GLS_END] = { |
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
|
3633 |
/* 0x00 */ { NULL, SafeChangeInfo, NULL, NULL, FeatureChangeInfo, }, |
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
|
3634 |
/* 0x01 */ { NULL, GRFUnsafe, NULL, NULL, NewSpriteSet, }, |
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
|
3635 |
/* 0x02 */ { NULL, GRFUnsafe, NULL, NULL, NewSpriteGroup, }, |
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
|
3636 |
/* 0x03 */ { NULL, GRFUnsafe, NULL, NULL, FeatureMapSpriteGroup, }, |
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
|
3637 |
/* 0x04 */ { NULL, NULL, NULL, NULL, FeatureNewName, }, |
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
|
3638 |
/* 0x05 */ { NULL, NULL, NULL, NULL, GraphicsNew, }, |
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
|
3639 |
/* 0x06 */ { NULL, NULL, NULL, CfgApply, CfgApply, }, |
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
|
3640 |
/* 0x07 */ { NULL, NULL, NULL, NULL, SkipIf, }, |
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
|
3641 |
/* 0x08 */ { ScanInfo, NULL, NULL, GRFInfo, GRFInfo, }, |
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
|
3642 |
/* 0x09 */ { NULL, NULL, NULL, SkipIf, SkipIf, }, |
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
|
3643 |
/* 0x0A */ { NULL, NULL, NULL, NULL, SpriteReplace, }, |
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
|
3644 |
/* 0x0B */ { NULL, NULL, NULL, GRFError, GRFError, }, |
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
|
3645 |
/* 0x0C */ { NULL, NULL, NULL, GRFComment, GRFComment, }, |
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
|
3646 |
/* 0x0D */ { NULL, SafeParamSet, NULL, ParamSet, ParamSet, }, |
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
|
3647 |
/* 0x0E */ { NULL, SafeGRFInhibit, NULL, GRFInhibit, GRFInhibit, }, |
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
|
3648 |
/* 0x0F */ { NULL, NULL, NULL, NULL, NULL, }, |
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
|
3649 |
/* 0x10 */ { NULL, NULL, DefineGotoLabel, NULL, NULL, }, |
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
|
3650 |
/* 0x11 */ { NULL, GRFUnsafe, NULL, NULL, GRFSound, }, |
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
|
3651 |
/* 0x12 */ { NULL, NULL, NULL, NULL, LoadFontGlyph, }, |
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
|
3652 |
}; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3653 |
|
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3654 |
byte* buf; |
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
|
3655 |
byte action; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3656 |
|
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3657 |
if (_preload_sprite == NULL) { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3658 |
/* 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
|
3659 |
* 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
|
3660 |
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
|
3661 |
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
|
3662 |
FioReadBlock(buf, num); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3663 |
} else { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3664 |
/* 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
|
3665 |
buf = _preload_sprite; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3666 |
_preload_sprite = NULL; |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3667 |
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
|
3668 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3669 |
/* 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
|
3670 |
FioSeekTo(num, SEEK_CUR); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3671 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3672 |
|
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
|
3673 |
action = buf[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
|
3674 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3675 |
if (action == 0xFF) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3676 |
grfmsg(7, "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
|
3677 |
GRFDataBlock(buf, num); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3678 |
} else if (action == 0xFE) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3679 |
grfmsg(7, "Handling 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
|
3680 |
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
|
3681 |
} else if (action >= lengthof(handlers)) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3682 |
grfmsg(7, "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
|
3683 |
} else if (handlers[action][stage] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3684 |
grfmsg(7, "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
|
3685 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3686 |
grfmsg(7, "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
|
3687 |
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
|
3688 |
} |
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
|
3689 |
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
|
3690 |
} |
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
|
3691 |
|
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
|
3692 |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3693 |
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
|
3694 |
{ |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3695 |
const char *filename = config->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
|
3696 |
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
|
3697 |
|
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
|
3698 |
/* 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
|
3699 |
* 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
|
3700 |
* 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
|
3701 |
* 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
|
3702 |
* 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
|
3703 |
* |
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
|
3704 |
* 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
|
3705 |
* 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
|
3706 |
* 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
|
3707 |
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
|
3708 |
_cur_grffile = GetFileByFilename(filename); |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3709 |
if (_cur_grffile == NULL) error("File '%s' lost in cache.\n", filename); |
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
|
3710 |
if (stage == GLS_ACTIVATION && !HASBIT(config->flags, GCF_ACTIVATED)) 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
|
3711 |
} |
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
|
3712 |
|
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
|
3713 |
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
|
3714 |
_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
|
3715 |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3716 |
_cur_grfconfig = config; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3717 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3718 |
DEBUG(grf, 2, "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
|
3719 |
|
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
|
3720 |
/* 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
|
3721 |
* 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
|
3722 |
* 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
|
3723 |
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
|
3724 |
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
|
3725 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3726 |
DEBUG(grf, 7, "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
|
3727 |
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
|
3728 |
} |
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
|
3729 |
|
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
|
3730 |
_skip_sprites = 0; // XXX |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
3731 |
_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
|
3732 |
|
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
|
3733 |
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
|
3734 |
byte type = FioReadByte(); |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
3735 |
_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
|
3736 |
|
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
|
3737 |
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
|
3738 |
if (_skip_sprites == 0) { |
2958
ac0a9673b522
(svn r3520) Remove unused parameters from some functions
tron
parents:
2935
diff
changeset
|
3739 |
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
|
3740 |
|
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
|
3741 |
/* 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
|
3742 |
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
|
3743 |
|
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
|
3744 |
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
|
3745 |
} 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
|
3746 |
FioSkipBytes(num); |
1611 | 3747 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3748 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3749 |
if (_skip_sprites == 0) grfmsg(7, "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
|
3750 |
|
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
|
3751 |
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
|
3752 |
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
|
3753 |
|
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
|
3754 |
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
|
3755 |
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
|
3756 |
} 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
|
3757 |
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
|
3758 |
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
|
3759 |
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
|
3760 |
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
|
3761 |
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
|
3762 |
} 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
|
3763 |
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
|
3764 |
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
|
3765 |
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
|
3766 |
} |
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
|
3767 |
} |
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
|
3768 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3769 |
} |
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
|
3770 |
|
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
|
3771 |
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
|
3772 |
} |
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
|
3773 |
} |
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
|
3774 |
|
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
|
3775 |
|
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
|
3776 |
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
|
3777 |
{ |
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
|
3778 |
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
|
3779 |
|
2930
99088d4aba31
(svn r3486) - NewGRF fix: Always reinitialize the ttdpatch flags as patch settings may have changed.
peter1138
parents:
2895
diff
changeset
|
3780 |
InitializeGRFSpecial(); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3781 |
|
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
|
3782 |
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
|
3783 |
|
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
|
3784 |
/* 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
|
3785 |
* 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
|
3786 |
* and load information from it. */ |
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
|
3787 |
for (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
|
3788 |
uint slot = file_index; |
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
|
3789 |
GRFConfig *c; |
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
|
3790 |
|
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
|
3791 |
_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
|
3792 |
_cur_spriteid = load_index; |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3793 |
for (c = _grfconfig; c != NULL; c = c->next) { |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3794 |
if (HASBIT(c->flags, GCF_DISABLED) || HASBIT(c->flags, GCF_NOT_FOUND)) continue; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3795 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3796 |
// TODO usererror() |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3797 |
if (!FioCheckFileExists(c->filename)) 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
|
3798 |
|
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
|
3799 |
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
|
3800 |
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
|
3801 |
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
|
3802 |
ClearTemporaryNewGRFData(); |
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
|
3803 |
DEBUG(sprite, 2, "Currently %i sprites are loaded", _cur_spriteid); |
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
|
3804 |
} |
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
|
3805 |
} |
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
|
3806 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3807 |
|
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3808 |
// Pre-calculate all refit masks after loading GRF files |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3809 |
CalculateRefitMasks(); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3810 |
} |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3811 |
|
5400
bba42ad3223b
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5382
diff
changeset
|
3812 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
3813 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
3814 |
|
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
|
3815 |