author | celestar |
Mon, 15 Jan 2007 20:14:06 +0000 | |
branch | custombridgeheads |
changeset 5650 | aefc131bf5ce |
parent 5649 | 55c8267c933f |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
4 |
||
5 |
#include <stdarg.h> |
|
6 |
||
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1883
diff
changeset
|
7 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1183
diff
changeset
|
8 |
#include "debug.h" |
0 | 9 |
#include "gfx.h" |
10 |
#include "fileio.h" |
|
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
11 |
#include "functions.h" |
0 | 12 |
#include "engine.h" |
2342
c19fb4f2df30
(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" |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
14 |
#include "station.h" |
405
6830ae7a0d5d
(svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents:
404
diff
changeset
|
15 |
#include "sprite.h" |
452
520e4ed6945d
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
449
diff
changeset
|
16 |
#include "newgrf.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2013
diff
changeset
|
17 |
#include "variables.h" |
3566
7bdf06a03960
(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
2bb8a2643fdf
(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
16b05f1de6bb
(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
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
21 |
#include "economy.h" |
2962
dbd168a4703a
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2958
diff
changeset
|
22 |
#include "newgrf_engine.h" |
3577
9e345c932ba2
(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
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
24 |
#include "newgrf_text.h" |
3708
1c548218151c
(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
dc67d70b5a45
(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
2c24234a7aec
(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
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
28 |
#include "currency.h" |
4656
acffecd6f484
(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
c4a780348f66
(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
acffecd6f484
(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
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
32 |
#include "newgrf_spritegroup.h" |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
33 |
#include "helpers.hpp" |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
34 |
|
0 | 35 |
/* TTDPatch extended GRF format codec |
36 |
* (c) Petr Baudis 2004 (GPL'd) |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
37 |
* Changes by Florian octo Forster are (c) by the OpenTTD development team. |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
38 |
* |
0 | 39 |
* Contains portions of documentation by TTDPatch team. |
40 |
* Thanks especially to Josef Drexler for the documentation as well as a lot |
|
41 |
* of help at #tycoon. Also thanks to Michael Blunck for is GRF files which |
|
42 |
* served as subject to the initial testing of this codec. */ |
|
43 |
||
455 | 44 |
|
2342
c19fb4f2df30
(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 |
c19fb4f2df30
(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
fa3ad39e2fa7
(svn r7324) -Codechange: reset newgrf signal location data
peter1138
parents:
5161
diff
changeset
|
47 |
SpriteID _signal_base; |
5210
dc52acfad05c
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
48 |
SpriteID _coast_base; |
0 | 49 |
|
2340
0a9f3eeccb96
(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
2999a89e8abd
(svn r4650) - NewGRF: use the correct type for _cur_spriteid
peter1138
parents:
3704
diff
changeset
|
52 |
static SpriteID _cur_spriteid; |
5225
52ddcedcc6f7
(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
29c95ab685c0
(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; |
0 | 55 |
|
5228
c4a780348f66
(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; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
57 |
|
3814
d0b901dfc313
(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 */ |
d0b901dfc313
(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; |
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
60 |
|
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
61 |
/* 32 * 8 = 256 flags. Apparently TTDPatch uses this many.. */ |
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
62 |
static uint32 _ttdpatch_flags[8]; |
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
63 |
|
3895
a67d4451a1df
(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 */ |
a67d4451a1df
(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; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
66 |
|
4742
d5a2d3da5002
(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) */ |
d5a2d3da5002
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
68 |
bool _have_2cc = false; |
d5a2d3da5002
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
69 |
|
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
70 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
71 |
typedef enum GrfDataType { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
72 |
GDT_SOUND, |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
73 |
} GrfDataType; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
74 |
|
acffecd6f484
(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; |
acffecd6f484
(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; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
77 |
|
acffecd6f484
(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 { |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
80 |
GSF_TRAIN, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
81 |
GSF_ROAD, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
82 |
GSF_SHIP, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
83 |
GSF_AIRCRAFT, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
84 |
GSF_STATION, |
2438
eaef2b29fa3d
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
85 |
GSF_CANAL, |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
86 |
GSF_BRIDGE, |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
87 |
GSF_TOWNHOUSE, |
3620
b459e678a003
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
88 |
GSF_GLOBALVAR, |
b459e678a003
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
89 |
GSF_INDUSTRYTILES, |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
90 |
GSF_INDUSTRIES, |
3620
b459e678a003
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
91 |
GSF_CARGOS, |
b459e678a003
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
92 |
GSF_SOUNDFX, |
1477 | 93 |
} grfspec_feature; |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
94 |
|
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
95 |
|
0 | 96 |
typedef void (*SpecialSpriteHandler)(byte *buf, int len); |
97 |
||
4964
0ef1eb7e7f35
(svn r6963) - Fix (r6960): signed/unsigned complaints from MSVC
peter1138
parents:
4961
diff
changeset
|
98 |
static const int _vehcounts[4] = { |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
99 |
/* GSF_TRAIN */ NUM_TRAIN_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
100 |
/* GSF_ROAD */ NUM_ROAD_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
101 |
/* GSF_SHIP */ NUM_SHIP_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
102 |
/* GSF_AIRCRAFT */ NUM_AIRCRAFT_ENGINES |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
103 |
}; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
104 |
|
4964
0ef1eb7e7f35
(svn r6963) - Fix (r6960): signed/unsigned complaints from MSVC
peter1138
parents:
4961
diff
changeset
|
105 |
static const int _vehshifts[4] = { |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
106 |
/* GSF_TRAIN */ 0, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
107 |
/* GSF_ROAD */ ROAD_ENGINES_INDEX, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
108 |
/* GSF_SHIP */ SHIP_ENGINES_INDEX, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
109 |
/* GSF_AIRCRAFT */ AIRCRAFT_ENGINES_INDEX, |
0 | 110 |
}; |
111 |
||
3768
46d328178509
(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 { |
46d328178509
(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, |
46d328178509
(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 |
}; |
46d328178509
(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
65b5313bc525
(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]; |
65b5313bc525
(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]; |
0 | 118 |
|
4961
0ba3cfeaff61
(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 */ |
0ba3cfeaff61
(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]; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
121 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
122 |
/** DEBUG() function dedicated to newGRF debugging messages |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
123 |
* Function is essentialy the same as DEBUG(grf, severity, ...) with the |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
124 |
* addition of file:line information when parsing grf files. |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
125 |
* NOTE: for the above reason(s) grfmsg() should ONLY be used for |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
126 |
* loading/parsing grf files, not for runtime debug messages as there |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
127 |
* is no file information available during that time. |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
128 |
* @param severity debugging severity level, see debug.h |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
129 |
* @param debugging message in printf() format */ |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
130 |
void CDECL grfmsg(int severity, const char *str, ...) |
0 | 131 |
{ |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
51
diff
changeset
|
132 |
char buf[1024]; |
0 | 133 |
va_list va; |
134 |
||
135 |
va_start(va, str); |
|
1477 | 136 |
vsnprintf(buf, sizeof(buf), str, va); |
0 | 137 |
va_end(va); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
138 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
139 |
DEBUG(grf, severity, "[%s:%d] %s", _cur_grfconfig->filename, _nfo_line, buf); |
0 | 140 |
} |
141 |
||
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
142 |
static inline void check_length(int real, int wanted, const char *str) |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
143 |
{ |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
144 |
if (real >= wanted) return; |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
145 |
grfmsg(0, "%s: Invalid pseudo sprite length %d (expected %d)!", str, real, wanted); |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
146 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
147 |
|
500
ef288590e096
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
490
diff
changeset
|
148 |
static inline byte grf_load_byte(byte **buf) |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
149 |
{ |
0 | 150 |
return *(*buf)++; |
151 |
} |
|
152 |
||
153 |
static uint16 grf_load_word(byte **buf) |
|
154 |
{ |
|
3711
4a0d1c635b56
(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
|
155 |
uint16 val = grf_load_byte(buf); |
4a0d1c635b56
(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 |
return val | (grf_load_byte(buf) << 8); |
0 | 157 |
} |
158 |
||
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
159 |
static uint16 grf_load_extended(byte** buf) |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
160 |
{ |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
161 |
uint16 val; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
162 |
val = grf_load_byte(buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
163 |
if (val == 0xFF) val = grf_load_word(buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
164 |
return val; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
165 |
} |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
166 |
|
2324 | 167 |
static uint32 grf_load_dword(byte **buf) |
0 | 168 |
{ |
3711
4a0d1c635b56
(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
|
169 |
uint32 val = grf_load_word(buf); |
4a0d1c635b56
(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 |
return val | (grf_load_word(buf) << 16); |
0 | 171 |
} |
172 |
||
3668
d7ed0a867b49
(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
|
173 |
static uint32 grf_load_var(byte size, byte **buf) |
d7ed0a867b49
(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 |
{ |
d7ed0a867b49
(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 |
switch (size) { |
d7ed0a867b49
(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 |
case 1: return grf_load_byte(buf); |
d7ed0a867b49
(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 2: return grf_load_word(buf); |
d7ed0a867b49
(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 4: return grf_load_dword(buf); |
d7ed0a867b49
(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 |
default: |
d7ed0a867b49
(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 |
NOT_REACHED(); |
d7ed0a867b49
(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 |
return 0; |
d7ed0a867b49
(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 |
} |
d7ed0a867b49
(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 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
184 |
|
1477 | 185 |
static GRFFile *GetFileByGRFID(uint32 grfid) |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
186 |
{ |
1477 | 187 |
GRFFile *file; |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
188 |
|
1477 | 189 |
for (file = _first_grffile; file != NULL; file = file->next) { |
190 |
if (file->grfid == grfid) break; |
|
191 |
} |
|
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
192 |
return file; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
193 |
} |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
194 |
|
1477 | 195 |
static GRFFile *GetFileByFilename(const char *filename) |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
196 |
{ |
1477 | 197 |
GRFFile *file; |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
198 |
|
1477 | 199 |
for (file = _first_grffile; file != NULL; file = file->next) { |
200 |
if (strcmp(file->filename, filename) == 0) break; |
|
201 |
} |
|
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
202 |
return file; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
203 |
} |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
204 |
|
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
205 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
206 |
typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); |
0 | 207 |
|
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
208 |
#define FOR_EACH_OBJECT for (i = 0; i < numinfo; i++) |
0 | 209 |
|
210 |
static void dewagonize(int condition, int engine) |
|
211 |
{ |
|
212 |
EngineInfo *ei = &_engine_info[engine]; |
|
213 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
|
214 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
215 |
if (condition != 0) { |
0 | 216 |
ei->unk2 &= ~0x80; |
217 |
rvi->flags &= ~2; |
|
218 |
} else { |
|
219 |
ei->unk2 |= 0x80; |
|
220 |
rvi->flags |= 2; |
|
221 |
} |
|
222 |
} |
|
223 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
224 |
static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 225 |
{ |
226 |
EngineInfo *ei = &_engine_info[engine]; |
|
227 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
|
228 |
byte *buf = *bufp; |
|
229 |
int i; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
230 |
bool ret = false; |
0 | 231 |
|
232 |
switch (prop) { |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
233 |
case 0x05: /* Track type */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
234 |
FOR_EACH_OBJECT { |
0 | 235 |
uint8 tracktype = grf_load_byte(&buf); |
236 |
||
3026
6401a6942660
(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
|
237 |
switch (tracktype) { |
5115
06bf0b853f81
(svn r7194) -Fix (FS#237): the electric rail type was not set correctly for NewGRFs where the engine traction type was set before the track type of the trains.
rubidium
parents:
5114
diff
changeset
|
238 |
case 0: ei[i].railtype = rvi[i].engclass == 2 ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; break; |
3026
6401a6942660
(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
|
239 |
case 1: ei[i].railtype = RAILTYPE_MONO; break; |
6401a6942660
(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
|
240 |
case 2: ei[i].railtype = RAILTYPE_MAGLEV; break; |
6401a6942660
(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
|
241 |
default: |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
242 |
grfmsg(1, "RailVehicleChangeInfo: Invalid track type %d specified, ignoring", tracktype); |
3026
6401a6942660
(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
|
243 |
break; |
6401a6942660
(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 |
} |
0 | 245 |
} |
3026
6401a6942660
(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
|
246 |
break; |
6401a6942660
(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 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
248 |
case 0x08: /* AI passenger service */ |
0 | 249 |
/* TODO */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
250 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
251 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
252 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
253 |
|
3488
d1d5c0f3f69d
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
254 |
case 0x09: /* Speed (1 unit is 1 kmh) */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
255 |
FOR_EACH_OBJECT { |
0 | 256 |
uint16 speed = grf_load_word(&buf); |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
257 |
if (speed == 0xFFFF) speed = 0; |
0 | 258 |
|
259 |
rvi[i].max_speed = speed; |
|
260 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
261 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
262 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
263 |
case 0x0B: /* Power */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
264 |
FOR_EACH_OBJECT { |
0 | 265 |
uint16 power = grf_load_word(&buf); |
266 |
||
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
267 |
if (rvi[i].flags & RVI_MULTIHEAD) power /= 2; |
1894
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
268 |
|
0 | 269 |
rvi[i].power = power; |
270 |
dewagonize(power, engine + i); |
|
271 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
272 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
273 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
274 |
case 0x0D: /* Running cost factor */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
275 |
FOR_EACH_OBJECT { |
0 | 276 |
uint8 runcostfact = grf_load_byte(&buf); |
277 |
||
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
278 |
if (rvi[i].flags & RVI_MULTIHEAD) runcostfact /= 2; |
2836
b5e8424f5955
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
279 |
|
0 | 280 |
rvi[i].running_cost_base = runcostfact; |
281 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
282 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
283 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
284 |
case 0x0E: /* Running cost base */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
285 |
FOR_EACH_OBJECT { |
0 | 286 |
uint32 base = grf_load_dword(&buf); |
287 |
||
288 |
switch (base) { |
|
2840
d68a605b2087
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2838
diff
changeset
|
289 |
case 0x4C30: rvi[i].running_cost_class = 0; break; |
d68a605b2087
(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 0x4C36: rvi[i].running_cost_class = 1; break; |
d68a605b2087
(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 0x4C3C: rvi[i].running_cost_class = 2; break; |
5324
b2429a2def00
(svn r7485) -Codechange: [NewGRF] Add debug warning for unsupported running cost bases for rail vehicles.
peter1138
parents:
5317
diff
changeset
|
292 |
case 0: break; /* Used by wagons */ |
b2429a2def00
(svn r7485) -Codechange: [NewGRF] Add debug warning for unsupported running cost bases for rail vehicles.
peter1138
parents:
5317
diff
changeset
|
293 |
default: |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
294 |
grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base); |
5324
b2429a2def00
(svn r7485) -Codechange: [NewGRF] Add debug warning for unsupported running cost bases for rail vehicles.
peter1138
parents:
5317
diff
changeset
|
295 |
break; |
0 | 296 |
} |
297 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
298 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
299 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
300 |
case 0x12: /* Sprite ID */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
301 |
FOR_EACH_OBJECT { |
0 | 302 |
uint8 spriteid = grf_load_byte(&buf); |
303 |
||
2895
943612f25754
(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
|
304 |
/* TTD sprite IDs point to a location in a 16bit array, but we use it |
943612f25754
(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 |
* as an array index, so we need it to be half the original value. */ |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
306 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
943612f25754
(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
|
307 |
|
0 | 308 |
rvi[i].image_index = spriteid; |
309 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
310 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
311 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
312 |
case 0x13: /* Dual-headed */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
313 |
FOR_EACH_OBJECT { |
0 | 314 |
uint8 dual = grf_load_byte(&buf); |
315 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
316 |
if (dual != 0) { |
2836
b5e8424f5955
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
317 |
if (!(rvi[i].flags & RVI_MULTIHEAD)) { |
b5e8424f5955
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
318 |
// adjust power and running cost if needed |
1894
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
319 |
rvi[i].power /= 2; |
2836
b5e8424f5955
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
320 |
rvi[i].running_cost_base /= 2; |
b5e8424f5955
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
321 |
} |
1894
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
322 |
rvi[i].flags |= RVI_MULTIHEAD; |
0 | 323 |
} else { |
2836
b5e8424f5955
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
324 |
if (rvi[i].flags & RVI_MULTIHEAD) { |
b5e8424f5955
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
325 |
// adjust power and running cost if needed |
1894
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
326 |
rvi[i].power *= 2; |
2840
d68a605b2087
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2838
diff
changeset
|
327 |
rvi[i].running_cost_base *= 2; |
2836
b5e8424f5955
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
328 |
} |
1894
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
329 |
rvi[i].flags &= ~RVI_MULTIHEAD; |
0 | 330 |
} |
331 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
332 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
333 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
334 |
case 0x14: /* Cargo capacity */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
335 |
FOR_EACH_OBJECT rvi[i].capacity = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
336 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
337 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
338 |
case 0x15: /* Cargo type */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
339 |
FOR_EACH_OBJECT { |
0 | 340 |
uint8 ctype = grf_load_byte(&buf); |
341 |
||
2846
ac8731dd4121
(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
|
342 |
if (ctype < NUM_CARGO) { |
ac8731dd4121
(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
|
343 |
rvi[i].cargo_type = ctype; |
ac8731dd4121
(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 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
345 |
grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, ignoring", ctype); |
2846
ac8731dd4121
(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 |
} |
0 | 347 |
} |
3023
e56ff3134c77
(svn r3603) - NewGRF: Support loading of AI rank data
peter1138
parents:
3006
diff
changeset
|
348 |
break; |
e56ff3134c77
(svn r3603) - NewGRF: Support loading of AI rank data
peter1138
parents:
3006
diff
changeset
|
349 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
350 |
case 0x16: /* Weight */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
351 |
FOR_EACH_OBJECT SB(rvi[i].weight, 0, 8, grf_load_byte(&buf)); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
352 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
353 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
354 |
case 0x17: /* Cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
355 |
FOR_EACH_OBJECT rvi[i].base_cost = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
356 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
357 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
358 |
case 0x18: /* AI rank */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
359 |
FOR_EACH_OBJECT rvi[i].ai_rank = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
360 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
361 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
362 |
case 0x19: /* Engine traction type */ |
2838
7d6a3195f87d
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
363 |
/* What do the individual numbers mean? |
7d6a3195f87d
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
364 |
* 0x00 .. 0x07: Steam |
7d6a3195f87d
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
365 |
* 0x08 .. 0x27: Diesel |
7d6a3195f87d
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
366 |
* 0x28 .. 0x31: Electric |
7d6a3195f87d
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
367 |
* 0x32 .. 0x37: Monorail |
7d6a3195f87d
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
368 |
* 0x38 .. 0x41: Maglev |
7d6a3195f87d
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
369 |
*/ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
370 |
FOR_EACH_OBJECT { |
0 | 371 |
uint8 traction = grf_load_byte(&buf); |
372 |
int engclass; |
|
373 |
||
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
374 |
if (traction <= 0x07) { |
0 | 375 |
engclass = 0; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
376 |
} else if (traction <= 0x27) { |
0 | 377 |
engclass = 1; |
3355
a653b8e47f27
(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
|
378 |
} else if (traction <= 0x31) { |
a653b8e47f27
(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
|
379 |
engclass = 2; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
380 |
} else if (traction <= 0x41) { |
0 | 381 |
engclass = 2; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
382 |
} else { |
0 | 383 |
break; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
384 |
} |
5115
06bf0b853f81
(svn r7194) -Fix (FS#237): the electric rail type was not set correctly for NewGRFs where the engine traction type was set before the track type of the trains.
rubidium
parents:
5114
diff
changeset
|
385 |
if (ei[i].railtype == RAILTYPE_RAIL && engclass == 2) ei[i].railtype = RAILTYPE_ELECTRIC; |
06bf0b853f81
(svn r7194) -Fix (FS#237): the electric rail type was not set correctly for NewGRFs where the engine traction type was set before the track type of the trains.
rubidium
parents:
5114
diff
changeset
|
386 |
if (ei[i].railtype == RAILTYPE_ELECTRIC && engclass != 2) ei[i].railtype = RAILTYPE_RAIL; |
0 | 387 |
|
388 |
rvi[i].engclass = engclass; |
|
389 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
390 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
391 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
392 |
case 0x1A: /* Alter purchase list sort order */ |
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
393 |
FOR_EACH_OBJECT { |
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
394 |
EngineID pos = grf_load_byte(&buf); |
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
395 |
|
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
396 |
if (pos < NUM_TRAIN_ENGINES) { |
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
397 |
AlterRailVehListOrder(engine + i, pos); |
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
398 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
399 |
grfmsg(2, "RailVehicleChangeInfo: Invalid train engine ID %d, ignoring", pos); |
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
400 |
} |
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
401 |
} |
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
402 |
break; |
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
403 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
404 |
case 0x1B: /* Powered wagons power bonus */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
405 |
FOR_EACH_OBJECT rvi[i].pow_wag_power = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
406 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
407 |
|
3997
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
408 |
case 0x1C: /* Refit cost */ |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
409 |
FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
410 |
break; |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
411 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
412 |
case 0x1D: /* Refit cargo */ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
413 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
414 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
415 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
416 |
case 0x1E: /* Callback */ |
3956
0f43adbc293a
(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
|
417 |
FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
418 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
419 |
|
5588
1bcb6b4c01d8
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5570
diff
changeset
|
420 |
case 0x1F: /* Tractive effort coefficient */ |
1bcb6b4c01d8
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5570
diff
changeset
|
421 |
FOR_EACH_OBJECT rvi[i].tractive_effort = grf_load_byte(&buf); |
1bcb6b4c01d8
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5570
diff
changeset
|
422 |
break; |
1bcb6b4c01d8
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5570
diff
changeset
|
423 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
424 |
case 0x21: /* Shorter vehicle */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
425 |
FOR_EACH_OBJECT rvi[i].shorten_factor = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
426 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
427 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
428 |
case 0x22: /* Visual effect */ |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
429 |
// see note in engine.h about rvi->visual_effect |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
430 |
FOR_EACH_OBJECT rvi[i].visual_effect = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
431 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
432 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
433 |
case 0x23: /* Powered wagons weight bonus */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
434 |
FOR_EACH_OBJECT rvi[i].pow_wag_weight = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
435 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
436 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
437 |
case 0x24: /* High byte of vehicle weight */ |
2542
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
438 |
FOR_EACH_OBJECT { |
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
439 |
byte weight = grf_load_byte(&buf); |
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
440 |
|
2545
d1965652e523
(svn r3074) -NewGrf: Fix stupid typo in weight setting.
peter1138
parents:
2542
diff
changeset
|
441 |
if (weight > 4) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
442 |
grfmsg(2, "RailVehicleChangeInfo: Nonsensical weight of %d tons, ignoring", weight << 8); |
2542
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
443 |
} else { |
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
444 |
SB(rvi[i].weight, 8, 8, weight); |
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
445 |
} |
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
446 |
} |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
447 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
448 |
|
3862
898c8212afa1
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
peter1138
parents:
3845
diff
changeset
|
449 |
case 0x25: /* User-defined bit mask to set when checking veh. var. 42 */ |
898c8212afa1
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
peter1138
parents:
3845
diff
changeset
|
450 |
FOR_EACH_OBJECT rvi[i].user_def_data = grf_load_byte(&buf); |
898c8212afa1
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
peter1138
parents:
3845
diff
changeset
|
451 |
break; |
898c8212afa1
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
peter1138
parents:
3845
diff
changeset
|
452 |
|
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
453 |
case 0x27: /* Miscellaneous flags */ |
4742
d5a2d3da5002
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
454 |
FOR_EACH_OBJECT { |
d5a2d3da5002
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
455 |
ei[i].misc_flags = grf_load_byte(&buf); |
d5a2d3da5002
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
456 |
if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
d5a2d3da5002
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
457 |
} |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
458 |
break; |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
459 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
460 |
case 0x28: /* Cargo classes allowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
461 |
FOR_EACH_OBJECT cargo_allowed[engine + i] = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
462 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
463 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
464 |
case 0x29: /* Cargo classes disallowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
465 |
FOR_EACH_OBJECT cargo_disallowed[engine + i] = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
466 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
467 |
|
5114
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
468 |
case 0x2A: /* Long format introduction date (days since year 0) */ |
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
469 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
2a29f37a7c1e
(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 |
break; |
2a29f37a7c1e
(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 |
|
0 | 472 |
/* TODO */ |
473 |
/* Fall-through for unimplemented one byte long properties. */ |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
474 |
case 0x20: /* Air drag */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
475 |
case 0x26: /* Retire vehicle early */ |
0 | 476 |
/* TODO */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
477 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
478 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
479 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
480 |
|
0 | 481 |
default: |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
482 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
483 |
break; |
0 | 484 |
} |
485 |
*bufp = buf; |
|
486 |
return ret; |
|
487 |
} |
|
488 |
||
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
489 |
static bool RoadVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
490 |
{ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
491 |
EngineInfo *ei = &_engine_info[ROAD_ENGINES_INDEX + engine]; |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
492 |
RoadVehicleInfo *rvi = &_road_vehicle_info[engine]; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
493 |
byte *buf = *bufp; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
494 |
int i; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
495 |
bool ret = false; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
496 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
497 |
switch (prop) { |
3488
d1d5c0f3f69d
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
498 |
case 0x08: /* Speed (1 unit is 0.5 kmh) */ |
d1d5c0f3f69d
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
499 |
FOR_EACH_OBJECT rvi[i].max_speed = grf_load_byte(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
500 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
501 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
502 |
case 0x09: /* Running cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
503 |
FOR_EACH_OBJECT rvi[i].running_cost = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
504 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
505 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
506 |
case 0x0A: /* Running cost base */ |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
507 |
/* TODO: I have no idea. --pasky */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
508 |
FOR_EACH_OBJECT grf_load_dword(&buf); |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
509 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
510 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
511 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
512 |
case 0x0E: /* Sprite ID */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
513 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
514 |
uint8 spriteid = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
515 |
|
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
516 |
// cars have different custom id in the GRF file |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
517 |
if (spriteid == 0xFF) spriteid = 0xFD; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
518 |
|
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
519 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
943612f25754
(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
|
520 |
|
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
521 |
rvi[i].image_index = spriteid; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
522 |
} |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
523 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
524 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
525 |
case 0x0F: /* Cargo capacity */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
526 |
FOR_EACH_OBJECT rvi[i].capacity = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
527 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
528 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
529 |
case 0x10: /* Cargo type */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
530 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
531 |
uint8 cargo = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
532 |
|
2846
ac8731dd4121
(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
|
533 |
if (cargo < NUM_CARGO) { |
ac8731dd4121
(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
|
534 |
rvi[i].cargo_type = cargo; |
ac8731dd4121
(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 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
536 |
grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, ignoring", cargo); |
2846
ac8731dd4121
(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 |
} |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
538 |
} |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
539 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
540 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
541 |
case 0x11: /* Cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
542 |
FOR_EACH_OBJECT rvi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
543 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
544 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
545 |
case 0x12: /* SFX */ |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
546 |
FOR_EACH_OBJECT rvi[i].sfx = (SoundFx)grf_load_byte(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
547 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
548 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
549 |
case 0x13: /* Power in 10hp */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
550 |
case 0x14: /* Weight in 1/4 tons */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
551 |
case 0x15: /* Speed in mph*0.8 */ |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
552 |
/* TODO: Support for road vehicles realistic power |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
553 |
* computations (called rvpower in TTDPatch) is just |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
554 |
* missing in OTTD yet. --pasky */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
555 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
556 |
ret = true; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
557 |
break; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
558 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
559 |
case 0x16: /* Cargos available for refitting */ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
560 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3006
f106b4538f41
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
561 |
break; |
f106b4538f41
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
562 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
563 |
case 0x17: /* Callback mask */ |
3956
0f43adbc293a
(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
|
564 |
FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
565 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
566 |
|
3997
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
567 |
case 0x1A: /* Refit cost */ |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
568 |
FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
569 |
break; |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
570 |
|
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
571 |
case 0x1C: /* Miscellaneous flags */ |
4952
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
572 |
FOR_EACH_OBJECT { |
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
573 |
ei[i].misc_flags = grf_load_byte(&buf); |
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
574 |
if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
575 |
} |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
576 |
break; |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
577 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
578 |
case 0x1D: /* Cargo classes allowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
579 |
FOR_EACH_OBJECT cargo_allowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
580 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
581 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
582 |
case 0x1E: /* Cargo classes disallowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
583 |
FOR_EACH_OBJECT cargo_disallowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
584 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
585 |
|
5114
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
586 |
case 0x1F: /* Long format introduction date (days since year 0) */ |
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
587 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
2a29f37a7c1e
(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 |
break; |
2a29f37a7c1e
(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 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
590 |
case 0x18: /* Tractive effort */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
591 |
case 0x19: /* Air drag */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
592 |
case 0x1B: /* Retire vehicle early */ |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
593 |
/* TODO */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
594 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
595 |
ret = true; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
596 |
break; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
597 |
|
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
598 |
default: |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
599 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
600 |
break; |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
601 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
602 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
603 |
*bufp = buf; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
604 |
return ret; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
605 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
606 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
607 |
static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 608 |
{ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
609 |
EngineInfo *ei = &_engine_info[SHIP_ENGINES_INDEX + engine]; |
0 | 610 |
ShipVehicleInfo *svi = &_ship_vehicle_info[engine]; |
611 |
byte *buf = *bufp; |
|
612 |
int i; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
613 |
bool ret = false; |
0 | 614 |
|
615 |
//printf("e %x prop %x?\n", engine, prop); |
|
616 |
switch (prop) { |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
617 |
case 0x08: /* Sprite ID */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
618 |
FOR_EACH_OBJECT { |
0 | 619 |
uint8 spriteid = grf_load_byte(&buf); |
620 |
||
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
621 |
// ships have different custom id in the GRF file |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
622 |
if (spriteid == 0xFF) spriteid = 0xFD; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
623 |
|
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
624 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
943612f25754
(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
|
625 |
|
0 | 626 |
svi[i].image_index = spriteid; |
627 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
628 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
629 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
630 |
case 0x09: /* Refittable */ |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
631 |
FOR_EACH_OBJECT svi[i].refittable = (grf_load_byte(&buf) != 0); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
632 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
633 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
634 |
case 0x0A: /* Cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
635 |
FOR_EACH_OBJECT svi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
636 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
637 |
|
3488
d1d5c0f3f69d
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
638 |
case 0x0B: /* Speed (1 unit is 0.5 kmh) */ |
d1d5c0f3f69d
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
639 |
FOR_EACH_OBJECT svi[i].max_speed = grf_load_byte(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
640 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
641 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
642 |
case 0x0C: /* Cargo type */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
643 |
FOR_EACH_OBJECT { |
0 | 644 |
uint8 cargo = grf_load_byte(&buf); |
645 |
||
646 |
// XXX: Need to consult this with patchman yet. |
|
647 |
#if 0 |
|
648 |
// Documentation claims this is already the |
|
649 |
// per-landscape cargo type id, but newships.grf |
|
650 |
// assume otherwise. |
|
651 |
cargo = local_cargo_id_ctype[cargo]; |
|
652 |
#endif |
|
2846
ac8731dd4121
(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
|
653 |
if (cargo < NUM_CARGO) { |
ac8731dd4121
(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
|
654 |
svi[i].cargo_type = cargo; |
ac8731dd4121
(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 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
656 |
grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, ignoring", cargo); |
2846
ac8731dd4121
(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 |
} |
0 | 658 |
} |
3006
f106b4538f41
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
659 |
break; |
f106b4538f41
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
660 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
661 |
case 0x0D: /* Cargo capacity */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
662 |
FOR_EACH_OBJECT svi[i].capacity = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
663 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
664 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
665 |
case 0x0F: /* Running cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
666 |
FOR_EACH_OBJECT svi[i].running_cost = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
667 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
668 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
669 |
case 0x10: /* SFX */ |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
670 |
FOR_EACH_OBJECT svi[i].sfx = (SoundFx)grf_load_byte(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
671 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
672 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
673 |
case 0x11: /* Cargos available for refitting */ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
674 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
675 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
676 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
677 |
case 0x12: /* Callback mask */ |
3956
0f43adbc293a
(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
|
678 |
FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
679 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
680 |
|
3997
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
681 |
case 0x13: /* Refit cost */ |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
682 |
FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
683 |
break; |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
684 |
|
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
685 |
case 0x17: /* Miscellaneous flags */ |
4952
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
686 |
FOR_EACH_OBJECT { |
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
687 |
ei[i].misc_flags = grf_load_byte(&buf); |
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
688 |
if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
689 |
} |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
690 |
break; |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
691 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
692 |
case 0x18: /* Cargo classes allowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
693 |
FOR_EACH_OBJECT cargo_allowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
694 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
695 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
696 |
case 0x19: /* Cargo classes disallowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
697 |
FOR_EACH_OBJECT cargo_disallowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
698 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
699 |
|
5114
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
700 |
case 0x1A: /* Long format introduction date (days since year 0) */ |
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
701 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
2a29f37a7c1e
(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 |
break; |
2a29f37a7c1e
(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 |
|
1872
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
704 |
case 0x14: /* Ocean speed fraction */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
705 |
case 0x15: /* Canal speed fraction */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
706 |
case 0x16: /* Retire vehicle early */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
707 |
/* TODO */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
708 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
709 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
710 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
711 |
|
0 | 712 |
default: |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
713 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
714 |
break; |
0 | 715 |
} |
716 |
||
717 |
*bufp = buf; |
|
718 |
return ret; |
|
719 |
} |
|
720 |
||
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
721 |
static bool AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
722 |
{ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
723 |
EngineInfo *ei = &_engine_info[AIRCRAFT_ENGINES_INDEX + engine]; |
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
724 |
AircraftVehicleInfo *avi = &_aircraft_vehicle_info[engine]; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
725 |
byte *buf = *bufp; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
726 |
int i; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
727 |
bool ret = false; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
728 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
729 |
//printf("e %x prop %x?\n", engine, prop); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
730 |
switch (prop) { |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
731 |
case 0x08: /* Sprite ID */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
732 |
FOR_EACH_OBJECT { |
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
733 |
uint8 spriteid = grf_load_byte(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
734 |
|
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
735 |
// aircraft have different custom id in the GRF file |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
736 |
if (spriteid == 0xFF) spriteid = 0xFD; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
737 |
|
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
738 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
943612f25754
(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
|
739 |
|
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
740 |
avi[i].image_index = spriteid; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
741 |
} |
3006
f106b4538f41
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
742 |
break; |
f106b4538f41
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
743 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
744 |
case 0x09: /* Helicopter */ |
4926
f67f27fb122f
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
745 |
FOR_EACH_OBJECT { |
f67f27fb122f
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
746 |
if (grf_load_byte(&buf) == 0) { |
f67f27fb122f
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
747 |
avi[i].subtype = 0; |
f67f27fb122f
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
748 |
} else { |
f67f27fb122f
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
749 |
SB(avi[i].subtype, 0, 1, 1); |
f67f27fb122f
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
750 |
} |
f67f27fb122f
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
751 |
} |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
752 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
753 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
754 |
case 0x0A: /* Large */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
755 |
FOR_EACH_OBJECT SB(avi[i].subtype, 1, 1, (grf_load_byte(&buf) != 0 ? 1 : 0)); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
756 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
757 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
758 |
case 0x0B: /* Cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
759 |
FOR_EACH_OBJECT avi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
760 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
761 |
|
3488
d1d5c0f3f69d
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
762 |
case 0x0C: /* Speed (1 unit is 8 mph) */ |
d1d5c0f3f69d
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
763 |
FOR_EACH_OBJECT avi[i].max_speed = grf_load_byte(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
764 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
765 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
766 |
case 0x0D: /* Acceleration */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
767 |
FOR_EACH_OBJECT avi[i].acceleration = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
768 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
769 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
770 |
case 0x0E: /* Running cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
771 |
FOR_EACH_OBJECT avi[i].running_cost = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
772 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
773 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
774 |
case 0x0F: /* Passenger capacity */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
775 |
FOR_EACH_OBJECT avi[i].passenger_capacity = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
776 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
777 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
778 |
case 0x11: /* Mail capacity */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
779 |
FOR_EACH_OBJECT avi[i].mail_capacity = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
780 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
781 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
782 |
case 0x12: /* SFX */ |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
783 |
FOR_EACH_OBJECT avi[i].sfx = (SoundFx)grf_load_byte(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
784 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
785 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
786 |
case 0x13: /* Cargos available for refitting */ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
787 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
788 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
789 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
790 |
case 0x14: /* Callback mask */ |
3956
0f43adbc293a
(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
|
791 |
FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
792 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
793 |
|
3997
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
794 |
case 0x15: /* Refit cost */ |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
795 |
FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
796 |
break; |
29c77eab14a4
(svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents:
3956
diff
changeset
|
797 |
|
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
798 |
case 0x17: /* Miscellaneous flags */ |
4952
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
799 |
FOR_EACH_OBJECT { |
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
800 |
ei[i].misc_flags = grf_load_byte(&buf); |
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
801 |
if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
8f4969f51719
(svn r6946) - Fix (r6654): This applies to all vehicle types, not just rail vehicles... (mart3p)
peter1138
parents:
4926
diff
changeset
|
802 |
} |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
803 |
break; |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
804 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
805 |
case 0x18: /* Cargo classes allowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
806 |
FOR_EACH_OBJECT cargo_allowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
807 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
808 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
809 |
case 0x19: /* Cargo classes disallowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
810 |
FOR_EACH_OBJECT cargo_disallowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
811 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
812 |
|
5114
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
813 |
case 0x1A: /* Long format introduction date (days since year 0) */ |
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
814 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
2a29f37a7c1e
(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 |
break; |
2a29f37a7c1e
(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 |
|
1872
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
817 |
case 0x16: /* Retire vehicle early */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
818 |
/* TODO */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
819 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
820 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
821 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
822 |
|
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
823 |
default: |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
824 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
825 |
break; |
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
826 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
827 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
828 |
*bufp = buf; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
829 |
return ret; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
830 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
831 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
832 |
static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int len) |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
833 |
{ |
3768
46d328178509
(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
|
834 |
StationSpec **statspec; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
835 |
byte *buf = *bufp; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
836 |
int i; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
837 |
bool ret = false; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
838 |
|
3768
46d328178509
(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
|
839 |
if (stid + numinfo > MAX_STATIONS) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
840 |
grfmsg(1, "StationChangeInfo: Station %u is invalid, max %u, ignoring", stid + numinfo, MAX_STATIONS); |
3768
46d328178509
(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 |
return false; |
46d328178509
(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
|
842 |
} |
46d328178509
(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 |
|
3501
cf7d2c33e7fc
(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
|
844 |
/* Allocate station specs if necessary */ |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
845 |
if (_cur_grffile->stations == NULL) CallocT(&_cur_grffile->stations, MAX_STATIONS); |
3768
46d328178509
(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
|
846 |
|
46d328178509
(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
|
847 |
statspec = &_cur_grffile->stations[stid]; |
46d328178509
(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 |
|
46d328178509
(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 |
if (prop != 0x08) { |
46d328178509
(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 |
/* Check that all stations we are modifying are defined. */ |
46d328178509
(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 |
FOR_EACH_OBJECT { |
46d328178509
(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 |
if (statspec[i] == NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
853 |
grfmsg(2, "StationChangeInfo: Attempt to modify undefined station %u, ignoring", stid + i); |
3768
46d328178509
(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 |
return false; |
46d328178509
(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
|
855 |
} |
3501
cf7d2c33e7fc
(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
|
856 |
} |
cf7d2c33e7fc
(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
|
857 |
} |
cf7d2c33e7fc
(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 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
859 |
switch (prop) { |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
860 |
case 0x08: /* Class ID */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
861 |
FOR_EACH_OBJECT { |
3768
46d328178509
(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
|
862 |
uint32 classid; |
46d328178509
(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
|
863 |
|
46d328178509
(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 |
/* Property 0x08 is special; it is where the station is allocated */ |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
865 |
if (statspec[i] == NULL) CallocT(&statspec[i], 1); |
3768
46d328178509
(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 |
|
3711
4a0d1c635b56
(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
|
867 |
/* Swap classid because we read it in BE meaning WAYP or DFLT */ |
3768
46d328178509
(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 |
classid = grf_load_dword(&buf); |
46d328178509
(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
|
869 |
statspec[i]->sclass = AllocateStationClass(BSWAP32(classid)); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
870 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
871 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
872 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
873 |
case 0x09: /* Define sprite layout */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
874 |
FOR_EACH_OBJECT { |
3768
46d328178509
(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
|
875 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
3570
f9749bae861e
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
876 |
uint t; |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
877 |
|
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
878 |
statspec->tiles = grf_load_extended(&buf); |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
879 |
CallocT(&statspec->renderdata, statspec->tiles); |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
880 |
statspec->copied_renderdata = false; |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
881 |
|
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
882 |
for (t = 0; t < statspec->tiles; t++) { |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
883 |
DrawTileSprites *dts = &statspec->renderdata[t]; |
3570
f9749bae861e
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
884 |
uint seq_count = 0; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
885 |
|
3737
26341085bbbf
(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
|
886 |
dts->seq = NULL; |
3775
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
887 |
dts->ground_sprite = grf_load_dword(&buf); |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
888 |
if (dts->ground_sprite == 0) continue; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
889 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
890 |
while (buf < *bufp + len) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
891 |
DrawTileSeqStruct *dtss; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
892 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
893 |
// no relative bounding box support |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
894 |
ReallocT((DrawTileSeqStruct**)&dts->seq, ++seq_count); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
895 |
dtss = (DrawTileSeqStruct*) &dts->seq[seq_count - 1]; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
896 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
897 |
dtss->delta_x = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
898 |
if ((byte) dtss->delta_x == 0x80) break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
899 |
dtss->delta_y = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
900 |
dtss->delta_z = grf_load_byte(&buf); |
4230
cd86b1c47f33
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
901 |
dtss->size_x = grf_load_byte(&buf); |
cd86b1c47f33
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
902 |
dtss->size_y = grf_load_byte(&buf); |
cd86b1c47f33
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
903 |
dtss->size_z = grf_load_byte(&buf); |
3771
b34d07131ad1
(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
|
904 |
dtss->image = grf_load_dword(&buf); |
b34d07131ad1
(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
|
905 |
|
3775
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
906 |
/* Remap flags as ours collide */ |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
907 |
if (HASBIT(dtss->image, 31)) { |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
908 |
CLRBIT(dtss->image, 31); |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
909 |
SETBIT(dtss->image, 30); |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
910 |
} |
3771
b34d07131ad1
(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
|
911 |
if (HASBIT(dtss->image, 14)) { |
b34d07131ad1
(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
|
912 |
CLRBIT(dtss->image, 14); |
b34d07131ad1
(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 |
SETBIT(dtss->image, 31); |
b34d07131ad1
(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
|
914 |
} |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
915 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
916 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
917 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
918 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
919 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
920 |
case 0x0A: /* Copy sprite layout */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
921 |
FOR_EACH_OBJECT { |
3768
46d328178509
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
922 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
923 |
byte srcid = grf_load_byte(&buf); |
3768
46d328178509
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
924 |
const StationSpec *srcstatspec = _cur_grffile->stations[srcid]; |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
925 |
|
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
926 |
statspec->tiles = srcstatspec->tiles; |
3738
d41775f0f3fb
(svn r4720) - Newstations: instead of literally copying sprite layout data, just copy the pointer to the existing data.
peter1138
parents:
3737
diff
changeset
|
927 |
statspec->renderdata = srcstatspec->renderdata; |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
928 |
statspec->copied_renderdata = true; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
929 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
930 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
931 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
932 |
case 0x0B: /* Callback mask */ |
3768
46d328178509
(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
|
933 |
FOR_EACH_OBJECT statspec[i]->callbackmask = grf_load_byte(&buf); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
934 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
935 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
936 |
case 0x0C: /* Disallowed number of platforms */ |
3768
46d328178509
(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 |
FOR_EACH_OBJECT statspec[i]->disallowed_platforms = grf_load_byte(&buf); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
938 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
939 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
940 |
case 0x0D: /* Disallowed platform lengths */ |
3768
46d328178509
(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
|
941 |
FOR_EACH_OBJECT statspec[i]->disallowed_lengths = grf_load_byte(&buf); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
942 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
943 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
944 |
case 0x0E: /* Define custom layout */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
945 |
FOR_EACH_OBJECT { |
3768
46d328178509
(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 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
947 |
|
5060
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
948 |
statspec->copied_layouts = false; |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
949 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
950 |
while (buf < *bufp + len) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
951 |
byte length = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
952 |
byte number = grf_load_byte(&buf); |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
953 |
StationLayout layout; |
3570
f9749bae861e
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
954 |
uint l, p; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
955 |
|
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
956 |
if (length == 0 || number == 0) break; |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
957 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
958 |
//debug("l %d > %d ?", length, stat->lengths); |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
959 |
if (length > statspec->lengths) { |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
960 |
ReallocT(&statspec->platforms, length); |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
961 |
memset(statspec->platforms + statspec->lengths, 0, length - statspec->lengths); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
962 |
|
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
963 |
ReallocT(&statspec->layouts, length); |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
964 |
memset(statspec->layouts + statspec->lengths, 0, |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
965 |
(length - statspec->lengths) * sizeof(*statspec->layouts)); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
966 |
|
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
967 |
statspec->lengths = length; |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
968 |
} |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
969 |
l = length - 1; // index is zero-based |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
970 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
971 |
//debug("p %d > %d ?", number, stat->platforms[l]); |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
972 |
if (number > statspec->platforms[l]) { |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
973 |
ReallocT(&statspec->layouts[l], number); |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
974 |
// We expect NULL being 0 here, but C99 guarantees that. |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
975 |
memset(statspec->layouts[l] + statspec->platforms[l], 0, |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
976 |
(number - statspec->platforms[l]) * sizeof(**statspec->layouts)); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
977 |
|
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
978 |
statspec->platforms[l] = number; |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
979 |
} |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
980 |
|
542 | 981 |
p = 0; |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
982 |
MallocT(&layout, length * number); |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
983 |
for (l = 0; l < length; l++) { |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
984 |
for (p = 0; p < number; p++) { |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
985 |
layout[l * number + p] = grf_load_byte(&buf); |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
986 |
} |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
987 |
} |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
988 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
989 |
l--; |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
990 |
p--; |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
991 |
free(statspec->layouts[l][p]); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
992 |
statspec->layouts[l][p] = layout; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
993 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
994 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
995 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
996 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
997 |
case 0x0F: /* Copy custom layout */ |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
998 |
FOR_EACH_OBJECT { |
5060
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
999 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1000 |
byte srcid = grf_load_byte(&buf); |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1001 |
const StationSpec *srcstatspec = _cur_grffile->stations[srcid]; |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1002 |
|
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1003 |
statspec->lengths = srcstatspec->lengths; |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1004 |
statspec->platforms = srcstatspec->platforms; |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1005 |
statspec->layouts = srcstatspec->layouts; |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1006 |
statspec->copied_layouts = true; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1007 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1008 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1009 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1010 |
case 0x10: /* Little/lots cargo threshold */ |
3768
46d328178509
(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
|
1011 |
FOR_EACH_OBJECT statspec[i]->cargo_threshold = grf_load_word(&buf); |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
1012 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1013 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1014 |
case 0x11: /* Pylon placement */ |
3768
46d328178509
(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
|
1015 |
FOR_EACH_OBJECT statspec[i]->pylons = grf_load_byte(&buf); |
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
1016 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1017 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1018 |
case 0x12: /* Cargo types for random triggers */ |
3768
46d328178509
(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
|
1019 |
FOR_EACH_OBJECT statspec[i]->cargo_triggers = grf_load_dword(&buf); |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1020 |
break; |
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1021 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1022 |
case 0x13: /* General flags */ |
3768
46d328178509
(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
|
1023 |
FOR_EACH_OBJECT statspec[i]->flags = grf_load_byte(&buf); |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1024 |
break; |
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1025 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1026 |
case 0x14: /* Overhead wire placement */ |
3768
46d328178509
(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
|
1027 |
FOR_EACH_OBJECT statspec[i]->wires = grf_load_byte(&buf); |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1028 |
break; |
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1029 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1030 |
case 0x15: /* Blocked tiles */ |
3768
46d328178509
(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
|
1031 |
FOR_EACH_OBJECT statspec[i]->blocked = grf_load_byte(&buf); |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1032 |
break; |
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1033 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1034 |
default: |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1035 |
ret = true; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1036 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1037 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1038 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1039 |
*bufp = buf; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1040 |
return ret; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1041 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1042 |
|
2478
16b05f1de6bb
(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
|
1043 |
static bool BridgeChangeInfo(uint brid, int numinfo, int prop, byte **bufp, int len) |
16b05f1de6bb
(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
|
1044 |
{ |
16b05f1de6bb
(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
|
1045 |
byte *buf = *bufp; |
16b05f1de6bb
(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
|
1046 |
int i; |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1047 |
bool ret = false; |
2478
16b05f1de6bb
(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
|
1048 |
|
16b05f1de6bb
(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
|
1049 |
switch (prop) { |
16b05f1de6bb
(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
|
1050 |
case 0x08: /* Year of availability */ |
4322
0bee6d9bc452
(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
|
1051 |
FOR_EACH_OBJECT _bridge[brid + i].avail_year = ORIGINAL_BASE_YEAR + grf_load_byte(&buf); |
2478
16b05f1de6bb
(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
|
1052 |
break; |
16b05f1de6bb
(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
|
1053 |
|
16b05f1de6bb
(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
|
1054 |
case 0x09: /* Minimum length */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1055 |
FOR_EACH_OBJECT _bridge[brid + i].min_length = grf_load_byte(&buf); |
2478
16b05f1de6bb
(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 |
break; |
16b05f1de6bb
(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 |
|
16b05f1de6bb
(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 |
case 0x0A: /* Maximum length */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1059 |
FOR_EACH_OBJECT _bridge[brid + i].max_length = grf_load_byte(&buf); |
2478
16b05f1de6bb
(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
|
1060 |
break; |
16b05f1de6bb
(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 |
|
16b05f1de6bb
(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 |
case 0x0B: /* Cost factor */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1063 |
FOR_EACH_OBJECT _bridge[brid + i].price = grf_load_byte(&buf); |
2478
16b05f1de6bb
(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
|
1064 |
break; |
16b05f1de6bb
(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 |
|
16b05f1de6bb
(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 |
case 0x0C: /* Maximum speed */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1067 |
FOR_EACH_OBJECT _bridge[brid + i].speed = grf_load_word(&buf); |
2478
16b05f1de6bb
(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
|
1068 |
break; |
16b05f1de6bb
(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 |
|
16b05f1de6bb
(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 |
case 0x0D: /* Bridge sprite tables */ |
16b05f1de6bb
(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 |
FOR_EACH_OBJECT { |
16b05f1de6bb
(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
|
1072 |
Bridge *bridge = &_bridge[brid + i]; |
16b05f1de6bb
(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 |
byte tableid = grf_load_byte(&buf); |
16b05f1de6bb
(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 |
byte numtables = grf_load_byte(&buf); |
16b05f1de6bb
(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 |
|
16b05f1de6bb
(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
|
1076 |
if (bridge->sprite_table == NULL) { |
3555
7a4f6e2aee0f
(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
|
1077 |
/* Allocate memory for sprite table pointers and zero out */ |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
1078 |
CallocT(bridge->sprite_table, 7); |
2478
16b05f1de6bb
(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 |
} |
16b05f1de6bb
(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
|
1080 |
|
3555
7a4f6e2aee0f
(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
|
1081 |
for (; numtables-- != 0; tableid++) { |
7a4f6e2aee0f
(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
|
1082 |
byte sprite; |
7a4f6e2aee0f
(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
|
1083 |
|
7a4f6e2aee0f
(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
|
1084 |
if (tableid >= 7) { // skip invalid data |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1085 |
grfmsg(1, "BridgeChangeInfo: Table %d >= 7, skipping", tableid); |
3555
7a4f6e2aee0f
(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
|
1086 |
for (sprite = 0; sprite < 32; sprite++) grf_load_dword(&buf); |
7a4f6e2aee0f
(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
|
1087 |
continue; |
2478
16b05f1de6bb
(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 |
} |
3555
7a4f6e2aee0f
(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
|
1089 |
|
7a4f6e2aee0f
(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 |
if (bridge->sprite_table[tableid] == NULL) { |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
1091 |
MallocT(&bridge->sprite_table[tableid], 32); |
3555
7a4f6e2aee0f
(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
|
1092 |
} |
7a4f6e2aee0f
(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
|
1093 |
|
7a4f6e2aee0f
(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 (sprite = 0; sprite < 32; sprite++) |
7a4f6e2aee0f
(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 |
bridge->sprite_table[tableid][sprite] = grf_load_dword(&buf); |
2478
16b05f1de6bb
(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
|
1096 |
} |
16b05f1de6bb
(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
|
1097 |
} |
16b05f1de6bb
(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
|
1098 |
break; |
16b05f1de6bb
(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
|
1099 |
|
16b05f1de6bb
(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
|
1100 |
case 0x0E: /* Flags; bit 0 - disable far pillars */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1101 |
FOR_EACH_OBJECT _bridge[brid + i].flags = grf_load_byte(&buf); |
2478
16b05f1de6bb
(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
|
1102 |
break; |
16b05f1de6bb
(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
|
1103 |
|
5114
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
1104 |
case 0x0F: /* Long format year of availability (year since year 0) */ |
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
1105 |
FOR_EACH_OBJECT _bridge[brid + i].avail_year = clamp(grf_load_dword(&buf), MIN_YEAR, MAX_YEAR); |
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
1106 |
break; |
2a29f37a7c1e
(svn r7191) -Feature: Add NewGRF support for 32 bit dates, allowing vehicles and bridges to be available before 1920.
peter1138
parents:
5108
diff
changeset
|
1107 |
|
2478
16b05f1de6bb
(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
|
1108 |
default: |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1109 |
ret = true; |
2478
16b05f1de6bb
(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
|
1110 |
} |
16b05f1de6bb
(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
|
1111 |
|
16b05f1de6bb
(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
|
1112 |
*bufp = buf; |
16b05f1de6bb
(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
|
1113 |
return ret; |
16b05f1de6bb
(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
|
1114 |
} |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1115 |
|
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1116 |
static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, int len) |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1117 |
{ |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1118 |
byte *buf = *bufp; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1119 |
int i; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1120 |
bool ret = false; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1121 |
|
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1122 |
switch (prop) { |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1123 |
case 0x08: /* Cost base factor */ |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1124 |
FOR_EACH_OBJECT { |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1125 |
byte factor = grf_load_byte(&buf); |
2508
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1126 |
uint price = gvid + i; |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1127 |
|
2508
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1128 |
if (price < NUM_PRICES) { |
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1129 |
SetPriceBaseMultiplier(price, factor); |
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1130 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1131 |
grfmsg(1, "GlobalVarChangeInfo: Price %d out of range, ignoring", price); |
2508
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1132 |
} |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1133 |
} |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1134 |
break; |
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1135 |
|
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1136 |
case 0x0A: // Currency display names |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1137 |
FOR_EACH_OBJECT { |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1138 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1139 |
StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf)); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1140 |
|
4504
3d20af4bd525
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1141 |
if ((newone != STR_UNDEFINED) && (curidx < NUM_CURRENCY)) { |
3d20af4bd525
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1142 |
_currency_specs[curidx].name = newone; |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1143 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1144 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1145 |
break; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1146 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1147 |
case 0x0B: // Currency multipliers |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1148 |
FOR_EACH_OBJECT { |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1149 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1150 |
uint32 rate = grf_load_dword(&buf); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1151 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1152 |
if (curidx < NUM_CURRENCY) { |
4602
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1153 |
/* TTDPatch uses a multiple of 1000 for its conversion calculations, |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1154 |
* which OTTD does not. For this reason, divide grf value by 1000, |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1155 |
* to be compatible */ |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1156 |
_currency_specs[curidx].rate = rate / 1000; |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1157 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1158 |
grfmsg(1, "GlobalVarChangeInfo: Currency multipliers %d out of range, ignoring", curidx); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1159 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1160 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1161 |
break; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1162 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1163 |
case 0x0C: // Currency options |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1164 |
FOR_EACH_OBJECT { |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1165 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1166 |
uint16 options = grf_load_word(&buf); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1167 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1168 |
if (curidx < NUM_CURRENCY) { |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1169 |
_currency_specs[curidx].separator = GB(options, 0, 8); |
4602
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1170 |
/* By specifying only one bit, we prevent errors, |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1171 |
* since newgrf specs said that only 0 and 1 can be set for symbol_pos */ |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1172 |
_currency_specs[curidx].symbol_pos = GB(options, 8, 1); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1173 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1174 |
grfmsg(1, "GlobalVarChangeInfo: Currency option %d out of range, ignoring", curidx); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1175 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1176 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1177 |
break; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1178 |
|
4602
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1179 |
case 0x0D: // Currency prefix symbol |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1180 |
FOR_EACH_OBJECT { |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1181 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1182 |
uint32 tempfix = grf_load_dword(&buf); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1183 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1184 |
if (curidx < NUM_CURRENCY) { |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1185 |
memcpy(_currency_specs[curidx].prefix,&tempfix,4); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1186 |
_currency_specs[curidx].prefix[4] = 0; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1187 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1188 |
grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1189 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1190 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1191 |
break; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1192 |
|
4602
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1193 |
case 0x0E: // Currency suffix symbol |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1194 |
FOR_EACH_OBJECT { |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1195 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1196 |
uint32 tempfix = grf_load_dword(&buf); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1197 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1198 |
if (curidx < NUM_CURRENCY) { |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1199 |
memcpy(&_currency_specs[curidx].suffix,&tempfix,4); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1200 |
_currency_specs[curidx].suffix[4] = 0; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1201 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1202 |
grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1203 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1204 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1205 |
break; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1206 |
|
4504
3d20af4bd525
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1207 |
case 0x0F: // Euro introduction dates |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1208 |
FOR_EACH_OBJECT { |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1209 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1210 |
Year year_euro = grf_load_word(&buf); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1211 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1212 |
if (curidx < NUM_CURRENCY) { |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1213 |
_currency_specs[curidx].to_euro = year_euro; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1214 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1215 |
grfmsg(1, "GlobalVarChangeInfo: Euro intro date %d out of range, ignoring", curidx); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1216 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1217 |
} |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1218 |
break; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1219 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1220 |
case 0x09: // Cargo translation table |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1221 |
case 0x10: // 12 * 32 * B Snow line height table |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1222 |
default: |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1223 |
ret = true; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1224 |
} |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1225 |
|
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1226 |
*bufp = buf; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1227 |
return ret; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1228 |
} |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1229 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1230 |
static bool SoundEffectChangeInfo(uint sid, int numinfo, int prop, byte **bufp, int len) |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1231 |
{ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1232 |
byte *buf = *bufp; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1233 |
int i; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1234 |
bool ret = false; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1235 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1236 |
if (_cur_grffile->sound_offset == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1237 |
grfmsg(1, "SoundEffectChangeInfo: No effects defined, skipping"); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1238 |
return false; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1239 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1240 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1241 |
switch (prop) { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1242 |
case 0x08: /* Relative volume */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1243 |
FOR_EACH_OBJECT { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1244 |
uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1245 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1246 |
if (sound >= GetNumSounds()) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1247 |
grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1248 |
} else { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1249 |
GetSound(sound)->volume = grf_load_byte(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1250 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1251 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1252 |
break; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1253 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1254 |
case 0x09: /* Priority */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1255 |
FOR_EACH_OBJECT { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1256 |
uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1257 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1258 |
if (sound >= GetNumSounds()) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1259 |
grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1260 |
} else { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1261 |
GetSound(sound)->priority = grf_load_byte(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1262 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1263 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1264 |
break; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1265 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1266 |
case 0x0A: /* Override old sound */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1267 |
FOR_EACH_OBJECT { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1268 |
uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1269 |
uint orig_sound = grf_load_byte(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1270 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1271 |
if (sound >= GetNumSounds() || orig_sound >= GetNumSounds()) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1272 |
grfmsg(1, "SoundEffectChangeInfo: Sound %d or %d not defined (max %d)", sound, orig_sound, GetNumSounds()); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1273 |
} else { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1274 |
FileEntry *newfe = GetSound(sound); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1275 |
FileEntry *oldfe = GetSound(orig_sound); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1276 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1277 |
/* Literally copy the data of the new sound over the original */ |
5024
f13f2f2d43f9
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5011
diff
changeset
|
1278 |
*oldfe = *newfe; |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1279 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1280 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1281 |
break; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1282 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1283 |
default: |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1284 |
ret = true; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1285 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1286 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1287 |
*bufp = buf; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1288 |
return ret; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1289 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1290 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1291 |
/* Action 0x00 */ |
3879
3e9cd6403d73
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1292 |
static void FeatureChangeInfo(byte *buf, int len) |
0 | 1293 |
{ |
1294 |
byte *bufend = buf + len; |
|
1295 |
int i; |
|
1296 |
||
1297 |
/* <00> <feature> <num-props> <num-info> <id> (<property <new-info>)... |
|
1298 |
* |
|
1299 |
* B feature 0, 1, 2 or 3 for trains, road vehicles, ships or planes |
|
1300 |
* 4 for defining new train station sets |
|
1301 |
* B num-props how many properties to change per vehicle/station |
|
1302 |
* B num-info how many vehicles/stations to change |
|
1303 |
* B id ID of first vehicle/station to change, if num-info is |
|
1304 |
* greater than one, this one and the following |
|
1305 |
* vehicles/stations will be changed |
|
1306 |
* B property what property to change, depends on the feature |
|
1307 |
* V new-info new bytes of info (variable size; depends on properties) */ |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1308 |
/* TODO: Bridges, town houses. */ |
0 | 1309 |
|
2438
eaef2b29fa3d
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
1310 |
static const VCI_Handler handler[] = { |
3825 | 1311 |
/* GSF_TRAIN */ RailVehicleChangeInfo, |
1312 |
/* GSF_ROAD */ RoadVehicleChangeInfo, |
|
1313 |
/* GSF_SHIP */ ShipVehicleChangeInfo, |
|
1314 |
/* GSF_AIRCRAFT */ AircraftVehicleChangeInfo, |
|
1315 |
/* GSF_STATION */ StationChangeInfo, |
|
1316 |
/* GSF_CANAL */ NULL, |
|
1317 |
/* GSF_BRIDGE */ BridgeChangeInfo, |
|
1318 |
/* GSF_TOWNHOUSE */ NULL, |
|
1319 |
/* GSF_GLOBALVAR */ GlobalVarChangeInfo, |
|
1320 |
/* GSF_INDUSTRYTILES */NULL, |
|
1321 |
/* GSF_INDUSTRIES */ NULL, |
|
4138
15f4aa024ad4
(svn r5496) -CodeChange: Removed two compiler warnings
belugas
parents:
4077
diff
changeset
|
1322 |
/* GSF_CARGOS */ NULL, |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1323 |
/* GSF_SOUNDFX */ SoundEffectChangeInfo, |
0 | 1324 |
}; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1325 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1326 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1327 |
uint8 numprops; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1328 |
uint8 numinfo; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1329 |
byte engine; |
542 | 1330 |
EngineInfo *ei = NULL; |
0 | 1331 |
|
396
f7dc2d2144b6
(svn r588) -newgrf: Silent ignore those stupid one-byte zero special sprites (dbsetw.grf is crawling with them) (pasky).
darkvater
parents:
391
diff
changeset
|
1332 |
if (len == 1) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1333 |
grfmsg(8, "Silently ignoring one-byte special sprite 0x00"); |
396
f7dc2d2144b6
(svn r588) -newgrf: Silent ignore those stupid one-byte zero special sprites (dbsetw.grf is crawling with them) (pasky).
darkvater
parents:
391
diff
changeset
|
1334 |
return; |
f7dc2d2144b6
(svn r588) -newgrf: Silent ignore those stupid one-byte zero special sprites (dbsetw.grf is crawling with them) (pasky).
darkvater
parents:
391
diff
changeset
|
1335 |
} |
f7dc2d2144b6
(svn r588) -newgrf: Silent ignore those stupid one-byte zero special sprites (dbsetw.grf is crawling with them) (pasky).
darkvater
parents:
391
diff
changeset
|
1336 |
|
3879
3e9cd6403d73
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1337 |
check_length(len, 6, "FeatureChangeInfo"); |
3714
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1338 |
buf++; |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1339 |
feature = grf_load_byte(&buf); |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1340 |
numprops = grf_load_byte(&buf); |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1341 |
numinfo = grf_load_byte(&buf); |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1342 |
engine = grf_load_byte(&buf); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
1343 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1344 |
grfmsg(6, "FeatureChangeInfo: feature %d, %d properties, to apply to %d+%d", |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
1345 |
feature, numprops, engine, numinfo); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
1346 |
|
2440
443e2f3cce75
(svn r2966) Fix: newgrf: Replace special case with a check for the existence of a handler in VehicleChangeInfo.
peter1138
parents:
2439
diff
changeset
|
1347 |
if (feature >= lengthof(handler) || handler[feature] == NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1348 |
grfmsg(1, "FeatureChangeInfo: Unsupported feature %d, skipping", feature); |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1349 |
return; |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1350 |
} |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1351 |
|
2439
c820a9751afc
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1352 |
if (feature <= GSF_AIRCRAFT) { |
c820a9751afc
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1353 |
if (engine + numinfo > _vehcounts[feature]) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1354 |
grfmsg(0, "FeatureChangeInfo: Last engine ID %d out of bounds (max %d), skipping", engine + numinfo, _vehcounts[feature]); |
2439
c820a9751afc
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1355 |
return; |
c820a9751afc
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1356 |
} |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1357 |
ei = &_engine_info[engine + _vehshifts[feature]]; |
2439
c820a9751afc
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1358 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1359 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1360 |
while (numprops-- && buf < bufend) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1361 |
uint8 prop = grf_load_byte(&buf); |
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1362 |
bool ignoring = false; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1363 |
|
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1364 |
switch (feature) { |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1365 |
case GSF_TRAIN: |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1366 |
case GSF_ROAD: |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1367 |
case GSF_SHIP: |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1368 |
case GSF_AIRCRAFT: |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1369 |
/* Common properties for vehicles */ |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1370 |
switch (prop) { |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1371 |
case 0x00: /* Introduction date */ |
4322
0bee6d9bc452
(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
|
1372 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_word(&buf) + DAYS_TILL_ORIGINAL_BASE_YEAR; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1373 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1374 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1375 |
case 0x02: /* Decay speed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1376 |
FOR_EACH_OBJECT SB(ei[i].unk2, 0, 7, grf_load_byte(&buf) & 0x7F); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1377 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1378 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1379 |
case 0x03: /* Vehicle life */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1380 |
FOR_EACH_OBJECT ei[i].lifelength = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1381 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1382 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1383 |
case 0x04: /* Model life */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1384 |
FOR_EACH_OBJECT ei[i].base_life = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1385 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1386 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1387 |
case 0x06: /* Climates available */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1388 |
FOR_EACH_OBJECT ei[i].climates = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1389 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1390 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1391 |
case 0x07: /* Loading speed */ |
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1392 |
/* Hyronymus explained me what does |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1393 |
* this mean and insists on having a |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1394 |
* credit ;-). --pasky */ |
5211
651c9272ad22
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents:
5210
diff
changeset
|
1395 |
FOR_EACH_OBJECT ei[i].load_amount = grf_load_byte(&buf); |
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1396 |
break; |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1397 |
|
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1398 |
default: |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1399 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1400 |
ignoring = true; |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1401 |
break; |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1402 |
} |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1403 |
break; |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1404 |
|
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1405 |
default: |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1406 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1407 |
ignoring = true; |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1408 |
break; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1409 |
} |
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1410 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1411 |
if (ignoring) grfmsg(2, "FeatureChangeInfo: Ignoring property 0x%02X (not implemented)", prop); |
0 | 1412 |
} |
1413 |
} |
|
1414 |
||
5648
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1415 |
/* Action 0x00 (GLS_SAFETYSCAN) */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1416 |
static void SafeChangeInfo(byte *buf, int len) |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1417 |
{ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1418 |
uint8 feature; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1419 |
uint8 numprops; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1420 |
uint8 numinfo; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1421 |
uint8 index; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1422 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1423 |
check_length(len, 6, "SafeChangeInfo"); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1424 |
buf++; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1425 |
feature = grf_load_byte(&buf); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1426 |
numprops = grf_load_byte(&buf); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1427 |
numinfo = grf_load_byte(&buf); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1428 |
index = grf_load_byte(&buf); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1429 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1430 |
if (feature == GSF_BRIDGE && numprops == 1) { |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1431 |
uint8 prop = grf_load_byte(&buf); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1432 |
/* Bridge property 0x0D is redefinition of sprite layout tables, which |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1433 |
* is considered safe. */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1434 |
if (prop == 0x0D) return; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1435 |
} |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1436 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1437 |
SETBIT(_cur_grfconfig->flags, GCF_UNSAFE); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1438 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1439 |
/* Skip remainder of GRF */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1440 |
_skip_sprites = -1; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1441 |
} |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
1442 |
|
439
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
1443 |
#undef FOR_EACH_OBJECT |
4e71a04a7fce
(svn r648) Dummy skip-support for two new station properties. Rename FOR_EACH_ENGINE() to more appropriate FOR_EACH_OBJECT(). (pasky)
miham
parents:
438
diff
changeset
|
1444 |
|
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1445 |
/** |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1446 |
* Creates a spritegroup representing a callback result |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1447 |
* @param value The value that was used to represent this callback result |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1448 |
* @return A spritegroup representing that callback result |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1449 |
*/ |
4893
07d158194395
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
1450 |
static const SpriteGroup* NewCallBackResultSpriteGroup(uint16 value) |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1451 |
{ |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
1452 |
SpriteGroup *group = AllocateSpriteGroup(); |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1453 |
|
2488
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1454 |
group->type = SGT_CALLBACK; |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1455 |
|
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1456 |
// Old style callback results have the highest byte 0xFF so signify it is a callback result |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1457 |
// New style ones only have the highest bit set (allows 15-bit results, instead of just 8) |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1458 |
if ((value >> 8) == 0xFF) { |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1459 |
value &= ~0xFF00; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1460 |
} else { |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1461 |
value &= ~0x8000; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1462 |
} |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1463 |
|
2488
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1464 |
group->g.callback.result = value; |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1465 |
|
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1466 |
return group; |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1467 |
} |
0 | 1468 |
|
2489
88827d8ae517
(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
|
1469 |
/** |
88827d8ae517
(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
|
1470 |
* Creates a spritegroup representing a sprite number result. |
88827d8ae517
(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
|
1471 |
* @param value The sprite number. |
88827d8ae517
(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
|
1472 |
* @param sprites The number of sprites per set. |
88827d8ae517
(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
|
1473 |
* @return A spritegroup representing the sprite number result. |
88827d8ae517
(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
|
1474 |
*/ |
4893
07d158194395
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
1475 |
static const SpriteGroup* NewResultSpriteGroup(SpriteID sprite, byte num_sprites) |
2489
88827d8ae517
(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
|
1476 |
{ |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
1477 |
SpriteGroup *group = AllocateSpriteGroup(); |
2489
88827d8ae517
(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
|
1478 |
group->type = SGT_RESULT; |
3668
d7ed0a867b49
(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
|
1479 |
group->g.result.sprite = sprite; |
d7ed0a867b49
(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
|
1480 |
group->g.result.num_sprites = num_sprites; |
2489
88827d8ae517
(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
|
1481 |
return group; |
88827d8ae517
(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
|
1482 |
} |
88827d8ae517
(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
|
1483 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1484 |
/* Action 0x01 */ |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1485 |
static void NewSpriteSet(byte *buf, int len) |
0 | 1486 |
{ |
1487 |
/* <01> <feature> <num-sets> <num-ent> |
|
1488 |
* |
|
1489 |
* B feature feature to define sprites for |
|
1490 |
* 0, 1, 2, 3: veh-type, 4: train stations |
|
1491 |
* B num-sets number of sprite sets |
|
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1492 |
* E num-ent how many entries per sprite set |
0 | 1493 |
* For vehicles, this is the number of different |
1494 |
* vehicle directions in each sprite set |
|
1495 |
* Set num-dirs=8, unless your sprites are symmetric. |
|
1496 |
* In that case, use num-dirs=4. |
|
1497 |
* For stations, must be 12 (hex) for the eighteen |
|
1498 |
* different sprites that make up a station */ |
|
1499 |
/* TODO: No stations support. */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1500 |
uint8 feature; |
2342
c19fb4f2df30
(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
|
1501 |
uint num_sets; |
c19fb4f2df30
(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
|
1502 |
uint num_ents; |
c19fb4f2df30
(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
|
1503 |
uint i; |
0 | 1504 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1505 |
check_length(len, 4, "NewSpriteSet"); |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1506 |
buf++; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1507 |
feature = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1508 |
num_sets = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1509 |
num_ents = grf_load_extended(&buf); |
0 | 1510 |
|
2342
c19fb4f2df30
(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
|
1511 |
_cur_grffile->spriteset_start = _cur_spriteid; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1512 |
_cur_grffile->spriteset_feature = feature; |
2342
c19fb4f2df30
(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
|
1513 |
_cur_grffile->spriteset_numsets = num_sets; |
c19fb4f2df30
(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
|
1514 |
_cur_grffile->spriteset_numents = num_ents; |
c19fb4f2df30
(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
|
1515 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1516 |
grfmsg(7, "New sprite set at %d of type %d, consisting of %d sets with %d views each (total %d)", |
2342
c19fb4f2df30
(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
|
1517 |
_cur_spriteid, feature, num_sets, num_ents, num_sets * num_ents |
c19fb4f2df30
(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
|
1518 |
); |
c19fb4f2df30
(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
|
1519 |
|
c19fb4f2df30
(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
|
1520 |
for (i = 0; i < num_sets * num_ents; i++) { |
c19fb4f2df30
(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
|
1521 |
LoadNextSprite(_cur_spriteid++, _file_index); |
3557
5d12a78ce141
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
1522 |
_nfo_line++; |
2342
c19fb4f2df30
(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
|
1523 |
} |
0 | 1524 |
} |
1525 |
||
3666
975cd26c8df7
(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
|
1526 |
/* Helper function to either create a callback or link to a previously |
975cd26c8df7
(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
|
1527 |
* defined spritegroup. */ |
4893
07d158194395
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
1528 |
static const SpriteGroup* GetGroupFromGroupID(byte setid, byte type, uint16 groupid) |
3666
975cd26c8df7
(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
|
1529 |
{ |
975cd26c8df7
(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
|
1530 |
if (HASBIT(groupid, 15)) return NewCallBackResultSpriteGroup(groupid); |
975cd26c8df7
(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
|
1531 |
|
975cd26c8df7
(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
|
1532 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1533 |
grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty", setid, type, groupid); |
3666
975cd26c8df7
(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
|
1534 |
return NULL; |
975cd26c8df7
(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
|
1535 |
} |
975cd26c8df7
(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
|
1536 |
|
975cd26c8df7
(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
|
1537 |
return _cur_grffile->spritegroups[groupid]; |
975cd26c8df7
(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
|
1538 |
} |
975cd26c8df7
(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
|
1539 |
|
975cd26c8df7
(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
|
1540 |
/* Helper function to either create a callback or a result sprite group. */ |
4893
07d158194395
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
1541 |
static const SpriteGroup* CreateGroupFromGroupID(byte feature, byte setid, byte type, uint16 spriteid, uint16 num_sprites) |
3666
975cd26c8df7
(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
|
1542 |
{ |
975cd26c8df7
(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
|
1543 |
if (HASBIT(spriteid, 15)) return NewCallBackResultSpriteGroup(spriteid); |
975cd26c8df7
(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
|
1544 |
|
3667
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1545 |
if (spriteid >= _cur_grffile->spriteset_numsets) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1546 |
grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Sprite set %u invalid, max %u", setid, type, spriteid, _cur_grffile->spriteset_numsets); |
3667
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1547 |
return NULL; |
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1548 |
} |
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1549 |
|
3666
975cd26c8df7
(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
|
1550 |
/* Check if the sprite is within range. This can fail if the Action 0x01 |
975cd26c8df7
(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 |
* is skipped, as TTDPatch mandates that Action 0x02s must be processed. |
975cd26c8df7
(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 |
* We don't have that rule, but must live by the Patch... */ |
975cd26c8df7
(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
|
1553 |
if (_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites > _cur_spriteid) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1554 |
grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Real Sprite IDs 0x%04X - 0x%04X do not (all) exist (max 0x%04X), leaving empty", |
3666
975cd26c8df7
(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 |
setid, type, |
975cd26c8df7
(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 |
_cur_grffile->spriteset_start + spriteid * num_sprites, |
975cd26c8df7
(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 |
_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites - 1, _cur_spriteid - 1); |
975cd26c8df7
(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
|
1558 |
return NULL; |
975cd26c8df7
(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 |
} |
975cd26c8df7
(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 |
|
3803
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1561 |
if (feature != _cur_grffile->spriteset_feature) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1562 |
grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Sprite set feature 0x%02X does not match action feature 0x%02X, skipping", |
3803
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1563 |
_cur_grffile->spriteset_feature, feature); |
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1564 |
return NULL; |
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1565 |
} |
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1566 |
|
3666
975cd26c8df7
(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 |
return NewResultSpriteGroup(_cur_grffile->spriteset_start + spriteid * num_sprites, num_sprites); |
975cd26c8df7
(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 |
} |
975cd26c8df7
(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 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1570 |
/* Action 0x02 */ |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1571 |
static void NewSpriteGroup(byte *buf, int len) |
0 | 1572 |
{ |
1573 |
/* <02> <feature> <set-id> <type/num-entries> <feature-specific-data...> |
|
1574 |
* |
|
1575 |
* B feature see action 1 |
|
1576 |
* B set-id ID of this particular definition |
|
1577 |
* B type/num-entries |
|
1578 |
* if 80 or greater, this is a randomized or variational |
|
1579 |
* list definition, see below |
|
1580 |
* otherwise it specifies a number of entries, the exact |
|
1581 |
* meaning depends on the feature |
|
1582 |
* V feature-specific-data (huge mess, don't even look it up --pasky) */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1583 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1584 |
uint8 setid; |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1585 |
uint8 type; |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1586 |
SpriteGroup *group = NULL; |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1587 |
byte *bufend = buf + len; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
1588 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1589 |
check_length(len, 5, "NewSpriteGroup"); |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1590 |
buf++; |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1591 |
|
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1592 |
feature = grf_load_byte(&buf); |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1593 |
setid = grf_load_byte(&buf); |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1594 |
type = grf_load_byte(&buf); |
0 | 1595 |
|
2444
e618726432a4
(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
|
1596 |
if (setid >= _cur_grffile->spritegroups_count) { |
2488
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1597 |
// Allocate memory for new sprite group references. |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
1598 |
ReallocT(&_cur_grffile->spritegroups, setid + 1); |
2488
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1599 |
// Initialise new space to NULL |
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1600 |
for (; _cur_grffile->spritegroups_count < (setid + 1); _cur_grffile->spritegroups_count++) |
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1601 |
_cur_grffile->spritegroups[_cur_grffile->spritegroups_count] = NULL; |
2444
e618726432a4
(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
|
1602 |
} |
e618726432a4
(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
|
1603 |
|
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1604 |
switch (type) { |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1605 |
/* Deterministic Sprite Group */ |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1606 |
case 0x81: // Self scope, byte |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1607 |
case 0x82: // Parent scope, byte |
3668
d7ed0a867b49
(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
|
1608 |
case 0x85: // Self scope, word |
d7ed0a867b49
(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
|
1609 |
case 0x86: // Parent scope, word |
d7ed0a867b49
(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
|
1610 |
case 0x89: // Self scope, dword |
d7ed0a867b49
(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
|
1611 |
case 0x8A: // Parent scope, dword |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1612 |
{ |
3668
d7ed0a867b49
(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
|
1613 |
byte varadjust; |
d7ed0a867b49
(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
|
1614 |
byte varsize; |
d7ed0a867b49
(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
|
1615 |
uint i; |
d7ed0a867b49
(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
|
1616 |
|
d7ed0a867b49
(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
|
1617 |
/* Check we can load the var size parameter */ |
d7ed0a867b49
(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
|
1618 |
check_length(bufend - buf, 1, "NewSpriteGroup (Deterministic) (1)"); |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1619 |
|
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1620 |
group = AllocateSpriteGroup(); |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1621 |
group->type = SGT_DETERMINISTIC; |
3668
d7ed0a867b49
(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
|
1622 |
group->g.determ.var_scope = HASBIT(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
d7ed0a867b49
(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
|
1623 |
|
d7ed0a867b49
(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
|
1624 |
switch (GB(type, 2, 2)) { |
3672
73caf2e829f8
(svn r4588) - NewGRF: silence a false compiler warning
peter1138
parents:
3668
diff
changeset
|
1625 |
default: NOT_REACHED(); |
3668
d7ed0a867b49
(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
|
1626 |
case 0: group->g.determ.size = DSG_SIZE_BYTE; varsize = 1; break; |
d7ed0a867b49
(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
|
1627 |
case 1: group->g.determ.size = DSG_SIZE_WORD; varsize = 2; break; |
d7ed0a867b49
(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
|
1628 |
case 2: group->g.determ.size = DSG_SIZE_DWORD; varsize = 4; break; |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1629 |
} |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1630 |
|
5288
7758df538a10
(svn r7437) -Fix (r4583): incorrect minimum size check in some cases for VarAction2
peter1138
parents:
5287
diff
changeset
|
1631 |
check_length(bufend - buf, 5 + varsize, "NewSpriteGroup (Deterministic) (2)"); |
3668
d7ed0a867b49
(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
|
1632 |
|
d7ed0a867b49
(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 |
/* Loop through the var adjusts. Unfortunately we don't know how many we have |
d7ed0a867b49
(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 |
* from the outset, so we shall have to keep reallocing. */ |
d7ed0a867b49
(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 |
do { |
d7ed0a867b49
(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 |
DeterministicSpriteGroupAdjust *adjust; |
d7ed0a867b49
(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
|
1637 |
|
d7ed0a867b49
(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 |
if (group->g.determ.num_adjusts > 0) { |
3694
ba2b26464b85
(svn r4631) - NewGRF: fix incorrect length check
peter1138
parents:
3676
diff
changeset
|
1639 |
check_length(bufend - buf, 2 + varsize + 3, "NewSpriteGroup (Deterministic) (3)"); |
3668
d7ed0a867b49
(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 |
} |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 |
group->g.determ.num_adjusts++; |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
1643 |
ReallocT(&group->g.determ.adjusts, group->g.determ.num_adjusts); |
3668
d7ed0a867b49
(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
|
1644 |
|
d7ed0a867b49
(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
|
1645 |
adjust = &group->g.determ.adjusts[group->g.determ.num_adjusts - 1]; |
d7ed0a867b49
(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
|
1646 |
|
d7ed0a867b49
(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 |
/* The first var adjust doesn't have an operation specified, so we set it to add. */ |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
1648 |
adjust->operation = group->g.determ.num_adjusts == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)grf_load_byte(&buf); |
3668
d7ed0a867b49
(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 |
adjust->variable = grf_load_byte(&buf); |
d7ed0a867b49
(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
|
1650 |
adjust->parameter = IS_BYTE_INSIDE(adjust->variable, 0x60, 0x80) ? grf_load_byte(&buf) : 0; |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 |
varadjust = grf_load_byte(&buf); |
d7ed0a867b49
(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 |
adjust->shift_num = GB(varadjust, 0, 5); |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
1654 |
adjust->type = (DeterministicSpriteGroupAdjustType)GB(varadjust, 6, 2); |
3668
d7ed0a867b49
(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
|
1655 |
adjust->and_mask = grf_load_var(varsize, &buf); |
d7ed0a867b49
(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
|
1656 |
|
d7ed0a867b49
(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 |
if (adjust->type != DSGA_TYPE_NONE) { |
d7ed0a867b49
(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 |
adjust->add_val = grf_load_var(varsize, &buf); |
d7ed0a867b49
(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 |
adjust->divmod_val = grf_load_var(varsize, &buf); |
d7ed0a867b49
(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 |
} else { |
d7ed0a867b49
(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 |
adjust->add_val = 0; |
d7ed0a867b49
(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 |
adjust->divmod_val = 0; |
d7ed0a867b49
(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 |
} |
d7ed0a867b49
(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
|
1664 |
|
d7ed0a867b49
(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 |
/* Continue reading var adjusts while bit 5 is set. */ |
d7ed0a867b49
(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 |
} while (HASBIT(varadjust, 5)); |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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
|
1668 |
group->g.determ.num_ranges = grf_load_byte(&buf); |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
1669 |
CallocT(&group->g.determ.ranges, group->g.determ.num_ranges); |
3668
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 |
check_length(bufend - buf, 2 + (2 + 2 * varsize) * group->g.determ.num_ranges, "NewSpriteGroup (Deterministic)"); |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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
|
1673 |
for (i = 0; i < group->g.determ.num_ranges; i++) { |
d7ed0a867b49
(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 |
group->g.determ.ranges[i].group = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
d7ed0a867b49
(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
|
1675 |
group->g.determ.ranges[i].low = grf_load_var(varsize, &buf); |
d7ed0a867b49
(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
|
1676 |
group->g.determ.ranges[i].high = grf_load_var(varsize, &buf); |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1677 |
} |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1678 |
|
3668
d7ed0a867b49
(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
|
1679 |
group->g.determ.default_group = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1680 |
break; |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
441
diff
changeset
|
1681 |
} |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
441
diff
changeset
|
1682 |
|
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1683 |
/* Randomized Sprite Group */ |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1684 |
case 0x80: // Self scope |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1685 |
case 0x83: // Parent scope |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1686 |
{ |
3668
d7ed0a867b49
(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 |
byte triggers; |
d7ed0a867b49
(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 |
uint i; |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 |
check_length(bufend - buf, 7, "NewSpriteGroup (Randomized) (1)"); |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1691 |
|
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1692 |
group = AllocateSpriteGroup(); |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1693 |
group->type = SGT_RANDOMIZED; |
3668
d7ed0a867b49
(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 |
group->g.random.var_scope = HASBIT(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 |
triggers = grf_load_byte(&buf); |
d7ed0a867b49
(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 |
group->g.random.triggers = GB(triggers, 0, 7); |
d7ed0a867b49
(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.random.cmp_mode = HASBIT(triggers, 7) ? RSG_CMP_ALL : RSG_CMP_ANY; |
d7ed0a867b49
(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
|
1699 |
group->g.random.lowest_randbit = grf_load_byte(&buf); |
d7ed0a867b49
(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 |
group->g.random.num_groups = grf_load_byte(&buf); |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
1701 |
CallocT(&group->g.random.groups, group->g.random.num_groups); |
3668
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 |
check_length(bufend - buf, 2 * group->g.random.num_groups, "NewSpriteGroup (Randomized) (2)"); |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 |
for (i = 0; i < group->g.random.num_groups; i++) { |
d7ed0a867b49
(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.random.groups[i] = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1707 |
} |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1708 |
|
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1709 |
break; |
2489
88827d8ae517
(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
|
1710 |
} |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1711 |
|
3668
d7ed0a867b49
(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
|
1712 |
/* Neither a variable or randomized sprite group... must be a real group */ |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1713 |
default: |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1714 |
{ |
3803
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1715 |
|
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1716 |
|
3668
d7ed0a867b49
(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 |
switch (feature) { |
d7ed0a867b49
(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 |
case GSF_TRAIN: |
d7ed0a867b49
(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 |
case GSF_ROAD: |
d7ed0a867b49
(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
|
1720 |
case GSF_SHIP: |
d7ed0a867b49
(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
|
1721 |
case GSF_AIRCRAFT: |
d7ed0a867b49
(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
|
1722 |
case GSF_STATION: |
d7ed0a867b49
(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
|
1723 |
{ |
d7ed0a867b49
(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 |
byte sprites = _cur_grffile->spriteset_numents; |
d7ed0a867b49
(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 |
byte num_loaded = type; |
d7ed0a867b49
(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 |
byte num_loading = grf_load_byte(&buf); |
d7ed0a867b49
(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 |
uint i; |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 |
if (_cur_grffile->spriteset_start == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1730 |
grfmsg(0, "NewSpriteGroup: No sprite set to work on! Skipping"); |
3668
d7ed0a867b49
(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
|
1731 |
return; |
d7ed0a867b49
(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 |
} |
d7ed0a867b49
(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
|
1733 |
|
d7ed0a867b49
(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 |
check_length(bufend - buf, 2 * num_loaded + 2 * num_loading, "NewSpriteGroup (Real) (1)"); |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 = AllocateSpriteGroup(); |
d7ed0a867b49
(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
|
1737 |
group->type = SGT_REAL; |
d7ed0a867b49
(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
|
1738 |
|
d7ed0a867b49
(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
|
1739 |
group->g.real.num_loaded = num_loaded; |
d7ed0a867b49
(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
|
1740 |
group->g.real.num_loading = num_loading; |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
1741 |
if (num_loaded > 0) CallocT(&group->g.real.loaded, num_loaded); |
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
1742 |
if (num_loading > 0) CallocT(&group->g.real.loading, num_loading); |
3668
d7ed0a867b49
(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
|
1743 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1744 |
grfmsg(6, "NewSpriteGroup: New SpriteGroup 0x%02X, %u views, %u loaded, %u loading", |
3668
d7ed0a867b49
(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
|
1745 |
setid, sprites, num_loaded, num_loading); |
d7ed0a867b49
(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
|
1746 |
|
d7ed0a867b49
(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 |
for (i = 0; i < num_loaded; i++) { |
d7ed0a867b49
(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 |
uint16 spriteid = grf_load_word(&buf); |
3803
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1749 |
group->g.real.loaded[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1750 |
grfmsg(8, "NewSpriteGroup: + rg->loaded[%i] = subset %u", i, spriteid); |
3668
d7ed0a867b49
(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 |
} |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 |
for (i = 0; i < num_loading; i++) { |
d7ed0a867b49
(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 |
uint16 spriteid = grf_load_word(&buf); |
3803
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
1755 |
group->g.real.loading[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1756 |
grfmsg(8, "NewSpriteGroup: + rg->loading[%i] = subset %u", i, spriteid); |
3668
d7ed0a867b49
(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 |
} |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 |
break; |
d7ed0a867b49
(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
|
1760 |
} |
d7ed0a867b49
(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 |
|
d7ed0a867b49
(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 |
/* Loading of Tile Layout and Production Callback groups would happen here */ |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1763 |
default: grfmsg(1, "NewSpriteGroup: Unsupported feature %d, skipping", feature); |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1764 |
} |
2489
88827d8ae517
(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
|
1765 |
} |
0 | 1766 |
} |
2444
e618726432a4
(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
|
1767 |
|
e618726432a4
(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
|
1768 |
_cur_grffile->spritegroups[setid] = group; |
0 | 1769 |
} |
1770 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1771 |
/* Action 0x03 */ |
3879
3e9cd6403d73
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1772 |
static void FeatureMapSpriteGroup(byte *buf, int len) |
0 | 1773 |
{ |
1774 |
/* <03> <feature> <n-id> <ids>... <num-cid> [<cargo-type> <cid>]... <def-cid> |
|
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4381
diff
changeset
|
1775 |
* id-list := [<id>] [id-list] |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4381
diff
changeset
|
1776 |
* cargo-list := <cargo-type> <cid> [cargo-list] |
0 | 1777 |
* |
1778 |
* B feature see action 0 |
|
1779 |
* B n-id bits 0-6: how many IDs this definition applies to |
|
1780 |
* bit 7: if set, this is a wagon override definition (see below) |
|
1781 |
* B ids the IDs for which this definition applies |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1782 |
* B num-cid number of cargo IDs (sprite group IDs) in this definition |
0 | 1783 |
* can be zero, in that case the def-cid is used always |
1784 |
* B cargo-type type of this cargo type (e.g. mail=2, wood=7, see below) |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1785 |
* W cid cargo ID (sprite group ID) for this type of cargo |
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1786 |
* W def-cid default cargo ID (sprite group ID) */ |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1787 |
/* TODO: Bridges, town houses. */ |
0 | 1788 |
/* TODO: Multiple cargo support could be useful even for trains/cars - |
1789 |
* cargo id 0xff is used for showing images in the build train list. */ |
|
1790 |
||
1791 |
static byte *last_engines; |
|
1792 |
static int last_engines_count; |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1793 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1794 |
uint8 idcount; |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1795 |
bool wagover; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1796 |
uint8 cidcount; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1797 |
int c, i; |
0 | 1798 |
|
3879
3e9cd6403d73
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1799 |
check_length(len, 6, "FeatureMapSpriteGroup"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1800 |
feature = buf[1]; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1801 |
idcount = buf[2] & 0x7F; |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1802 |
wagover = (buf[2] & 0x80) == 0x80; |
3879
3e9cd6403d73
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1803 |
check_length(len, 3 + idcount, "FeatureMapSpriteGroup"); |
3783
17a76f40e236
(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
|
1804 |
|
17a76f40e236
(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
|
1805 |
/* If ``n-id'' (or ``idcount'') is zero, this is a ``feature |
17a76f40e236
(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
|
1806 |
* callback''. */ |
17a76f40e236
(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
|
1807 |
if (idcount == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1808 |
grfmsg(2, "FeatureMapSpriteGroup: Feature callbacks not implemented yet"); |
3783
17a76f40e236
(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
|
1809 |
return; |
17a76f40e236
(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
|
1810 |
} |
17a76f40e236
(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
|
1811 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1812 |
cidcount = buf[3 + idcount]; |
3879
3e9cd6403d73
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1813 |
check_length(len, 4 + idcount + cidcount * 3, "FeatureMapSpriteGroup"); |
3e9cd6403d73
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1814 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1815 |
grfmsg(6, "FeatureMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d", |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1816 |
feature, idcount, cidcount, wagover); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1817 |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1818 |
if (feature > GSF_STATION) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1819 |
grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature %d, skipping", feature); |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1820 |
return; |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1821 |
} |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1822 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1823 |
|
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
1824 |
if (feature == GSF_STATION) { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1825 |
// We do things differently for stations. |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1826 |
|
403
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1827 |
for (i = 0; i < idcount; i++) { |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1828 |
uint8 stid = buf[3 + i]; |
3768
46d328178509
(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
|
1829 |
StationSpec *statspec = _cur_grffile->stations[stid]; |
403
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1830 |
byte *bp = &buf[4 + idcount]; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1831 |
|
403
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1832 |
for (c = 0; c < cidcount; c++) { |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1833 |
uint8 ctype = grf_load_byte(&bp); |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1834 |
uint16 groupid = grf_load_word(&bp); |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1835 |
|
2516
b11f1229cefd
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1836 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1837 |
grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
403
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1838 |
groupid, _cur_grffile->spritegroups_count); |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1839 |
return; |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1840 |
} |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1841 |
|
3750
a8600490f8fc
(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
|
1842 |
if (ctype == 0xFE) ctype = GC_DEFAULT_NA; |
a8600490f8fc
(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
|
1843 |
if (ctype == 0xFF) ctype = GC_PURCHASE; |
a8600490f8fc
(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
|
1844 |
|
5338
5b48218d8bd2
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5334
diff
changeset
|
1845 |
if (ctype >= NUM_GLOBAL_CID) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1846 |
grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); |
5338
5b48218d8bd2
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5334
diff
changeset
|
1847 |
continue; |
5b48218d8bd2
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5334
diff
changeset
|
1848 |
} |
5b48218d8bd2
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5334
diff
changeset
|
1849 |
|
3750
a8600490f8fc
(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
|
1850 |
statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid]; |
403
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1851 |
} |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1852 |
} |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1853 |
|
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1854 |
{ |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1855 |
byte *bp = buf + 4 + idcount + cidcount * 3; |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1856 |
uint16 groupid = grf_load_word(&bp); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1857 |
|
2516
b11f1229cefd
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1858 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1859 |
grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1860 |
groupid, _cur_grffile->spritegroups_count); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1861 |
return; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1862 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1863 |
|
403
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1864 |
for (i = 0; i < idcount; i++) { |
bfb365c74e80
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
401
diff
changeset
|
1865 |
uint8 stid = buf[3 + i]; |
3768
46d328178509
(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
|
1866 |
StationSpec *statspec = _cur_grffile->stations[stid]; |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1867 |
|
3750
a8600490f8fc
(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
|
1868 |
statspec->spritegroup[GC_DEFAULT] = _cur_grffile->spritegroups[groupid]; |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1869 |
statspec->grfid = _cur_grffile->grfid; |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1870 |
statspec->localidx = stid; |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1871 |
SetCustomStationSpec(statspec); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1872 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1873 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1874 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1875 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1876 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1877 |
// FIXME: Tropicset contains things like: |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1878 |
// 03 00 01 19 01 00 00 00 00 - this is missing one 00 at the end, |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1879 |
// what should we exactly do with that? --pasky |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1880 |
|
3635
59265706435c
(svn r4540) - NewGRF: don't treat integer values as boolean.
peter1138
parents:
3634
diff
changeset
|
1881 |
if (_cur_grffile->spriteset_start == 0 || _cur_grffile->spritegroups == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1882 |
grfmsg(1, "FeatureMapSpriteGroup: No sprite set to work on! Skipping"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1883 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1884 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1885 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1886 |
if (!wagover && last_engines_count != idcount) { |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
1887 |
ReallocT(&last_engines, idcount); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1888 |
last_engines_count = idcount; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1889 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1890 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1891 |
if (wagover) { |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1892 |
if (last_engines_count == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1893 |
grfmsg(0, "FeatureMapSpriteGroup: WagonOverride: No engine to do override with"); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1894 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1895 |
} |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1896 |
grfmsg(6, "FeatureMapSpriteGroup: WagonOverride: %u engines, %u wagons", |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1897 |
last_engines_count, idcount); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1898 |
} |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1899 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1900 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1901 |
for (i = 0; i < idcount; i++) { |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1902 |
uint8 engine_id = buf[3 + i]; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1903 |
uint8 engine = engine_id + _vehshifts[feature]; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1904 |
byte *bp = &buf[4 + idcount]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1905 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1906 |
if (engine_id > _vehcounts[feature]) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1907 |
grfmsg(0, "Id %u for feature 0x%02X is out of bounds", engine_id, feature); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1908 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1909 |
} |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1910 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1911 |
grfmsg(7, "FeatureMapSpriteGroup: [%d] Engine %d...", i, engine); |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1912 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1913 |
for (c = 0; c < cidcount; c++) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1914 |
uint8 ctype = grf_load_byte(&bp); |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1915 |
uint16 groupid = grf_load_word(&bp); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1916 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1917 |
grfmsg(8, "FeatureMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid); |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1918 |
|
2516
b11f1229cefd
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1919 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1920 |
grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1921 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1922 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1923 |
|
1802
448f187042d3
(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
|
1924 |
if (ctype == GC_INVALID) ctype = GC_PURCHASE; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1925 |
|
5338
5b48218d8bd2
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5334
diff
changeset
|
1926 |
if (ctype >= NUM_GLOBAL_CID) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1927 |
grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); |
5338
5b48218d8bd2
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5334
diff
changeset
|
1928 |
continue; |
5b48218d8bd2
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5334
diff
changeset
|
1929 |
} |
5b48218d8bd2
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5334
diff
changeset
|
1930 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1931 |
if (wagover) { |
4869
cded5f3a83c9
(svn r6795) - NewGRF: Add support for cargo-specific wagon overrides.
peter1138
parents:
4818
diff
changeset
|
1932 |
SetWagonOverrideSprites(engine, ctype, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1933 |
} else { |
2444
e618726432a4
(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
|
1934 |
SetCustomEngineSprites(engine, ctype, _cur_grffile->spritegroups[groupid]); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1935 |
last_engines[i] = engine; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1936 |
} |
0 | 1937 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1938 |
} |
0 | 1939 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1940 |
{ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1941 |
byte *bp = buf + 4 + idcount + cidcount * 3; |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1942 |
uint16 groupid = grf_load_word(&bp); |
0 | 1943 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1944 |
grfmsg(8, "-- Default group id 0x%04X", groupid); |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1945 |
|
0 | 1946 |
for (i = 0; i < idcount; i++) { |
1947 |
uint8 engine = buf[3 + i] + _vehshifts[feature]; |
|
1948 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1949 |
// Don't tell me you don't love duplicated code! |
2516
b11f1229cefd
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1950 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1951 |
grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1952 |
return; |
0 | 1953 |
} |
1954 |
||
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1955 |
if (wagover) { |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1956 |
/* If the ID for this action 3 is the same as the vehicle ID, |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1957 |
* this indicates we have a helicopter rotor override. */ |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1958 |
if (feature == GSF_AIRCRAFT && engine == last_engines[i]) { |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1959 |
SetRotorOverrideSprites(engine, _cur_grffile->spritegroups[groupid]); |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1960 |
} else { |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1961 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
4869
cded5f3a83c9
(svn r6795) - NewGRF: Add support for cargo-specific wagon overrides.
peter1138
parents:
4818
diff
changeset
|
1962 |
SetWagonOverrideSprites(engine, GC_DEFAULT, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1963 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1964 |
} else { |
2444
e618726432a4
(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
|
1965 |
SetCustomEngineSprites(engine, GC_DEFAULT, _cur_grffile->spritegroups[groupid]); |
3924
de86db4fbd1e
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents:
3895
diff
changeset
|
1966 |
SetEngineGRF(engine, _cur_grffile); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1967 |
last_engines[i] = engine; |
0 | 1968 |
} |
1969 |
} |
|
1970 |
} |
|
1971 |
} |
|
1972 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1973 |
/* Action 0x04 */ |
3879
3e9cd6403d73
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
1974 |
static void FeatureNewName(byte *buf, int len) |
0 | 1975 |
{ |
1976 |
/* <04> <veh-type> <language-id> <num-veh> <offset> <data...> |
|
1977 |
* |
|
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1978 |
* B veh-type see action 0 (as 00..07, + 0A |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1979 |
* But IF veh-type = 48, then generic text |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1980 |
* B language-id If bit 6 is set, This is the extended language scheme, |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1981 |
with up to 64 language. |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1982 |
Otherwise, it is a mapping where set bits have meaning |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1983 |
0 = american, 1 = english, 2 = german, 3 = french, 4 = spanish |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1984 |
Bit 7 set means this is a generic text, not a vehicle one (or else) |
0 | 1985 |
* B num-veh number of vehicles which are getting a new name |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1986 |
* B/W offset number of the first vehicle that gets a new name |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1987 |
* Byte : ID of vehicle to change |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1988 |
* Word : ID of string to change/add |
0 | 1989 |
* S data new texts, each of them zero-terminated, after |
1990 |
* which the next name begins. */ |
|
1991 |
/* TODO: No support for changing non-vehicle text. Perhaps we shouldn't |
|
1992 |
* implement it at all, but it could be useful for some "modpacks" |
|
1993 |
* (completely new scenarios changing all graphics and logically also |
|
1994 |
* factory names etc). We should then also support all languages (by |
|
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1995 |
* name), not only the original four ones. --pasky |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1996 |
* All of the above are coming. In Time. Some sooner than others :)*/ |
0 | 1997 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1998 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1999 |
uint8 lang; |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2000 |
uint8 num; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2001 |
uint16 id; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2002 |
uint16 endid; |
1329 | 2003 |
const char* name; |
3643
5d1f3fe61036
(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
|
2004 |
bool new_scheme = _cur_grffile->grf_version >= 7; |
4992
6d0a80c5c654
(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
|
2005 |
bool generic; |
0 | 2006 |
|
3879
3e9cd6403d73
(svn r4928) CodeChange : Rename functions referring to "Vehicle" for "Feature".
belugas
parents:
3875
diff
changeset
|
2007 |
check_length(len, 6, "FeatureNewName"); |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2008 |
buf++; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2009 |
feature = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2010 |
lang = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2011 |
num = grf_load_byte(&buf); |
4992
6d0a80c5c654
(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
|
2012 |
generic = HASBIT(lang, 7); |
6d0a80c5c654
(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
|
2013 |
id = generic ? grf_load_word(&buf) : grf_load_byte(&buf); |
6d0a80c5c654
(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
|
2014 |
|
6d0a80c5c654
(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
|
2015 |
CLRBIT(lang, 7); |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2016 |
|
3760
10a6f762e754
(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
|
2017 |
if (feature <= GSF_AIRCRAFT && id < _vehcounts[feature]) { |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2018 |
id += _vehshifts[feature]; |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2019 |
} |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2020 |
endid = id + num; |
0 | 2021 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2022 |
grfmsg(6, "FeatureNewName: About to rename engines %d..%d (feature %d) in language 0x%02X", |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
2023 |
id, endid, feature, lang); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
2024 |
|
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2025 |
name = (const char*)buf; /*transfer read value*/ |
4992
6d0a80c5c654
(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
|
2026 |
len -= generic ? 6 : 5; |
6d0a80c5c654
(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
|
2027 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2028 |
for (; id < endid && len > 0; id++) { |
2458
c95808cd2ac9
(svn r2984) Use adequate types, this should aid portability a bit
tron
parents:
2456
diff
changeset
|
2029 |
size_t ofs = strlen(name) + 1; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2030 |
|
4711
bfeaddae37c5
(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
|
2031 |
if (ofs < 128) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2032 |
grfmsg(8, "FeatureNewName: %d <- %s", id, name); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2033 |
|
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2034 |
switch (feature) { |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2035 |
case GSF_TRAIN: |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2036 |
case GSF_ROAD: |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2037 |
case GSF_SHIP: |
3614 | 2038 |
case GSF_AIRCRAFT: { |
3821
2bb8a2643fdf
(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
|
2039 |
if (id < TOTAL_NUM_ENGINES) { |
2bb8a2643fdf
(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
|
2040 |
StringID string = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_8000_KIRBY_PAUL_TANK_STEAM + id); |
2bb8a2643fdf
(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
|
2041 |
SetCustomEngineName(id, string); |
2bb8a2643fdf
(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
|
2042 |
} else { |
2bb8a2643fdf
(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
|
2043 |
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, id); |
2bb8a2643fdf
(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
|
2044 |
} |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2045 |
break; |
3614 | 2046 |
} |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2047 |
|
3760
10a6f762e754
(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
|
2048 |
default: |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2049 |
switch (GB(id, 8, 8)) { |
3760
10a6f762e754
(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
|
2050 |
case 0xC4: /* Station class name */ |
3768
46d328178509
(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
|
2051 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2052 |
grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
3760
10a6f762e754
(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
|
2053 |
} else { |
3768
46d328178509
(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
|
2054 |
StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass; |
3821
2bb8a2643fdf
(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
|
2055 |
SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED)); |
3760
10a6f762e754
(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
|
2056 |
} |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2057 |
break; |
3760
10a6f762e754
(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
|
2058 |
|
10a6f762e754
(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
|
2059 |
case 0xC5: /* Station name */ |
3768
46d328178509
(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
|
2060 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2061 |
grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
3760
10a6f762e754
(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
|
2062 |
} else { |
3821
2bb8a2643fdf
(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
|
2063 |
_cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
3760
10a6f762e754
(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
|
2064 |
} |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2065 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2066 |
|
4504
3d20af4bd525
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2067 |
case 0xC9: |
3d20af4bd525
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2068 |
case 0xD0: |
3d20af4bd525
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2069 |
case 0xDC: |
3d20af4bd525
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2070 |
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
3d20af4bd525
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2071 |
break; |
3d20af4bd525
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
2072 |
|
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2073 |
default: |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2074 |
grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2075 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2076 |
} |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2077 |
break; |
3642
a247e07fafdf
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
2078 |
|
a247e07fafdf
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
2079 |
#if 0 |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2080 |
case GSF_CANAL : |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2081 |
case GSF_BRIDGE : |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2082 |
case GSF_TOWNHOUSE : |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2083 |
AddGRFString(_cur_spriteid, id, lang, name); |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2084 |
switch (GB(id, 8,8)) { |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2085 |
case 0xC9: /* House name */ |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2086 |
default: |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2087 |
grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2088 |
} |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2089 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2090 |
|
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2091 |
case GSF_INDUSTRIES : |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2092 |
case 0x48 : /* for generic strings */ |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2093 |
AddGRFString(_cur_spriteid, id, lang, name); |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2094 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2095 |
default : |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2096 |
grfmsg(7, "FeatureNewName: Unsupported feature (0x%02X)", feature); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2097 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2098 |
#endif |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2099 |
} |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
2100 |
} else { |
3863
62f1303f4bb4
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
peter1138
parents:
3862
diff
changeset
|
2101 |
/* ofs is the string length + 1, so if the string is empty, ofs |
62f1303f4bb4
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
peter1138
parents:
3862
diff
changeset
|
2102 |
* is 1 */ |
62f1303f4bb4
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
peter1138
parents:
3862
diff
changeset
|
2103 |
if (ofs == 1) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2104 |
grfmsg(7, "FeatureNewName: Can't add empty name"); |
3863
62f1303f4bb4
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
peter1138
parents:
3862
diff
changeset
|
2105 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2106 |
grfmsg(7, "FeatureNewName: Too long a name (%d)", ofs); |
3863
62f1303f4bb4
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
peter1138
parents:
3862
diff
changeset
|
2107 |
} |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
2108 |
} |
1329 | 2109 |
name += ofs; |
4321
b763b7007162
(svn r5974) -Codechange: added casts all around the place to make Windows 64bit happy (michi_cc)
truelight
parents:
4297
diff
changeset
|
2110 |
len -= (int)ofs; |
0 | 2111 |
} |
2112 |
} |
|
2113 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2114 |
/* Action 0x05 */ |
0 | 2115 |
static void GraphicsNew(byte *buf, int len) |
2116 |
{ |
|
2117 |
/* <05> <graphics-type> <num-sprites> <other data...> |
|
2118 |
* |
|
2119 |
* B graphics-type What set of graphics the sprites define. |
|
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2120 |
* E num-sprites How many sprites are in this set? |
0 | 2121 |
* V other data Graphics type specific data. Currently unused. */ |
2122 |
/* TODO */ |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2123 |
|
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2124 |
uint8 type; |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2125 |
uint16 num; |
3708
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2126 |
SpriteID replace = 0; |
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2127 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2128 |
check_length(len, 2, "GraphicsNew"); |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2129 |
buf++; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2130 |
type = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2131 |
num = grf_load_extended(&buf); |
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2132 |
|
3638
6e0b43d905d4
(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
|
2133 |
switch (type) { |
6e0b43d905d4
(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
|
2134 |
case 0x04: /* Signal graphics */ |
6e0b43d905d4
(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
|
2135 |
if (num != 112 && num != 240) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2136 |
grfmsg(1, "GraphicsNews: Signal graphics sprite count must be 112 or 240, skipping"); |
3638
6e0b43d905d4
(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
|
2137 |
return; |
6e0b43d905d4
(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
|
2138 |
} |
6e0b43d905d4
(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
|
2139 |
_signal_base = _cur_spriteid; |
6e0b43d905d4
(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
|
2140 |
break; |
6e0b43d905d4
(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
|
2141 |
|
3708
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2142 |
case 0x05: /* Catenary graphics */ |
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2143 |
if (num != 48) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2144 |
grfmsg(1, "GraphicsNews: Catenary graphics sprite count must be 48, skipping"); |
3708
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2145 |
return; |
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2146 |
} |
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2147 |
replace = SPR_ELRAIL_BASE + 3; |
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2148 |
break; |
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2149 |
|
3709
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2150 |
case 0x06: /* Foundations */ |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2151 |
if (num != 74) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2152 |
grfmsg(1, "GraphicsNews: Foundation graphics sprite count must be 74, skipping"); |
3709
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2153 |
return; |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2154 |
} |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2155 |
replace = SPR_SLOPES_BASE; |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2156 |
break; |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2157 |
|
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2158 |
case 0x08: /* Canal graphics */ |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2159 |
if (num != 65) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2160 |
grfmsg(1, "GraphicsNews: Canal graphics sprite count must be 65, skipping"); |
3709
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2161 |
return; |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2162 |
} |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2163 |
replace = SPR_CANALS_BASE + 5; |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2164 |
break; |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
2165 |
|
5210
dc52acfad05c
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2166 |
case 0x0D: /* Coast graphics */ |
dc52acfad05c
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2167 |
if (num != 16) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2168 |
grfmsg(1, "GraphicsNews: Coast graphics sprite count must be 16, skipping"); |
5210
dc52acfad05c
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2169 |
return; |
dc52acfad05c
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2170 |
} |
dc52acfad05c
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2171 |
_coast_base = _cur_spriteid; |
dc52acfad05c
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2172 |
break; |
dc52acfad05c
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
2173 |
|
3638
6e0b43d905d4
(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
|
2174 |
default: |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2175 |
grfmsg(2, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring)", |
3638
6e0b43d905d4
(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
|
2176 |
type, num); |
6e0b43d905d4
(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
|
2177 |
return; |
6e0b43d905d4
(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
|
2178 |
} |
6e0b43d905d4
(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
|
2179 |
|
3708
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2180 |
if (replace == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2181 |
grfmsg(2, "GraphicsNew: Loading %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, _cur_spriteid); |
3708
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2182 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2183 |
grfmsg(2, "GraphicsNew: Replacing %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, replace); |
3708
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2184 |
} |
3638
6e0b43d905d4
(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
|
2185 |
|
6e0b43d905d4
(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
|
2186 |
for (; num > 0; num--) { |
3708
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
2187 |
LoadNextSprite(replace == 0 ? _cur_spriteid++ : replace++, _file_index); |
3638
6e0b43d905d4
(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
|
2188 |
_nfo_line++; |
6e0b43d905d4
(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
|
2189 |
} |
0 | 2190 |
} |
2191 |
||
3806 | 2192 |
static uint32 GetParamVal(byte param, uint32 *cond_val) |
2193 |
{ |
|
2194 |
switch (param) { |
|
5340
82c981816fcb
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5338
diff
changeset
|
2195 |
case 0x81: /* current year */ |
82c981816fcb
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5338
diff
changeset
|
2196 |
return clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; |
82c981816fcb
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5338
diff
changeset
|
2197 |
|
3806 | 2198 |
case 0x83: /* current climate, 0=temp, 1=arctic, 2=trop, 3=toyland */ |
2199 |
return _opt.landscape; |
|
2200 |
||
5161
a064564a4a70
(svn r7266) -Codechange: Make the NewGRF loading stage look like ttdpatch to NewGRFs
peter1138
parents:
5115
diff
changeset
|
2201 |
case 0x84: /* GRF loading stage */ |
a064564a4a70
(svn r7266) -Codechange: Make the NewGRF loading stage look like ttdpatch to NewGRFs
peter1138
parents:
5115
diff
changeset
|
2202 |
return (_cur_stage > GLS_INIT) | ((_cur_stage == GLS_ACTIVATION) << 9); |
3806 | 2203 |
|
3811
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2204 |
case 0x85: /* TTDPatch flags, only for bit tests */ |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2205 |
if (cond_val == NULL) { |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2206 |
/* Supported in Action 0x07 and 0x09, not 0x0D */ |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2207 |
return 0; |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2208 |
} else { |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2209 |
uint32 param_val = _ttdpatch_flags[*cond_val / 0x20]; |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2210 |
*cond_val %= 0x20; |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2211 |
return param_val; |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2212 |
} |
3806 | 2213 |
|
2214 |
case 0x86: /* road traffic side, bit 4 clear=left, set=right */ |
|
2215 |
return _opt.road_side << 4; |
|
2216 |
||
2217 |
case 0x88: /* GRF ID check */ |
|
2218 |
return 0; |
|
2219 |
||
2220 |
case 0x8B: { /* TTDPatch version */ |
|
2221 |
uint major = 2; |
|
4993
7d84a318e3a4
(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
|
2222 |
uint minor = 6; |
7d84a318e3a4
(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
|
2223 |
uint revision = 0; // special case: 2.0.1 is 2.0.10 |
7d84a318e3a4
(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
|
2224 |
uint build = 1168; |
7d84a318e3a4
(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
|
2225 |
return (major << 24) | (minor << 20) | (revision << 16) | build; |
3806 | 2226 |
} |
2227 |
||
2228 |
case 0x8D: /* TTD Version, 00=DOS, 01=Windows */ |
|
2229 |
return !_use_dos_palette; |
|
2230 |
||
2231 |
case 0x8E: /* Y-offset for train sprites */ |
|
2232 |
return _traininfo_vehicle_pitch; |
|
2233 |
||
2234 |
case 0x92: /* Game mode */ |
|
2235 |
return _game_mode; |
|
2236 |
||
5287
94a6c3c924b2
(svn r7436) -Codechange: Add action7/9/D variable 0x9A (-1)
peter1138
parents:
5234
diff
changeset
|
2237 |
case 0x9A: /* Always -1 */ |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
2238 |
return UINT_MAX; |
5287
94a6c3c924b2
(svn r7436) -Codechange: Add action7/9/D variable 0x9A (-1)
peter1138
parents:
5234
diff
changeset
|
2239 |
|
3806 | 2240 |
case 0x9D: /* TTD Platform, 00=TTDPatch, 01=OpenTTD */ |
2241 |
return 1; |
|
2242 |
||
3814
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2243 |
case 0x9E: /* Miscellaneous GRF features */ |
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2244 |
return _misc_grf_features; |
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2245 |
|
3806 | 2246 |
default: |
2247 |
/* GRF Parameter */ |
|
2248 |
if (param < 0x80) return _cur_grffile->param[param]; |
|
2249 |
||
2250 |
/* In-game variable. */ |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2251 |
grfmsg(1, "Unsupported in-game variable 0x%02X", param); |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
2252 |
return UINT_MAX; |
3806 | 2253 |
} |
2254 |
} |
|
2255 |
||
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2256 |
/* Action 0x06 */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2257 |
static void CfgApply(byte *buf, int len) |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2258 |
{ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2259 |
/* <06> <param-num> <param-size> <offset> ... <FF> |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2260 |
* |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2261 |
* B param-num Number of parameter to substitute (First = "zero") |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2262 |
* Ignored if that parameter was not specified in newgrf.cfg |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2263 |
* B param-size How many bytes to replace. If larger than 4, the |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2264 |
* bytes of the following parameter are used. In that |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2265 |
* case, nothing is applied unless *all* parameters |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2266 |
* were specified. |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2267 |
* B offset Offset into data from beginning of next sprite |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2268 |
* to place where parameter is to be stored. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2269 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2270 |
/* Preload the next sprite */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2271 |
uint32 pos = FioGetPos(); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2272 |
uint16 num = FioReadWord(); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2273 |
uint8 type = FioReadByte(); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2274 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2275 |
/* Check if the sprite is a pseudo sprite. We can't operate on real sprites. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2276 |
if (type == 0xFF) { |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
2277 |
MallocT(&_preload_sprite, num); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2278 |
FioReadBlock(_preload_sprite, num); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2279 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2280 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2281 |
/* Reset the file position to the start of the next sprite */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2282 |
FioSeekTo(pos, SEEK_SET); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2283 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2284 |
if (type != 0xFF) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2285 |
grfmsg(2, "CfgApply: Ignoring (next sprite is real, unsupported)"); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2286 |
return; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2287 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2288 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2289 |
/* Now perform the Action 0x06 on our data. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2290 |
buf++; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2291 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2292 |
for (;;) { |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2293 |
uint i; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2294 |
uint param_num; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2295 |
uint param_size; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2296 |
uint offset; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2297 |
bool add_value; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2298 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2299 |
/* Read the parameter to apply. 0xFF indicates no more data to change. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2300 |
param_num = grf_load_byte(&buf); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2301 |
if (param_num == 0xFF) break; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2302 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2303 |
/* Get the size of the parameter to use. If the size covers multiple |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2304 |
* double words, sequential parameter values are used. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2305 |
param_size = grf_load_byte(&buf); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2306 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2307 |
/* Bit 7 of param_size indicates we should add to the original value |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2308 |
* instead of replacing it. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2309 |
add_value = HASBIT(param_size, 7); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2310 |
param_size = GB(param_size, 0, 7); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2311 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2312 |
/* Where to apply the data to within the pseudo sprite data. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2313 |
offset = grf_load_extended(&buf); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2314 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2315 |
/* If the parameter is a GRF parameter (not an internal variable) check |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2316 |
* if it (and all further sequential parameters) has been defined. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2317 |
if (param_num < 0x80 && (param_num + (param_size - 1) / 4) >= _cur_grffile->param_end) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2318 |
grfmsg(2, "CfgApply: Ignoring (param %d not set)", (param_num + (param_size - 1) / 4)); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2319 |
break; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2320 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2321 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2322 |
grfmsg(8, "CfgApply: Applying %u bytes from parameter 0x%02X at offset 0x%04X", param_size, param_num, offset); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2323 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2324 |
for (i = 0; i < param_size; i++) { |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2325 |
uint32 value = GetParamVal(param_num + i / 4, NULL); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2326 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2327 |
if (add_value) { |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2328 |
_preload_sprite[offset + i] += GB(value, (i % 4) * 8, 8); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2329 |
} else { |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2330 |
_preload_sprite[offset + i] = GB(value, (i % 4) * 8, 8); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2331 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2332 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2333 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2334 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
2335 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2336 |
/* Action 0x07 */ |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2337 |
/* Action 0x09 */ |
0 | 2338 |
static void SkipIf(byte *buf, int len) |
2339 |
{ |
|
2340 |
/* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites> |
|
2341 |
* |
|
2342 |
* B param-num |
|
2343 |
* B param-size |
|
2344 |
* B condition-type |
|
2345 |
* V value |
|
2346 |
* B num-sprites */ |
|
2347 |
/* TODO: More params. More condition types. */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2348 |
uint8 param; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2349 |
uint8 paramsize; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2350 |
uint8 condtype; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2351 |
uint8 numsprites; |
2336
48ace1344af0
(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
|
2352 |
uint32 param_val = 0; |
48ace1344af0
(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
|
2353 |
uint32 cond_val = 0; |
3806 | 2354 |
uint32 mask = 0; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
2355 |
bool result; |
3561
29c95ab685c0
(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
|
2356 |
GRFLabel *label; |
29c95ab685c0
(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
|
2357 |
GRFLabel *choice = NULL; |
0 | 2358 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2359 |
check_length(len, 6, "SkipIf"); |
3714
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
2360 |
buf++; |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
2361 |
param = grf_load_byte(&buf); |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
2362 |
paramsize = grf_load_byte(&buf); |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
2363 |
condtype = grf_load_byte(&buf); |
0 | 2364 |
|
359
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
2365 |
if (condtype < 2) { |
1611 | 2366 |
/* Always 1 for bit tests, the given value should be ignored. */ |
359
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
2367 |
paramsize = 1; |
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
2368 |
} |
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
2369 |
|
1611 | 2370 |
switch (paramsize) { |
3806 | 2371 |
case 4: cond_val = grf_load_dword(&buf); mask = 0xFFFFFFFF; break; |
2372 |
case 2: cond_val = grf_load_word(&buf); mask = 0x0000FFFF; break; |
|
2373 |
case 1: cond_val = grf_load_byte(&buf); mask = 0x000000FF; break; |
|
1611 | 2374 |
default: break; |
2375 |
} |
|
359
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
2376 |
|
3806 | 2377 |
if (param < 0x80 && _cur_grffile->param_end <= param) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2378 |
grfmsg(7, "Param %d undefined, skipping test", param); |
3806 | 2379 |
return; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2380 |
} |
0 | 2381 |
|
3806 | 2382 |
param_val = GetParamVal(param, &cond_val); |
2383 |
||
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2384 |
grfmsg(7, "Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val); |
5623
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2385 |
|
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2386 |
if (param == 0x88) { |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2387 |
/* GRF ID checks */ |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2388 |
|
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2389 |
const GRFConfig *c = GetGRFConfig(cond_val); |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2390 |
|
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2391 |
if (condtype != 10 && c == NULL) { |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2392 |
grfmsg(7, "GRFID 0x%08X unknown, skipping test", BSWAP32(cond_val)); |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2393 |
return; |
5234
91b7def5e4b2
(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
|
2394 |
} |
91b7def5e4b2
(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
|
2395 |
|
5623
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2396 |
switch (condtype) { |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2397 |
/* Tests 6 to 10 are only for param 0x88, GRFID checks */ |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2398 |
case 6: /* Is GRFID active? */ |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2399 |
result = HASBIT(c->flags, GCF_ACTIVATED); |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2400 |
break; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2401 |
|
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2402 |
case 7: /* Is GRFID non-active? */ |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2403 |
result = !HASBIT(c->flags, GCF_ACTIVATED); |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2404 |
break; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2405 |
|
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2406 |
case 8: /* GRFID is not but will be active? */ |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2407 |
result = !HASBIT(c->flags, GCF_ACTIVATED) && !HASBIT(c->flags, GCF_DISABLED); |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2408 |
break; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2409 |
|
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2410 |
case 9: /* GRFID is or will be active? */ |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2411 |
result = !HASBIT(c->flags, GCF_NOT_FOUND) && !HASBIT(c->flags, GCF_DISABLED); |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2412 |
break; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2413 |
|
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2414 |
case 10: /* GRFID is not nor will be active */ |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2415 |
/* This is the only condtype that doesn't get ignored if the GRFID is not found */ |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2416 |
result = c == NULL || HASBIT(c->flags, GCF_DISABLED) || HASBIT(c->flags, GCF_NOT_FOUND); |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2417 |
break; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2418 |
|
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2419 |
default: grfmsg(1, "Unsupported GRF test %d. Ignoring", condtype); return; |
5234
91b7def5e4b2
(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
|
2420 |
} |
5623
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2421 |
} else { |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2422 |
/* Parameter or variable tests */ |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2423 |
switch (condtype) { |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2424 |
case 0: result = !!(param_val & (1 << cond_val)); |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2425 |
break; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2426 |
case 1: result = !(param_val & (1 << cond_val)); |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2427 |
break; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2428 |
case 2: result = (param_val & mask) == cond_val; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2429 |
break; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2430 |
case 3: result = (param_val & mask) != cond_val; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2431 |
break; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2432 |
case 4: result = (param_val & mask) < cond_val; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2433 |
break; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2434 |
case 5: result = (param_val & mask) > cond_val; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2435 |
break; |
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2436 |
|
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2437 |
default: grfmsg(1, "Unsupported test %d. Ignoring", condtype); return; |
5234
91b7def5e4b2
(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
|
2438 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2439 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2440 |
|
1607
320079c7ac28
(svn r2111) So, result is bool therefore no need for this horrible == 0 thing.
pasky
parents:
1606
diff
changeset
|
2441 |
if (!result) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2442 |
grfmsg(2, "Not skipping sprites, test was false"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2443 |
return; |
359
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
2444 |
} |
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
2445 |
|
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
2446 |
numsprites = grf_load_byte(&buf); |
3561
29c95ab685c0
(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
|
2447 |
|
29c95ab685c0
(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
|
2448 |
/* numsprites can be a GOTO label if it has been defined in the GRF |
29c95ab685c0
(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
|
2449 |
* file. The jump will always be the first matching label that follows |
29c95ab685c0
(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
|
2450 |
* the current nfo_line. If no matching label is found, the first matching |
29c95ab685c0
(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
|
2451 |
* label in the file is used. */ |
29c95ab685c0
(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
|
2452 |
for (label = _cur_grffile->label; label != NULL; label = label->next) { |
29c95ab685c0
(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
|
2453 |
if (label->label != numsprites) continue; |
29c95ab685c0
(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
|
2454 |
|
29c95ab685c0
(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
|
2455 |
/* Remember a goto before the current line */ |
29c95ab685c0
(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
|
2456 |
if (choice == NULL) choice = label; |
29c95ab685c0
(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
|
2457 |
/* If we find a label here, this is definitely good */ |
29c95ab685c0
(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
|
2458 |
if (label->nfo_line > _nfo_line) { |
29c95ab685c0
(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
|
2459 |
choice = label; |
29c95ab685c0
(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
|
2460 |
break; |
29c95ab685c0
(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
|
2461 |
} |
29c95ab685c0
(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
|
2462 |
} |
29c95ab685c0
(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
|
2463 |
|
29c95ab685c0
(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
|
2464 |
if (choice != NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2465 |
grfmsg(2, "Jumping to label 0x%0X at line %d, test was true", choice->label, choice->nfo_line); |
3561
29c95ab685c0
(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
|
2466 |
FioSeekTo(choice->pos, SEEK_SET); |
29c95ab685c0
(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
|
2467 |
_nfo_line = choice->nfo_line; |
29c95ab685c0
(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
|
2468 |
return; |
29c95ab685c0
(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
|
2469 |
} |
29c95ab685c0
(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
|
2470 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2471 |
grfmsg(2, "Skipping %d sprites, test was true", numsprites); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2472 |
_skip_sprites = numsprites; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2473 |
if (_skip_sprites == 0) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2474 |
/* Zero means there are no sprites to skip, so |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2475 |
* we use -1 to indicate that all further |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2476 |
* sprites should be skipped. */ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2477 |
_skip_sprites = -1; |
0 | 2478 |
} |
2479 |
} |
|
2480 |
||
5317
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2481 |
|
5648
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2482 |
/* Action 0x08 (GLS_FILESCAN) */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2483 |
static void ScanInfo(byte *buf, int len) |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2484 |
{ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2485 |
uint8 version; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2486 |
uint32 grfid; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2487 |
const char *name; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2488 |
const char *info; |
5317
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2489 |
int name_len; |
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2490 |
int info_len; |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2491 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2492 |
check_length(len, 8, "Info"); buf++; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2493 |
version = grf_load_byte(&buf); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2494 |
grfid = grf_load_dword(&buf); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2495 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2496 |
_cur_grfconfig->grfid = grfid; |
5317
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2497 |
|
5329
2b117d8652f0
(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
|
2498 |
/* GRF IDs starting with 0xFF are reserved for internal TTDPatch use */ |
2b117d8652f0
(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
|
2499 |
if (GB(grfid, 24, 8) == 0xFF) SETBIT(_cur_grfconfig->flags, GCF_SYSTEM); |
2b117d8652f0
(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
|
2500 |
|
5317
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2501 |
len -= 6; |
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2502 |
name = (const char*)buf; |
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2503 |
name_len = ttd_strnlen(name, len); |
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2504 |
|
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2505 |
if (name_len < len) { |
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2506 |
_cur_grfconfig->name = TranslateTTDPatchCodes(name); |
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2507 |
|
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2508 |
len -= name_len + 1; |
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2509 |
info = name + name_len + 1; |
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2510 |
info_len = ttd_strnlen(info, len); |
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2511 |
|
5623
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
2512 |
if (info_len < len) _cur_grfconfig->info = TranslateTTDPatchCodes(info); |
5317
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
2513 |
} |
5329
2b117d8652f0
(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
|
2514 |
|
2b117d8652f0
(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
|
2515 |
/* GLS_INFOSCAN only looks for the action 8, so we can skip the rest of the file */ |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2516 |
_skip_sprites = -1; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2517 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
2518 |
|
3640
b73687dd2b62
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2519 |
/* Action 0x08 */ |
0 | 2520 |
static void GRFInfo(byte *buf, int len) |
2521 |
{ |
|
2522 |
/* <08> <version> <grf-id> <name> <info> |
|
2523 |
* |
|
2524 |
* B version newgrf version, currently 06 |
|
2525 |
* 4*B grf-id globally unique ID of this .grf file |
|
2526 |
* S name name of this .grf set |
|
2527 |
* S info string describing the set, and e.g. author and copyright */ |
|
2528 |
/* TODO: Check version. (We should have own versioning done somehow.) */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2529 |
uint8 version; |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
2530 |
uint32 grfid; |
1329 | 2531 |
const char *name; |
0 | 2532 |
|
3711
4a0d1c635b56
(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
|
2533 |
check_length(len, 8, "GRFInfo"); buf++; |
3712
b0e03bf96808
(svn r4655) - Fix [NewGRF r4654]: /me bangs head against the wall....gaah
Darkvater
parents:
3711
diff
changeset
|
2534 |
version = grf_load_byte(&buf); |
3711
4a0d1c635b56
(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
|
2535 |
grfid = grf_load_dword(&buf); |
4a0d1c635b56
(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
|
2536 |
name = (const char*)buf; |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
2537 |
|
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
2538 |
_cur_grffile->grfid = grfid; |
3640
b73687dd2b62
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2539 |
_cur_grffile->grf_version = version; |
5234
91b7def5e4b2
(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
|
2540 |
SETBIT(_cur_grfconfig->flags, GCF_ACTIVATED); |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
2541 |
|
3711
4a0d1c635b56
(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
|
2542 |
/* Do swap the GRFID for displaying purposes since people expect that */ |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2543 |
DEBUG(grf, 1, "Loaded GRFv%d set %08lX - %s", version, BSWAP32(grfid), name); |
0 | 2544 |
} |
2545 |
||
3640
b73687dd2b62
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2546 |
/* Action 0x0A */ |
0 | 2547 |
static void SpriteReplace(byte *buf, int len) |
2548 |
{ |
|
2549 |
/* <0A> <num-sets> <set1> [<set2> ...] |
|
2550 |
* <set>: <num-sprites> <first-sprite> |
|
2551 |
* |
|
2552 |
* B num-sets How many sets of sprites to replace. |
|
2553 |
* Each set: |
|
2554 |
* B num-sprites How many sprites are in this set |
|
2555 |
* W first-sprite First sprite number to replace */ |
|
361
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
2556 |
uint8 num_sets; |
2342
c19fb4f2df30
(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
|
2557 |
uint i; |
361
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
2558 |
|
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
2559 |
buf++; /* skip action byte */ |
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
2560 |
num_sets = grf_load_byte(&buf); |
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
2561 |
|
2342
c19fb4f2df30
(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
|
2562 |
for (i = 0; i < num_sets; i++) { |
c19fb4f2df30
(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
|
2563 |
uint8 num_sprites = grf_load_byte(&buf); |
c19fb4f2df30
(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
|
2564 |
uint16 first_sprite = grf_load_word(&buf); |
c19fb4f2df30
(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
|
2565 |
uint j; |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
2566 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2567 |
grfmsg(2, "SpriteReplace: [Set %d] Changing %d sprites, beginning with %d", |
2342
c19fb4f2df30
(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
|
2568 |
i, num_sprites, first_sprite |
c19fb4f2df30
(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
|
2569 |
); |
361
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
2570 |
|
2342
c19fb4f2df30
(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
|
2571 |
for (j = 0; j < num_sprites; j++) { |
c19fb4f2df30
(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
|
2572 |
LoadNextSprite(first_sprite + j, _file_index); // XXX |
3557
5d12a78ce141
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
2573 |
_nfo_line++; |
361
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
2574 |
} |
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
2575 |
} |
0 | 2576 |
} |
2577 |
||
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2578 |
/* Action 0x0B */ |
0 | 2579 |
static void GRFError(byte *buf, int len) |
2580 |
{ |
|
2581 |
/* <0B> <severity> <language-id> <message-id> [<message...> 00] [<data...>] 00 [<parnum>] |
|
2582 |
* |
|
2583 |
* B severity 00: notice, contine loading grf file |
|
2584 |
* 01: warning, continue loading grf file |
|
2585 |
* 02: error, but continue loading grf file, and attempt |
|
2586 |
* loading grf again when loading or starting next game |
|
2587 |
* 03: error, abort loading and prevent loading again in |
|
2588 |
* the future (only when restarting the patch) |
|
2589 |
* B language-id see action 4, use 1F for built-in error messages |
|
2590 |
* B message-id message to show, see below |
|
2591 |
* S message for custom messages (message-id FF), text of the message |
|
2592 |
* not present for built-in messages. |
|
2593 |
* V data additional data for built-in (or custom) messages |
|
2594 |
* B parnum see action 6, only used with built-in message 03 */ |
|
2595 |
/* TODO: For now we just show the message, sometimes incomplete and never translated. */ |
|
2596 |
||
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2597 |
static const char *const msgstr[] = { |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2598 |
"%sRequires at least pseudo-TTDPatch version %s", |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2599 |
"%sThis file is for %s version of TTD", |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2600 |
"%sDesigned to be used with %s", |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2601 |
"%sInvalid parameter %s", |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2602 |
"%sMust be loaded before %s", |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2603 |
"%sMust be loaded after %s", |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2604 |
"%s%s" |
0 | 2605 |
}; |
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2606 |
|
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2607 |
static const char *const sevstr[] = { |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2608 |
"", |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2609 |
"Warning: ", |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2610 |
"Error: ", |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2611 |
"Fatal: ", |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2612 |
}; |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2613 |
uint8 sevid; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2614 |
uint8 msgid; |
0 | 2615 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2616 |
check_length(len, 6, "GRFError"); |
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2617 |
sevid = buf[1]; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2618 |
msgid = buf[3]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2619 |
|
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2620 |
// Undocumented TTDPatch feature. |
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2621 |
if (!HASBIT(sevid, 7) && _cur_stage < GLS_ACTIVATION) { |
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2622 |
grfmsg(7, "Skipping non-fatal GRFError in stage 1"); |
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2623 |
return; |
3588
a1adf8a40756
(svn r4474) - NewGRF: Skip non-fatal errors when not in stage 2.
peter1138
parents:
3577
diff
changeset
|
2624 |
} |
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2625 |
|
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
2626 |
sevid = GB(sevid, 0, 2); |
5570
9ce93d899b1c
(svn r7568) -Fix [r7564]: buf+4 is the same as &buf[4], not buf[4] for a char*.
Darkvater
parents:
5568
diff
changeset
|
2627 |
grfmsg(0, msgstr[(msgid == 0xFF) ? lengthof(msgstr) - 1 : msgid], sevstr[sevid], &buf[4]); |
0 | 2628 |
} |
2629 |
||
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2630 |
/* Action 0x0C */ |
0 | 2631 |
static void GRFComment(byte *buf, int len) |
2632 |
{ |
|
2633 |
/* <0C> [<ignored...>] |
|
2634 |
* |
|
2635 |
* V ignored Anything following the 0C is ignored */ |
|
3561
29c95ab685c0
(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
|
2636 |
|
29c95ab685c0
(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
|
2637 |
static char comment[256]; |
29c95ab685c0
(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
|
2638 |
if (len == 1) return; |
29c95ab685c0
(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
|
2639 |
|
3571 | 2640 |
ttd_strlcpy(comment, (char*)(buf + 1), minu(sizeof(comment), len)); |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2641 |
grfmsg(2, "GRFComment: %s", comment); |
0 | 2642 |
} |
2643 |
||
5648
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2644 |
/* Action 0x0D (GLS_SAFETYSCAN) */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2645 |
static void SafeParamSet(byte *buf, int len) |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2646 |
{ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2647 |
uint8 target; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2648 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2649 |
check_length(len, 5, "SafeParamSet"); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2650 |
buf++; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2651 |
target = grf_load_byte(&buf); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2652 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2653 |
/* Only writing GRF parameters is considered safe */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2654 |
if (target < 0x80) return; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2655 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2656 |
/* GRM could be unsafe, but as here it can only happen after other GRFs |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2657 |
* are loaded, it should be okay. If the GRF tried to use the slots it |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2658 |
* reserved, it would be marked unsafe anyway. GRM for (e.g. bridge) |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2659 |
* sprites is considered safe. */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2660 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2661 |
SETBIT(_cur_grfconfig->flags, GCF_UNSAFE); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2662 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2663 |
/* Skip remainder of GRF */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2664 |
_skip_sprites = -1; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2665 |
} |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2666 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2667 |
/* Action 0x0D */ |
0 | 2668 |
static void ParamSet(byte *buf, int len) |
2669 |
{ |
|
2670 |
/* <0D> <target> <operation> <source1> <source2> [<data>] |
|
2671 |
* |
|
2672 |
* B target parameter number where result is stored |
|
2673 |
* B operation operation to perform, see below |
|
2674 |
* B source1 first source operand |
|
2675 |
* B source2 second source operand |
|
2676 |
* D data data to use in the calculation, not necessary |
|
2677 |
* if both source1 and source2 refer to actual parameters |
|
2678 |
* |
|
2679 |
* Operations |
|
2680 |
* 00 Set parameter equal to source1 |
|
2681 |
* 01 Addition, source1 + source2 |
|
2682 |
* 02 Subtraction, source1 - source2 |
|
2683 |
* 03 Unsigned multiplication, source1 * source2 (both unsigned) |
|
2684 |
* 04 Signed multiplication, source1 * source2 (both signed) |
|
2685 |
* 05 Unsigned bit shift, source1 by source2 (source2 taken to be a |
|
2686 |
* signed quantity; left shift if positive and right shift if |
|
2687 |
* negative, source1 is unsigned) |
|
2688 |
* 06 Signed bit shift, source1 by source2 |
|
2689 |
* (source2 like in 05, and source1 as well) |
|
2690 |
*/ |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2691 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2692 |
byte target; |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2693 |
byte oper; |
2345 | 2694 |
uint32 src1; |
2695 |
uint32 src2; |
|
2696 |
uint32 data = 0; |
|
2697 |
uint32 res; |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2698 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2699 |
check_length(len, 5, "ParamSet"); |
418
67457dd7e5bc
(svn r615) Fix the same bug in ParamSet action loading, pointer out by Bjarni too. (pasky)
bjarni
parents:
416
diff
changeset
|
2700 |
buf++; |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2701 |
target = grf_load_byte(&buf); |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2702 |
oper = grf_load_byte(&buf); |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2703 |
src1 = grf_load_byte(&buf); |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2704 |
src2 = grf_load_byte(&buf); |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2705 |
|
2345 | 2706 |
if (len >= 8) data = grf_load_dword(&buf); |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
2707 |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2708 |
/* You can add 80 to the operation to make it apply only if the target |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2709 |
* is not defined yet. In this respect, a parameter is taken to be |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2710 |
* defined if any of the following applies: |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2711 |
* - it has been set to any value in the newgrf(w).cfg parameter list |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2712 |
* - it OR A PARAMETER WITH HIGHER NUMBER has been set to any value by |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2713 |
* an earlier action D */ |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2714 |
if (oper & 0x80) { |
3807
927ac7827a28
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
2715 |
if (target < 0x80 && target < _cur_grffile->param_end) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2716 |
grfmsg(7, "Param %u already defined, skipping", target); |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2717 |
return; |
3807
927ac7827a28
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
2718 |
} |
927ac7827a28
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
2719 |
|
927ac7827a28
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
2720 |
oper &= 0x7F; |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2721 |
} |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2722 |
|
3808
332b9b202afb
(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
|
2723 |
if (src2 == 0xFE) { |
332b9b202afb
(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
|
2724 |
if (GB(data, 0, 8) == 0xFF) { |
332b9b202afb
(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
|
2725 |
if (data == 0x0000FFFF) { |
332b9b202afb
(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
|
2726 |
/* Patch variables */ |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2727 |
grfmsg(2, "ParamSet: Reading Patch variables unsupported"); |
3808
332b9b202afb
(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
|
2728 |
return; |
332b9b202afb
(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
|
2729 |
} else { |
332b9b202afb
(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
|
2730 |
/* GRF Resource Management */ |
5225
52ddcedcc6f7
(svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents:
5211
diff
changeset
|
2731 |
if (_cur_stage != GLS_ACTIVATION) { |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2732 |
/* Ignore GRM during initialization */ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2733 |
src1 = 0; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2734 |
} else { |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2735 |
uint8 op = src1; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2736 |
uint8 feature = GB(data, 8, 8); |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2737 |
uint16 count = GB(data, 16, 16); |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2738 |
|
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2739 |
switch (feature) { |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2740 |
case 0x00: /* Trains */ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2741 |
case 0x01: /* Road Vehicles */ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2742 |
case 0x02: /* Ships */ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2743 |
case 0x03: /* Aircraft */ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2744 |
{ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2745 |
uint start = 0; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2746 |
uint size = 0; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2747 |
uint shift = _vehshifts[feature]; |
4964
0ef1eb7e7f35
(svn r6963) - Fix (r6960): signed/unsigned complaints from MSVC
peter1138
parents:
4961
diff
changeset
|
2748 |
int i; |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2749 |
|
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2750 |
if (op == 6) { |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2751 |
/* Return GRFID of set that reserved ID */ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2752 |
src1 = _grm_engines[shift + _cur_grffile->param[target]]; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2753 |
break; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2754 |
} |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2755 |
|
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2756 |
/* With an operation of 2 or 3, we want to reserve a specific block of IDs */ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2757 |
if (op == 2 || op == 3) start = _cur_grffile->param[target]; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2758 |
|
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2759 |
for (i = start; i < _vehcounts[feature]; i++) { |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2760 |
if (_grm_engines[shift + i] == 0) { |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2761 |
size++; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2762 |
} else { |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2763 |
if (op == 2 || op == 3) break; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2764 |
start = i + 1; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2765 |
size = 0; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2766 |
} |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2767 |
|
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2768 |
if (size == count) break; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2769 |
} |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2770 |
|
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2771 |
if (size == count) { |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2772 |
/* Got the slot... */ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2773 |
if (op == 0 || op == 3) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2774 |
grfmsg(2, "GRM: Reserving %d vehicles at %d", count, start); |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2775 |
for (i = 0; i < count; i++) _grm_engines[shift + start + i] = _cur_grffile->grfid; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2776 |
} |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2777 |
src1 = start; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2778 |
} else { |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2779 |
/* Unable to allocate */ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2780 |
if (op != 4 && op != 5) { |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2781 |
/* Deactivate GRF */ |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2782 |
grfmsg(0, "GRM: Unable to allocate %d vehicles, deactivating", count); |
5234
91b7def5e4b2
(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
|
2783 |
SETBIT(_cur_grfconfig->flags, GCF_DISABLED); |
91b7def5e4b2
(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
|
2784 |
CLRBIT(_cur_grfconfig->flags, GCF_ACTIVATED); |
5011
23f0b424a1be
(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
|
2785 |
|
23f0b424a1be
(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
|
2786 |
_skip_sprites = -1; |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2787 |
return; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2788 |
} |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2789 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2790 |
grfmsg(1, "GRM: Unable to allocate %d vehicles", count); |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
2791 |
src1 = UINT_MAX; |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2792 |
} |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2793 |
break; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2794 |
} |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2795 |
|
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2796 |
case 0x08: /* General sprites */ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2797 |
switch (op) { |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2798 |
case 0: |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2799 |
/* 'Reserve' space at the current sprite ID */ |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2800 |
src1 = _cur_spriteid; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2801 |
_cur_spriteid += count; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2802 |
break; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2803 |
|
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2804 |
case 1: |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2805 |
src1 = _cur_spriteid; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2806 |
break; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2807 |
|
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2808 |
default: |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2809 |
grfmsg(1, "GRM: Unsupported operation %d for general sprites", op); |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2810 |
return; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2811 |
} |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2812 |
break; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2813 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2814 |
default: grfmsg(1, "GRM: Unsupported feature 0x%X", feature); return; |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2815 |
} |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
2816 |
} |
3808
332b9b202afb
(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
|
2817 |
} |
332b9b202afb
(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
|
2818 |
} else { |
332b9b202afb
(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
|
2819 |
/* Read another GRF File's parameter */ |
332b9b202afb
(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
|
2820 |
const GRFFile *file = GetFileByGRFID(data); |
332b9b202afb
(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
|
2821 |
if (file == NULL || src1 >= file->param_end) { |
332b9b202afb
(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
|
2822 |
src1 = 0; |
332b9b202afb
(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
|
2823 |
} else { |
332b9b202afb
(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
|
2824 |
src1 = file->param[src1]; |
332b9b202afb
(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
|
2825 |
} |
332b9b202afb
(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
|
2826 |
} |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2827 |
} else { |
3808
332b9b202afb
(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
|
2828 |
/* The source1 and source2 operands refer to the grf parameter number |
332b9b202afb
(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
|
2829 |
* like in action 6 and 7. In addition, they can refer to the special |
332b9b202afb
(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
|
2830 |
* variables available in action 7, or they can be FF to use the value |
332b9b202afb
(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
|
2831 |
* of <data>. If referring to parameters that are undefined, a value |
332b9b202afb
(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
|
2832 |
* of 0 is used instead. */ |
3811
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2833 |
src1 = (src1 == 0xFF) ? data : GetParamVal(src1, NULL); |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
2834 |
src2 = (src2 == 0xFF) ? data : GetParamVal(src2, NULL); |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2835 |
} |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2836 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2837 |
/* TODO: You can access the parameters of another GRF file by using |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2838 |
* source2=FE, source1=the other GRF's parameter number and data=GRF |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2839 |
* ID. This is only valid with operation 00 (set). If the GRF ID |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2840 |
* cannot be found, a value of 0 is used for the parameter value |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2841 |
* instead. */ |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2842 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2843 |
switch (oper) { |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2844 |
case 0x00: |
2345 | 2845 |
res = src1; |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2846 |
break; |
2345 | 2847 |
|
2848 |
case 0x01: |
|
2849 |
res = src1 + src2; |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2850 |
break; |
2345 | 2851 |
|
2852 |
case 0x02: |
|
2853 |
res = src1 - src2; |
|
2854 |
break; |
|
2855 |
||
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2856 |
case 0x03: |
2345 | 2857 |
res = src1 * src2; |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2858 |
break; |
2345 | 2859 |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2860 |
case 0x04: |
2345 | 2861 |
res = (int32)src1 * (int32)src2; |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2862 |
break; |
2345 | 2863 |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2864 |
case 0x05: |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2865 |
if ((int32)src2 < 0) { |
2345 | 2866 |
res = src1 >> -(int32)src2; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2867 |
} else { |
2345 | 2868 |
res = src1 << src2; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2869 |
} |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2870 |
break; |
2345 | 2871 |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2872 |
case 0x06: |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2873 |
if ((int32)src2 < 0) { |
2345 | 2874 |
res = (int32)src1 >> -(int32)src2; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2875 |
} else { |
2345 | 2876 |
res = (int32)src1 << src2; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
2877 |
} |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2878 |
break; |
2345 | 2879 |
|
2442
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2880 |
case 0x07: /* Bitwise AND */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2881 |
res = src1 & src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2882 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2883 |
|
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2884 |
case 0x08: /* Bitwise OR */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2885 |
res = src1 | src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2886 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2887 |
|
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2888 |
case 0x09: /* Unsigned division */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2889 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2890 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2891 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2892 |
res = src1 / src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2893 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2894 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2895 |
|
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2896 |
case 0x0A: /* Signed divison */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2897 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2898 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2899 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2900 |
res = (int32)src1 / (int32)src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2901 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2902 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2903 |
|
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2904 |
case 0x0B: /* Unsigned modulo */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2905 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2906 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2907 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2908 |
res = src1 % src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2909 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2910 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2911 |
|
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2912 |
case 0x0C: /* Signed modulo */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2913 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2914 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2915 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2916 |
res = (int32)src1 % (int32)src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2917 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2918 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2919 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2920 |
default: grfmsg(0, "ParamSet: Unknown operation %d, skipping", oper); return; |
2345 | 2921 |
} |
2922 |
||
2923 |
switch (target) { |
|
2924 |
case 0x8E: // Y-Offset for train sprites |
|
2925 |
_traininfo_vehicle_pitch = res; |
|
2926 |
break; |
|
2927 |
||
2928 |
// TODO implement |
|
2929 |
case 0x8F: // Rail track type cost factors |
|
2930 |
case 0x93: // Tile refresh offset to left |
|
2931 |
case 0x94: // Tile refresh offset to right |
|
2932 |
case 0x95: // Tile refresh offset upwards |
|
2933 |
case 0x96: // Tile refresh offset downwards |
|
2934 |
case 0x97: // Snow line height |
|
2935 |
case 0x99: // Global ID offset |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2936 |
grfmsg(7, "ParamSet: Skipping unimplemented target 0x%02X", target); |
2345 | 2937 |
break; |
2938 |
||
3814
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2939 |
case 0x9E: /* Miscellaneous GRF features */ |
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2940 |
_misc_grf_features = res; |
3845
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
2941 |
/* Set train list engine width */ |
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
2942 |
_traininfo_vehicle_width = HASBIT(res, 3) ? 32 : 29; |
3814
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2943 |
break; |
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
2944 |
|
2345 | 2945 |
default: |
2946 |
if (target < 0x80) { |
|
2947 |
_cur_grffile->param[target] = res; |
|
2948 |
if (target + 1U > _cur_grffile->param_end) _cur_grffile->param_end = target + 1; |
|
2949 |
} else { |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2950 |
grfmsg(7, "ParamSet: Skipping unknown target 0x%02X", target); |
2345 | 2951 |
} |
2952 |
break; |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
2953 |
} |
0 | 2954 |
} |
2955 |
||
5648
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2956 |
/* Action 0x0E (GLS_SAFETYSCAN) */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2957 |
static void SafeGRFInhibit(byte *buf, int len) |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2958 |
{ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2959 |
/* <0E> <num> <grfids...> |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2960 |
* |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2961 |
* B num Number of GRFIDs that follow |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2962 |
* D grfids GRFIDs of the files to deactivate */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2963 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2964 |
byte num; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2965 |
int i; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2966 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2967 |
check_length(len, 1, "GRFInhibit"); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2968 |
buf++, len--; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2969 |
num = grf_load_byte(&buf); len--; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2970 |
check_length(len, 4 * num, "GRFInhibit"); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2971 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2972 |
for (i = 0; i < num; i++) { |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2973 |
uint32 grfid = grf_load_dword(&buf); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2974 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2975 |
/* GRF is unsafe it if tries to deactivate other GRFs */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2976 |
if (grfid != _cur_grfconfig->grfid) { |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2977 |
SETBIT(_cur_grfconfig->flags, GCF_UNSAFE); |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2978 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2979 |
/* Skip remainder of GRF */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2980 |
_skip_sprites = -1; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2981 |
|
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2982 |
return; |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2983 |
} |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2984 |
} |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2985 |
} |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
2986 |
|
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2987 |
/* Action 0x0E */ |
0 | 2988 |
static void GRFInhibit(byte *buf, int len) |
2989 |
{ |
|
2990 |
/* <0E> <num> <grfids...> |
|
2991 |
* |
|
2992 |
* B num Number of GRFIDs that follow |
|
2993 |
* D grfids GRFIDs of the files to deactivate */ |
|
367
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
2994 |
|
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
2995 |
byte num; |
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
2996 |
int i; |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
2997 |
|
367
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
2998 |
check_length(len, 1, "GRFInhibit"); |
416
810c6de8eeed
(svn r613) Fix bug in GRFInhibit action loading, pointed out by Bjarni. (pasky)
bjarni
parents:
413
diff
changeset
|
2999 |
buf++, len--; |
367
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
3000 |
num = grf_load_byte(&buf); len--; |
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
3001 |
check_length(len, 4 * num, "GRFInhibit"); |
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
3002 |
|
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
3003 |
for (i = 0; i < num; i++) { |
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
3004 |
uint32 grfid = grf_load_dword(&buf); |
5333
8e7d68b06399
(svn r7495) -Fix (r7354): [NewGRF] Deactivate the target GRF, not the current GRF.
peter1138
parents:
5329
diff
changeset
|
3005 |
GRFConfig *file = GetGRFConfig(grfid); |
367
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
3006 |
|
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
3007 |
/* Unset activation flag */ |
5557
dc2402eb851b
(svn r7554) -Fix (r7496): In Action 0xE, don't deactivate the current GRF (to be ported to 0.5)
peter1138
parents:
5340
diff
changeset
|
3008 |
if (file != NULL && file != _cur_grfconfig) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3009 |
grfmsg(2, "GRFInhibit: Deactivating file '%s'", file->filename); |
5333
8e7d68b06399
(svn r7495) -Fix (r7354): [NewGRF] Deactivate the target GRF, not the current GRF.
peter1138
parents:
5329
diff
changeset
|
3010 |
SETBIT(file->flags, GCF_DISABLED); |
8e7d68b06399
(svn r7495) -Fix (r7354): [NewGRF] Deactivate the target GRF, not the current GRF.
peter1138
parents:
5329
diff
changeset
|
3011 |
CLRBIT(file->flags, GCF_ACTIVATED); |
367
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
3012 |
} |
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
3013 |
} |
0 | 3014 |
} |
3015 |
||
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
3016 |
/* Action 0x10 */ |
3561
29c95ab685c0
(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
|
3017 |
static void DefineGotoLabel(byte *buf, int len) |
29c95ab685c0
(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
|
3018 |
{ |
29c95ab685c0
(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
|
3019 |
/* <10> <label> [<comment>] |
29c95ab685c0
(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
|
3020 |
* |
29c95ab685c0
(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
|
3021 |
* B label The label to define |
29c95ab685c0
(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
|
3022 |
* V comment Optional comment - ignored */ |
29c95ab685c0
(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
|
3023 |
|
29c95ab685c0
(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
|
3024 |
GRFLabel *label; |
29c95ab685c0
(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
|
3025 |
|
3566
7bdf06a03960
(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
|
3026 |
check_length(len, 1, "DefineGotoLabel"); |
3561
29c95ab685c0
(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
|
3027 |
buf++; len--; |
29c95ab685c0
(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
|
3028 |
|
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
3029 |
MallocT(&label, 1); |
3561
29c95ab685c0
(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
|
3030 |
label->label = grf_load_byte(&buf); |
29c95ab685c0
(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
|
3031 |
label->nfo_line = _nfo_line; |
29c95ab685c0
(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
|
3032 |
label->pos = FioGetPos(); |
29c95ab685c0
(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
|
3033 |
label->next = NULL; |
29c95ab685c0
(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
|
3034 |
|
29c95ab685c0
(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
|
3035 |
/* Set up a linked list of goto targets which we will search in an Action 0x7/0x9 */ |
29c95ab685c0
(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
|
3036 |
if (_cur_grffile->label == NULL) { |
29c95ab685c0
(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
|
3037 |
_cur_grffile->label = label; |
29c95ab685c0
(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
|
3038 |
} else { |
29c95ab685c0
(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
|
3039 |
/* Attach the label to the end of the list */ |
29c95ab685c0
(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
|
3040 |
GRFLabel *l; |
29c95ab685c0
(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
|
3041 |
for (l = _cur_grffile->label; l->next != NULL; l = l->next); |
29c95ab685c0
(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
|
3042 |
l->next = label; |
29c95ab685c0
(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
|
3043 |
} |
29c95ab685c0
(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
|
3044 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3045 |
grfmsg(2, "DefineGotoLabel: GOTO target with label 0x%02X", label->label); |
3561
29c95ab685c0
(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
|
3046 |
} |
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
3047 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3048 |
/* Action 0x11 */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3049 |
static void GRFSound(byte *buf, int len) |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3050 |
{ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3051 |
/* <11> <num> |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3052 |
* |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3053 |
* W num Number of sound files that follow */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3054 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3055 |
uint16 num; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3056 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3057 |
check_length(len, 1, "GRFSound"); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3058 |
buf++; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3059 |
num = grf_load_word(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3060 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3061 |
_grf_data_blocks = num; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3062 |
_grf_data_type = GDT_SOUND; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3063 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3064 |
if (_cur_grffile->sound_offset == 0) _cur_grffile->sound_offset = GetNumSounds(); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3065 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3066 |
|
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3067 |
static void ImportGRFSound(byte *buf, int len) |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3068 |
{ |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3069 |
const GRFFile *file; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3070 |
FileEntry *se = AllocateFileEntry(); |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3071 |
uint32 grfid = grf_load_dword(&buf); |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3072 |
uint16 sound = grf_load_word(&buf); |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3073 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3074 |
file = GetFileByGRFID(grfid); |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3075 |
if (file == NULL || file->sound_offset == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3076 |
grfmsg(1, "ImportGRFSound: Source file not available"); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3077 |
return; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3078 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3079 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3080 |
if (file->sound_offset + sound >= GetNumSounds()) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3081 |
grfmsg(1, "ImportGRFSound: Sound effect %d is invalid", sound); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3082 |
return; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3083 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3084 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3085 |
grfmsg(2, "ImportGRFSound: Copying sound %d (%d) from file %X", sound, file->sound_offset + sound, grfid); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3086 |
|
5024
f13f2f2d43f9
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5011
diff
changeset
|
3087 |
*se = *GetSound(file->sound_offset + sound); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3088 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3089 |
/* Reset volume and priority, which TTDPatch doesn't copy */ |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3090 |
se->volume = 128; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3091 |
se->priority = 0; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3092 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3093 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3094 |
/* 'Action 0xFE' */ |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3095 |
static void GRFImportBlock(byte *buf, int len) |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3096 |
{ |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3097 |
if (_grf_data_blocks == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3098 |
grfmsg(2, "GRFImportBlock: Unexpected import block, skipping"); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3099 |
return; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3100 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3101 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3102 |
buf++; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3103 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3104 |
_grf_data_blocks--; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3105 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3106 |
/* XXX 'Action 0xFE' isn't really specified. It is only mentioned for |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3107 |
* importing sounds, so this is probably all wrong... */ |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3108 |
if (grf_load_byte(&buf) != _grf_data_type) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3109 |
grfmsg(1, "GRFImportBlock: Import type mismatch"); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3110 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3111 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3112 |
switch (_grf_data_type) { |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3113 |
case GDT_SOUND: ImportGRFSound(buf, len - 1); break; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3114 |
default: NOT_REACHED(); break; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3115 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3116 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3117 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3118 |
static void LoadGRFSound(byte *buf, int len) |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3119 |
{ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3120 |
byte *buf_start = buf; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3121 |
FileEntry *se; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3122 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3123 |
/* Allocate a sound entry. This is done even if the data is not loaded |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3124 |
* so that the indices used elsewhere are still correct. */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3125 |
se = AllocateFileEntry(); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3126 |
|
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
3127 |
if (grf_load_dword(&buf) != BSWAP32('RIFF')) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3128 |
grfmsg(1, "LoadGRFSound: Missing RIFF header"); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3129 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3130 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3131 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3132 |
/* Size of file -- we ignore this */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3133 |
grf_load_dword(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3134 |
|
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
3135 |
if (grf_load_dword(&buf) != BSWAP32('WAVE')) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3136 |
grfmsg(1, "LoadGRFSound: Invalid RIFF type"); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3137 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3138 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3139 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3140 |
for (;;) { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3141 |
uint32 tag = grf_load_dword(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3142 |
uint32 size = grf_load_dword(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3143 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3144 |
switch (tag) { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3145 |
case ' tmf': /* 'fmt ' */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3146 |
/* Audio format, must be 1 (PCM) */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3147 |
if (grf_load_word(&buf) != 1) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3148 |
grfmsg(1, "LoadGRFSound: Invalid audio format"); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3149 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3150 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3151 |
se->channels = grf_load_word(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3152 |
se->rate = grf_load_dword(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3153 |
grf_load_dword(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3154 |
grf_load_word(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3155 |
se->bits_per_sample = grf_load_word(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3156 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3157 |
/* Consume any extra bytes */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3158 |
for (; size > 16; size--) grf_load_byte(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3159 |
break; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3160 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3161 |
case 'atad': /* 'data' */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3162 |
se->file_size = size; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3163 |
se->file_offset = FioGetPos() - (len - (buf - buf_start)) + 1; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3164 |
se->file_offset |= _file_index << 24; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3165 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3166 |
/* Set default volume and priority */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3167 |
se->volume = 0x80; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3168 |
se->priority = 0; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3169 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3170 |
grfmsg(2, "LoadGRFSound: channels %u, sample rate %u, bits per sample %u, length %u", se->channels, se->rate, se->bits_per_sample, size); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3171 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3172 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3173 |
default: |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3174 |
se->file_size = 0; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3175 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3176 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3177 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3178 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3179 |
|
5108
dc67d70b5a45
(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
|
3180 |
/* Action 0x12 */ |
dc67d70b5a45
(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
|
3181 |
static void LoadFontGlyph(byte *buf, int len) |
dc67d70b5a45
(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
|
3182 |
{ |
dc67d70b5a45
(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
|
3183 |
/* <12> <num_def> <font_size> <num_char> <base_char> |
dc67d70b5a45
(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
|
3184 |
* |
dc67d70b5a45
(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
|
3185 |
* B num_def Number of definitions |
dc67d70b5a45
(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
|
3186 |
* B font_size Size of font (0 = normal, 1 = small, 2 = large) |
dc67d70b5a45
(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
|
3187 |
* B num_char Number of consecutive glyphs |
dc67d70b5a45
(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
|
3188 |
* W base_char First character index */ |
dc67d70b5a45
(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
|
3189 |
|
dc67d70b5a45
(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
|
3190 |
uint8 num_def; |
dc67d70b5a45
(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
|
3191 |
uint i; |
dc67d70b5a45
(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
|
3192 |
|
dc67d70b5a45
(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
|
3193 |
buf++; len--; |
dc67d70b5a45
(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
|
3194 |
check_length(len, 1, "LoadFontGlyph"); |
dc67d70b5a45
(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
|
3195 |
|
dc67d70b5a45
(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
|
3196 |
num_def = grf_load_byte(&buf); |
dc67d70b5a45
(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
|
3197 |
|
dc67d70b5a45
(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
|
3198 |
check_length(len, 1 + num_def * 4, "LoadFontGlyph"); |
dc67d70b5a45
(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
|
3199 |
|
dc67d70b5a45
(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
|
3200 |
for (i = 0; i < num_def; i++) { |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
3201 |
FontSize size = (FontSize)grf_load_byte(&buf); |
5108
dc67d70b5a45
(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
|
3202 |
uint8 num_char = grf_load_byte(&buf); |
dc67d70b5a45
(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
|
3203 |
uint16 base_char = grf_load_word(&buf); |
dc67d70b5a45
(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
|
3204 |
uint c; |
dc67d70b5a45
(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
|
3205 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3206 |
grfmsg(7, "LoadFontGlyph: Loading %u glyph(s) at 0x%04X for size %u", num_char, base_char, size); |
5108
dc67d70b5a45
(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
|
3207 |
|
dc67d70b5a45
(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
|
3208 |
for (c = 0; c < num_char; c++) { |
dc67d70b5a45
(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
|
3209 |
SetUnicodeGlyph(size, base_char + c, _cur_spriteid); |
dc67d70b5a45
(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
|
3210 |
LoadNextSprite(_cur_spriteid++, _file_index); |
dc67d70b5a45
(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
|
3211 |
_nfo_line++; |
dc67d70b5a45
(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
|
3212 |
} |
dc67d70b5a45
(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
|
3213 |
} |
dc67d70b5a45
(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
|
3214 |
} |
dc67d70b5a45
(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
|
3215 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3216 |
/* 'Action 0xFF' */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3217 |
static void GRFDataBlock(byte *buf, int len) |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3218 |
{ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3219 |
byte name_len; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3220 |
const char *name; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3221 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3222 |
if (_grf_data_blocks == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3223 |
grfmsg(2, "GRFDataBlock: unexpected data block, skipping"); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3224 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3225 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3226 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3227 |
buf++; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3228 |
name_len = grf_load_byte(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3229 |
name = (const char *)buf; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3230 |
buf += name_len + 1; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3231 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3232 |
grfmsg(2, "GRFDataBlock: block name '%s'...", name); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3233 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3234 |
_grf_data_blocks--; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3235 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3236 |
switch (_grf_data_type) { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3237 |
case GDT_SOUND: LoadGRFSound(buf, len - name_len - 2); break; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3238 |
default: NOT_REACHED(); break; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3239 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3240 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3241 |
|
5329
2b117d8652f0
(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
|
3242 |
|
2b117d8652f0
(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
|
3243 |
/* Used during safety scan on unsafe actions */ |
2b117d8652f0
(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
|
3244 |
static void GRFUnsafe(byte *buf, int len) |
2b117d8652f0
(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
|
3245 |
{ |
2b117d8652f0
(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
|
3246 |
SETBIT(_cur_grfconfig->flags, GCF_UNSAFE); |
2b117d8652f0
(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
|
3247 |
|
5648
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
3248 |
/* Skip remainder of GRF */ |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
3249 |
_skip_sprites = -1; |
5329
2b117d8652f0
(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
|
3250 |
} |
2b117d8652f0
(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
|
3251 |
|
2b117d8652f0
(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
|
3252 |
|
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
3253 |
static void InitializeGRFSpecial(void) |
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
3254 |
{ |
4381
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3255 |
_ttdpatch_flags[0] = ((_patches.always_small_airport ? 1 : 0) << 0x0C) // keepsmallairport |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3256 |
| (1 << 0x0D) // newairports |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3257 |
| (1 << 0x0E) // largestations |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3258 |
| ((_patches.longbridges ? 1 : 0) << 0x0F) // longbridges |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3259 |
| (0 << 0x10) // loadtime |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3260 |
| (1 << 0x12) // presignals |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3261 |
| (1 << 0x13) // extpresignals |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3262 |
| ((_patches.never_expire_vehicles ? 1 : 0) << 0x16) // enginespersist |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3263 |
| (1 << 0x1B) // multihead |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3264 |
| (1 << 0x1D) // lowmemory |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3265 |
| (1 << 0x1E); // generalfixes |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3266 |
|
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3267 |
_ttdpatch_flags[1] = (0 << 0x07) // moreairports - based on units of noise |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3268 |
| ((_patches.mammoth_trains ? 1 : 0) << 0x08) // mammothtrains |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3269 |
| (1 << 0x09) // trainrefit |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3270 |
| (0 << 0x0B) // subsidiaries |
5648
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
3271 |
| ((_patches.gradual_loading ? 1 : 0) << 0x0C) // gradualloading |
4381
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3272 |
| (1 << 0x12) // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3273 |
| (1 << 0x13) // unifiedmaglevmode - set bit 1 mode |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3274 |
| (1 << 0x14) // bridgespeedlimits |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3275 |
| (1 << 0x16) // eternalgame |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3276 |
| (1 << 0x17) // newtrains |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3277 |
| (1 << 0x18) // newrvs |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3278 |
| (1 << 0x19) // newships |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3279 |
| (1 << 0x1A) // newplanes |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3280 |
| ((_patches.signal_side ? 1 : 0) << 0x1B) // signalsontrafficside |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3281 |
| (1 << 0x1C); // electrifiedrailway |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3282 |
|
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3283 |
_ttdpatch_flags[2] = (1 << 0x01) // loadallgraphics - obsolote |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3284 |
| (1 << 0x03) // semaphores |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3285 |
| (0 << 0x0B) // enhancedgui |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3286 |
| (0 << 0x0C) // newagerating |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3287 |
| ((_patches.build_on_slopes ? 1 : 0) << 0x0D) // buildonslopes |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3288 |
| (0 << 0x0F) // planespeed |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3289 |
| (0 << 0x10) // moreindustriesperclimate - obsolete |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3290 |
| (0 << 0x11) // moretoylandfeatures |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3291 |
| (1 << 0x12) // newstations |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3292 |
| (0 << 0x13) // tracktypecostdiff |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3293 |
| (0 << 0x14) // manualconvert |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3294 |
| ((_patches.build_on_slopes ? 1 : 0) << 0x15) // buildoncoasts |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3295 |
| (1 << 0x16) // canals |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3296 |
| (1 << 0x17) // newstartyear |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3297 |
| (0 << 0x18) // freighttrains |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3298 |
| (0 << 0x19) // newhouses |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3299 |
| (1 << 0x1A) // newbridges |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3300 |
| (0 << 0x1B) // newtownnames |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3301 |
| (0 << 0x1C) // moreanimations |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3302 |
| ((_patches.wagon_speed_limits ? 1 : 0) << 0x1D) // wagonspeedlimits |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3303 |
| (1 << 0x1E) // newshistory |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3304 |
| (0 << 0x1F); // custombridgeheads |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3305 |
|
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3306 |
_ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3307 |
| (1 << 0x01) // windowsnap |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3308 |
| (0 << 0x02) // townbuildnoroad |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3309 |
| (0 << 0x03) // pathbasedsignalling. To enable if ever pbs is back |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3310 |
| (0 << 0x04) // aichoosechance |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3311 |
| (1 << 0x05) // resolutionwidth |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3312 |
| (1 << 0x06) // resolutionheight |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3313 |
| (0 << 0x07) // newindustries |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3314 |
| (0 << 0x08) // fifoloading |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3315 |
| (0 << 0x09) // townroadbranchprob |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3316 |
| (0 << 0x0A) // tempsnowline |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3317 |
| (0 << 0x0B) // newcargo |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3318 |
| (1 << 0x0C) // enhancemultiplayer |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3319 |
| (1 << 0x0D) // onewayroads |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3320 |
| ((_patches.nonuniform_stations ? 1 : 0) << 0x0E) // irregularstations |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3321 |
| (1 << 0x0F) // statistics |
4657
188335e8d316
(svn r6533) - Fix (r6532): Somebody forgot to add newsounds to the ttdpatch flags...
peter1138
parents:
4656
diff
changeset
|
3322 |
| (1 << 0x10) // newsounds |
4381
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3323 |
| (1 << 0x11) // autoreplace |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3324 |
| (1 << 0x12) // autoslope |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3325 |
| (0 << 0x13) // followvehicle |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3326 |
| (0 << 0x14) // trams |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3327 |
| (0 << 0x15) // enhancetunnels |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3328 |
| (0 << 0x16) // shortrvs |
c1af6c934040
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
belugas
parents:
4377
diff
changeset
|
3329 |
| (0 << 0x17); // articulatedrvs |
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
3330 |
} |
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
3331 |
|
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3332 |
static void ResetCustomStations(void) |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3333 |
{ |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3334 |
StationSpec *statspec; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3335 |
GRFFile *file; |
2627
8c964f74bd7b
(svn r3169) Little bit of coding style fixing, and change from value to lengthof()
peter1138
parents:
2625
diff
changeset
|
3336 |
uint i; |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3337 |
uint t; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3338 |
|
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3339 |
for (file = _first_grffile; file != NULL; file = file->next) { |
3768
46d328178509
(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
|
3340 |
if (file->stations == NULL) continue; |
46d328178509
(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
|
3341 |
for (i = 0; i < MAX_STATIONS; i++) { |
46d328178509
(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
|
3342 |
if (file->stations[i] == NULL) continue; |
46d328178509
(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
|
3343 |
statspec = file->stations[i]; |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3344 |
|
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3345 |
/* Release renderdata, if it wasn't copied from another custom station spec */ |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3346 |
if (!statspec->copied_renderdata) { |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3347 |
for (t = 0; t < statspec->tiles; t++) { |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3348 |
free((void*)statspec->renderdata[t].seq); |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3349 |
} |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3350 |
free(statspec->renderdata); |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3351 |
} |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
3352 |
|
5061
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3353 |
/* Release platforms and layouts */ |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3354 |
if (!statspec->copied_layouts) { |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3355 |
uint l, p; |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3356 |
for (l = 0; l < statspec->lengths; l++) { |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3357 |
for (p = 0; p < statspec->platforms[l]; p++) { |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3358 |
free(statspec->layouts[l][p]); |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3359 |
} |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3360 |
free(statspec->layouts[l]); |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3361 |
} |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3362 |
free(statspec->layouts); |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3363 |
free(statspec->platforms); |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
3364 |
} |
3768
46d328178509
(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
|
3365 |
|
46d328178509
(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
|
3366 |
/* Release this station */ |
46d328178509
(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
|
3367 |
free(statspec); |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3368 |
} |
3501
cf7d2c33e7fc
(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
|
3369 |
|
cf7d2c33e7fc
(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
|
3370 |
/* Free and reset the station data */ |
cf7d2c33e7fc
(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
|
3371 |
free(file->stations); |
cf7d2c33e7fc
(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
|
3372 |
file->stations = NULL; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3373 |
} |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3374 |
} |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3375 |
|
4953
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3376 |
static void ResetNewGRF(void) |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3377 |
{ |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3378 |
GRFFile *f, *next; |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3379 |
|
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3380 |
for (f = _first_grffile; f != NULL; f = next) { |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3381 |
next = f->next; |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3382 |
|
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3383 |
free(f->filename); |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3384 |
free(f); |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3385 |
} |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3386 |
|
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3387 |
_first_grffile = NULL; |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3388 |
_cur_grffile = NULL; |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3389 |
} |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3390 |
|
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
3391 |
/** |
2463
de2605ed3758
(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
|
3392 |
* Reset all NewGRF loaded data |
de2605ed3758
(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
|
3393 |
* TODO |
de2605ed3758
(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
|
3394 |
*/ |
de2605ed3758
(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
|
3395 |
static void ResetNewGRFData(void) |
de2605ed3758
(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
|
3396 |
{ |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3397 |
uint i; |
2478
16b05f1de6bb
(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
|
3398 |
|
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3399 |
CleanUpStrings(); |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3400 |
|
2463
de2605ed3758
(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
|
3401 |
// Copy/reset original engine info data |
de2605ed3758
(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
|
3402 |
memcpy(&_engine_info, &orig_engine_info, sizeof(orig_engine_info)); |
de2605ed3758
(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
|
3403 |
memcpy(&_rail_vehicle_info, &orig_rail_vehicle_info, sizeof(orig_rail_vehicle_info)); |
de2605ed3758
(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
|
3404 |
memcpy(&_ship_vehicle_info, &orig_ship_vehicle_info, sizeof(orig_ship_vehicle_info)); |
de2605ed3758
(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
|
3405 |
memcpy(&_aircraft_vehicle_info, &orig_aircraft_vehicle_info, sizeof(orig_aircraft_vehicle_info)); |
de2605ed3758
(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
|
3406 |
memcpy(&_road_vehicle_info, &orig_road_vehicle_info, sizeof(orig_road_vehicle_info)); |
2478
16b05f1de6bb
(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
|
3407 |
|
16b05f1de6bb
(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
|
3408 |
// Copy/reset original bridge info data |
16b05f1de6bb
(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
|
3409 |
// First, free sprite table data |
16b05f1de6bb
(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
|
3410 |
for (i = 0; i < MAX_BRIDGES; i++) { |
16b05f1de6bb
(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
|
3411 |
if (_bridge[i].sprite_table != NULL) { |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3412 |
uint j; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3413 |
|
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3414 |
for (j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]); |
2478
16b05f1de6bb
(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
|
3415 |
free(_bridge[i].sprite_table); |
16b05f1de6bb
(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
|
3416 |
} |
16b05f1de6bb
(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
|
3417 |
} |
16b05f1de6bb
(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
|
3418 |
memcpy(&_bridge, &orig_bridge, sizeof(_bridge)); |
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
3419 |
|
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3420 |
// Reset refit/cargo class data |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3421 |
memset(&cargo_allowed, 0, sizeof(cargo_allowed)); |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3422 |
memset(&cargo_disallowed, 0, sizeof(cargo_disallowed)); |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3423 |
|
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3424 |
// Reset GRM reservations |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3425 |
memset(&_grm_engines, 0, sizeof(_grm_engines)); |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
3426 |
|
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
3427 |
// Unload sprite group data |
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
3428 |
UnloadWagonOverrides(); |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
3429 |
UnloadRotorOverrideSprites(); |
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
3430 |
UnloadCustomEngineSprites(); |
2769
acea0abd2195
(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
|
3431 |
UnloadCustomEngineNames(); |
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
3432 |
ResetEngineListOrder(); |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
3433 |
|
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
3434 |
// Reset price base data |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
3435 |
ResetPriceBaseMultipliers(); |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3436 |
|
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
3437 |
/* Reset the curencies array */ |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
3438 |
ResetCurrencies(); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
3439 |
|
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3440 |
// Reset station classes |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3441 |
ResetStationClasses(); |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
3442 |
ResetCustomStations(); |
2812
f250489941f9
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
3443 |
|
4953
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3444 |
/* Reset NewGRF files */ |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3445 |
ResetNewGRF(); |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
3446 |
|
2812
f250489941f9
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
3447 |
// Add engine type to engine data. This is needed for the refit precalculation. |
f250489941f9
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
3448 |
AddTypeToEngines(); |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3449 |
|
3845
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
3450 |
/* Reset misc GRF features and train list display variables */ |
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
3451 |
_misc_grf_features = 0; |
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
3452 |
_traininfo_vehicle_pitch = 0; |
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
3453 |
_traininfo_vehicle_width = 29; |
4742
d5a2d3da5002
(svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents:
4711
diff
changeset
|
3454 |
_have_2cc = false; |
5209
fa3ad39e2fa7
(svn r7324) -Codechange: reset newgrf signal location data
peter1138
parents:
5161
diff
changeset
|
3455 |
_signal_base = 0; |
5210
dc52acfad05c
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
5209
diff
changeset
|
3456 |
_coast_base = 0; |
3845
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
3457 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3458 |
InitializeSoundPool(); |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3459 |
InitializeSpriteGroupPool(); |
2463
de2605ed3758
(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
|
3460 |
} |
de2605ed3758
(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
|
3461 |
|
3561
29c95ab685c0
(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
|
3462 |
/** Reset all NewGRFData that was used only while processing data */ |
29c95ab685c0
(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
|
3463 |
static void ClearTemporaryNewGRFData(void) |
29c95ab685c0
(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
|
3464 |
{ |
29c95ab685c0
(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
|
3465 |
/* Clear the GOTO labels used for GRF processing */ |
29c95ab685c0
(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
|
3466 |
GRFLabel *l; |
29c95ab685c0
(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
|
3467 |
for (l = _cur_grffile->label; l != NULL;) { |
29c95ab685c0
(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
|
3468 |
GRFLabel *l2 = l->next; |
29c95ab685c0
(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
|
3469 |
free(l); |
29c95ab685c0
(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
|
3470 |
l = l2; |
29c95ab685c0
(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
|
3471 |
} |
29c95ab685c0
(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
|
3472 |
_cur_grffile->label = NULL; |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3473 |
|
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3474 |
/* Clear the list of spritegroups */ |
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3475 |
free(_cur_grffile->spritegroups); |
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3476 |
_cur_grffile->spritegroups = NULL; |
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
3477 |
_cur_grffile->spritegroups_count = 0; |
3561
29c95ab685c0
(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
|
3478 |
} |
29c95ab685c0
(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
|
3479 |
|
3628
bd4a6601e5a2
(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
|
3480 |
static void InitNewGRFFile(const GRFConfig *config, int sprite_offset) |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
3481 |
{ |
1477 | 3482 |
GRFFile *newfile; |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3483 |
|
3628
bd4a6601e5a2
(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
|
3484 |
newfile = GetFileByFilename(config->filename); |
490
83455cd1cc55
(svn r772) Whoops, I know. Do not consider pointer to be a boolean value. Sorry 'bout that, sirs.
pasky
parents:
489
diff
changeset
|
3485 |
if (newfile != NULL) { |
489
9c8e1806935e
(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
|
3486 |
/* We already loaded it once. */ |
9c8e1806935e
(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
|
3487 |
newfile->sprite_offset = sprite_offset; |
9c8e1806935e
(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
|
3488 |
_cur_grffile = newfile; |
9c8e1806935e
(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
|
3489 |
return; |
9c8e1806935e
(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
|
3490 |
} |
9c8e1806935e
(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
|
3491 |
|
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
3492 |
CallocT(&newfile, 1); |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3493 |
|
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3494 |
if (newfile == NULL) error ("Out of memory"); |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3495 |
|
3628
bd4a6601e5a2
(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
|
3496 |
newfile->filename = strdup(config->filename); |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3497 |
newfile->sprite_offset = sprite_offset; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3498 |
|
3628
bd4a6601e5a2
(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
|
3499 |
/* Copy the initial parameter list */ |
bd4a6601e5a2
(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
|
3500 |
assert(lengthof(newfile->param) == lengthof(config->param) && lengthof(config->param) == 0x80); |
bd4a6601e5a2
(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
|
3501 |
newfile->param_end = config->num_params; |
5623
ef2a8a524a95
(svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents:
5588
diff
changeset
|
3502 |
memcpy(newfile->param, config->param, sizeof(newfile->param)); |
3628
bd4a6601e5a2
(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
|
3503 |
|
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3504 |
if (_first_grffile == NULL) { |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3505 |
_cur_grffile = newfile; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3506 |
_first_grffile = newfile; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3507 |
} else { |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3508 |
_cur_grffile->next = newfile; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3509 |
_cur_grffile = newfile; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3510 |
} |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3511 |
} |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3512 |
|
5037
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3513 |
|
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3514 |
/** Bitmasked values of what type of cargo is refittable for the given vehicle-type. |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3515 |
* This coupled with the landscape information (_landscape_global_cargo_mask) gives |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3516 |
* us exactly what is refittable and what is not */ |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3517 |
#define MC(cargo) (1 << cargo) |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3518 |
static const uint32 _default_refitmasks[NUM_VEHICLE_TYPES] = { |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3519 |
/* Trains */ |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3520 |
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) | |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3521 |
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) | |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3522 |
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), |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3523 |
/* Road vehicles (not refittable by default) */ |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3524 |
0, |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3525 |
/* Ships */ |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3526 |
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) | |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3527 |
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) | |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3528 |
MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS), |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3529 |
/* Aircraft */ |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3530 |
MC(GC_PASSENGERS) | MC(GC_MAIL) | MC(GC_GOODS) | MC(GC_VALUABLES) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_SUGAR) | MC(GC_TOYS) | |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3531 |
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), |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3532 |
/* Special/Disaster */ |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3533 |
0,0 |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3534 |
}; |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3535 |
#undef MC |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3536 |
|
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
3537 |
|
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3538 |
/** |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3539 |
* Precalculate refit masks from cargo classes for all vehicles. |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3540 |
*/ |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3541 |
static void CalculateRefitMasks(void) |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3542 |
{ |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3543 |
EngineID engine; |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3544 |
|
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3545 |
for (engine = 0; engine < TOTAL_NUM_ENGINES; engine++) { |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3546 |
uint32 mask = 0; |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3547 |
uint32 not_mask = 0; |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3548 |
uint32 xor_mask = _engine_info[engine].refit_mask; |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3549 |
byte i; |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3550 |
|
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3551 |
if (cargo_allowed[engine] != 0) { |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3552 |
// Build up the list of cargo types from the set cargo classes. |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3553 |
for (i = 0; i < lengthof(cargo_classes); i++) { |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3554 |
if (HASBIT(cargo_allowed[engine], i)) mask |= cargo_classes[i]; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3555 |
if (HASBIT(cargo_disallowed[engine], i)) not_mask |= cargo_classes[i]; |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3556 |
} |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3557 |
} else { |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3558 |
// Don't apply default refit mask to wagons or engines with no capacity |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3559 |
if (xor_mask == 0 && ( |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3560 |
GetEngine(engine)->type != VEH_Train || ( |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3561 |
RailVehInfo(engine)->capacity != 0 && |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3562 |
!(RailVehInfo(engine)->flags & RVI_WAGON) |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3563 |
) |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3564 |
)) { |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3565 |
xor_mask = _default_refitmasks[GetEngine(engine)->type - VEH_Train]; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
3566 |
} |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3567 |
} |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3568 |
_engine_info[engine].refit_mask = ((mask & ~not_mask) ^ xor_mask) & _landscape_global_cargo_mask[_opt.landscape]; |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3569 |
} |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3570 |
} |
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
3571 |
|
0 | 3572 |
/* Here we perform initial decoding of some special sprites (as are they |
3573 |
* described at http://www.ttdpatch.net/src/newgrf.txt, but this is only a very |
|
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
3574 |
* partial implementation yet). */ |
0 | 3575 |
/* XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by |
3576 |
* a crafted invalid GRF file. We should tell that to the user somehow, or |
|
3577 |
* better make this more robust in the future. */ |
|
5008
f95f0bd55c34
(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
|
3578 |
static void DecodeSpecialSprite(uint num, GrfLoadingStage stage) |
0 | 3579 |
{ |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
3580 |
/* XXX: There is a difference between staged loading in TTDPatch and |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
3581 |
* here. In TTDPatch, for some reason actions 1 and 2 are carried out |
3561
29c95ab685c0
(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
|
3582 |
* during stage 1, whilst action 3 is carried out during stage 2 (to |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
3583 |
* "resolve" cargo IDs... wtf). This is a little problem, because cargo |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
3584 |
* IDs are valid only within a given set (action 1) block, and may be |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
3585 |
* overwritten after action 3 associates them. But overwriting happens |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
3586 |
* in an earlier stage than associating, so... We just process actions |
3561
29c95ab685c0
(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
|
3587 |
* 1 and 2 in stage 2 now, let's hope that won't get us into problems. |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
3588 |
* --pasky */ |
3561
29c95ab685c0
(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
|
3589 |
/* We need a pre-stage to set up GOTO labels of Action 0x10 because the grf |
29c95ab685c0
(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
|
3590 |
* is not in memory and scanning the file every time would be too expensive. |
29c95ab685c0
(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
|
3591 |
* In other stages we skip action 0x10 since it's already dealt with. */ |
5008
f95f0bd55c34
(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
|
3592 |
static const SpecialSpriteHandler handlers[][GLS_END] = { |
5648
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
3593 |
/* 0x00 */ { NULL, SafeChangeInfo, NULL, NULL, FeatureChangeInfo, }, |
5329
2b117d8652f0
(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
|
3594 |
/* 0x01 */ { NULL, GRFUnsafe, NULL, NULL, NewSpriteSet, }, |
2b117d8652f0
(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
|
3595 |
/* 0x02 */ { NULL, GRFUnsafe, NULL, NULL, NewSpriteGroup, }, |
2b117d8652f0
(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
|
3596 |
/* 0x03 */ { NULL, GRFUnsafe, NULL, NULL, FeatureMapSpriteGroup, }, |
2b117d8652f0
(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
|
3597 |
/* 0x04 */ { NULL, NULL, NULL, NULL, FeatureNewName, }, |
2b117d8652f0
(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
|
3598 |
/* 0x05 */ { NULL, NULL, NULL, NULL, GraphicsNew, }, |
2b117d8652f0
(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
|
3599 |
/* 0x06 */ { NULL, NULL, NULL, CfgApply, CfgApply, }, |
2b117d8652f0
(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
|
3600 |
/* 0x07 */ { NULL, NULL, NULL, NULL, SkipIf, }, |
5648
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
3601 |
/* 0x08 */ { ScanInfo, NULL, NULL, GRFInfo, GRFInfo, }, |
5329
2b117d8652f0
(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
|
3602 |
/* 0x09 */ { NULL, NULL, NULL, SkipIf, SkipIf, }, |
2b117d8652f0
(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
|
3603 |
/* 0x0A */ { NULL, NULL, NULL, NULL, SpriteReplace, }, |
2b117d8652f0
(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
|
3604 |
/* 0x0B */ { NULL, NULL, NULL, GRFError, GRFError, }, |
2b117d8652f0
(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
|
3605 |
/* 0x0C */ { NULL, NULL, NULL, GRFComment, GRFComment, }, |
5648
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
3606 |
/* 0x0D */ { NULL, SafeParamSet, NULL, ParamSet, ParamSet, }, |
1608018c5ff2
(svn r8059) [cbh] - Sync with r7788:8032 from trunk
celestar
parents:
5645
diff
changeset
|
3607 |
/* 0x0E */ { NULL, SafeGRFInhibit, NULL, GRFInhibit, GRFInhibit, }, |
5329
2b117d8652f0
(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
|
3608 |
/* 0x0F */ { NULL, NULL, NULL, NULL, NULL, }, |
2b117d8652f0
(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
|
3609 |
/* 0x10 */ { NULL, NULL, DefineGotoLabel, NULL, NULL, }, |
2b117d8652f0
(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
|
3610 |
/* 0x11 */ { NULL, GRFUnsafe, NULL, NULL, GRFSound, }, |
2b117d8652f0
(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
|
3611 |
/* 0x12 */ { NULL, NULL, NULL, NULL, LoadFontGlyph, }, |
2342
c19fb4f2df30
(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
|
3612 |
}; |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
3613 |
|
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3614 |
byte* buf; |
2342
c19fb4f2df30
(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
|
3615 |
byte action; |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
3616 |
|
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3617 |
if (_preload_sprite == NULL) { |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3618 |
/* No preloaded sprite to work with; allocate and read the |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3619 |
* pseudo sprite content. */ |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
3620 |
MallocT(&buf, num); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3621 |
if (buf == NULL) error("DecodeSpecialSprite: Could not allocate memory"); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3622 |
FioReadBlock(buf, num); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3623 |
} else { |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3624 |
/* Use the preloaded sprite data. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3625 |
buf = _preload_sprite; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3626 |
_preload_sprite = NULL; |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3627 |
grfmsg(7, "DecodeSpecialSprite: Using preloaded pseudo sprite data"); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3628 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3629 |
/* Skip the real (original) content of this action. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3630 |
FioSeekTo(num, SEEK_CUR); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3631 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3632 |
|
2342
c19fb4f2df30
(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
|
3633 |
action = buf[0]; |
c19fb4f2df30
(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
|
3634 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3635 |
if (action == 0xFF) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3636 |
grfmsg(7, "Handling data block in stage %d", stage); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3637 |
GRFDataBlock(buf, num); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3638 |
} else if (action == 0xFE) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3639 |
grfmsg(7, "Handling import block in stage %d", stage); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
3640 |
GRFImportBlock(buf, num); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
3641 |
} else if (action >= lengthof(handlers)) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3642 |
grfmsg(7, "Skipping unknown action 0x%02X", action); |
5008
f95f0bd55c34
(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
|
3643 |
} else if (handlers[action][stage] == NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3644 |
grfmsg(7, "Skipping action 0x%02X in stage %d", action, stage); |
2645
964bd8fe3ce2
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
3645 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3646 |
grfmsg(7, "Handling action 0x%02X in stage %d", action, stage); |
5008
f95f0bd55c34
(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
|
3647 |
handlers[action][stage](buf, num); |
2342
c19fb4f2df30
(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
|
3648 |
} |
c19fb4f2df30
(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
|
3649 |
free(buf); |
c19fb4f2df30
(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
|
3650 |
} |
c19fb4f2df30
(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
|
3651 |
|
c19fb4f2df30
(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 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3653 |
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage) |
2342
c19fb4f2df30
(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
|
3654 |
{ |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3655 |
const char *filename = config->filename; |
2342
c19fb4f2df30
(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
|
3656 |
uint16 num; |
c19fb4f2df30
(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
|
3657 |
|
c19fb4f2df30
(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
|
3658 |
/* A .grf file is activated only if it was active when the game was |
c19fb4f2df30
(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
|
3659 |
* started. If a game is loaded, only its active .grfs will be |
c19fb4f2df30
(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
|
3660 |
* reactivated, unless "loadallgraphics on" is used. A .grf file is |
c19fb4f2df30
(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
|
3661 |
* considered active if its action 8 has been processed, i.e. its |
c19fb4f2df30
(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
|
3662 |
* action 8 hasn't been skipped using an action 7. |
c19fb4f2df30
(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
|
3663 |
* |
c19fb4f2df30
(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
|
3664 |
* During activation, only actions 0, 1, 2, 3, 4, 5, 7, 8, 9, 0A and 0B are |
c19fb4f2df30
(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
|
3665 |
* carried out. All others are ignored, because they only need to be |
c19fb4f2df30
(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
|
3666 |
* processed once at initialization. */ |
5329
2b117d8652f0
(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
|
3667 |
if (stage != GLS_FILESCAN && stage != GLS_SAFETYSCAN && stage != GLS_LABELSCAN) { |
2342
c19fb4f2df30
(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
|
3668 |
_cur_grffile = GetFileByFilename(filename); |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3669 |
if (_cur_grffile == NULL) error("File '%s' lost in cache.\n", filename); |
5234
91b7def5e4b2
(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
|
3670 |
if (stage == GLS_ACTIVATION && !HASBIT(config->flags, GCF_ACTIVATED)) return; |
2342
c19fb4f2df30
(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
|
3671 |
} |
c19fb4f2df30
(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
|
3672 |
|
c19fb4f2df30
(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 |
FioOpenFile(file_index, filename); |
c19fb4f2df30
(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 |
_file_index = file_index; // XXX |
c19fb4f2df30
(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
|
3675 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3676 |
_cur_grfconfig = config; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3677 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3678 |
DEBUG(grf, 2, "Reading NewGRF-file '%s'", filename); |
2342
c19fb4f2df30
(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
|
3679 |
|
c19fb4f2df30
(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
|
3680 |
/* Skip the first sprite; we don't care about how many sprites this |
c19fb4f2df30
(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
|
3681 |
* does contain; newest TTDPatches and George's longvehicles don't |
c19fb4f2df30
(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
|
3682 |
* neither, apparently. */ |
c19fb4f2df30
(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
|
3683 |
if (FioReadWord() == 4 && FioReadByte() == 0xFF) { |
c19fb4f2df30
(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
|
3684 |
FioReadDword(); |
c19fb4f2df30
(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
|
3685 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3686 |
DEBUG(grf, 7, "Custom .grf has invalid format"); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3687 |
return; |
2342
c19fb4f2df30
(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 |
} |
c19fb4f2df30
(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 |
|
c19fb4f2df30
(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 |
_skip_sprites = 0; // XXX |
3557
5d12a78ce141
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
3691 |
_nfo_line = 0; |
2342
c19fb4f2df30
(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 |
|
c19fb4f2df30
(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
|
3693 |
while ((num = FioReadWord()) != 0) { |
c19fb4f2df30
(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 |
byte type = FioReadByte(); |
3557
5d12a78ce141
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
3695 |
_nfo_line++; |
2342
c19fb4f2df30
(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 |
|
c19fb4f2df30
(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 |
if (type == 0xFF) { |
c19fb4f2df30
(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 |
if (_skip_sprites == 0) { |
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2935
diff
changeset
|
3699 |
DecodeSpecialSprite(num, stage); |
5011
23f0b424a1be
(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
|
3700 |
|
23f0b424a1be
(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
|
3701 |
/* Stop all processing if we are to skip the remaining sprites */ |
23f0b424a1be
(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
|
3702 |
if (_skip_sprites == -1) break; |
23f0b424a1be
(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
|
3703 |
|
2342
c19fb4f2df30
(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 |
continue; |
c19fb4f2df30
(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 |
} else { |
c19fb4f2df30
(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 |
FioSkipBytes(num); |
1611 | 3707 |
} |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
3708 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3709 |
if (_skip_sprites == 0) grfmsg(7, "Skipping unexpected sprite"); |
2342
c19fb4f2df30
(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
|
3710 |
|
c19fb4f2df30
(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 |
FioSkipBytes(7); |
c19fb4f2df30
(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 |
num -= 8; |
c19fb4f2df30
(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 |
|
c19fb4f2df30
(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 |
if (type & 2) { |
c19fb4f2df30
(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 |
FioSkipBytes(num); |
c19fb4f2df30
(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
|
3716 |
} else { |
c19fb4f2df30
(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
|
3717 |
while (num > 0) { |
c19fb4f2df30
(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
|
3718 |
int8 i = FioReadByte(); |
c19fb4f2df30
(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 |
if (i >= 0) { |
c19fb4f2df30
(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 |
num -= i; |
c19fb4f2df30
(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 |
FioSkipBytes(i); |
c19fb4f2df30
(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 |
} else { |
c19fb4f2df30
(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 |
i = -(i >> 3); |
c19fb4f2df30
(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 |
num -= i; |
c19fb4f2df30
(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 |
FioReadByte(); |
c19fb4f2df30
(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
|
3726 |
} |
c19fb4f2df30
(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
|
3727 |
} |
c19fb4f2df30
(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 |
} |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
3729 |
} |
2342
c19fb4f2df30
(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 |
|
c19fb4f2df30
(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
|
3731 |
if (_skip_sprites > 0) _skip_sprites--; |
c19fb4f2df30
(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 |
} |
c19fb4f2df30
(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 |
} |
c19fb4f2df30
(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 |
|
c19fb4f2df30
(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
|
3735 |
|
c19fb4f2df30
(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 |
void LoadNewGRF(uint load_index, uint file_index) |
c19fb4f2df30
(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 |
{ |
5008
f95f0bd55c34
(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
|
3738 |
GrfLoadingStage stage; |
2342
c19fb4f2df30
(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
|
3739 |
|
2930
a3bfaa5a9222
(svn r3486) - NewGRF fix: Always reinitialize the ttdpatch flags as patch settings may have changed.
peter1138
parents:
2895
diff
changeset
|
3740 |
InitializeGRFSpecial(); |
0 | 3741 |
|
2463
de2605ed3758
(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
|
3742 |
ResetNewGRFData(); |
de2605ed3758
(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
|
3743 |
|
2342
c19fb4f2df30
(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 |
/* Load newgrf sprites |
c19fb4f2df30
(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 |
* in each loading stage, (try to) open each file specified in the config |
c19fb4f2df30
(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 |
* and load information from it. */ |
5008
f95f0bd55c34
(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
|
3747 |
for (stage = GLS_LABELSCAN; stage <= GLS_ACTIVATION; stage++) { |
2400
0b51bc385750
(svn r2926) -Fix: Use the same file slots in both initialisation stages when loading a patch grf
tron
parents:
2346
diff
changeset
|
3748 |
uint slot = file_index; |
3628
bd4a6601e5a2
(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
|
3749 |
GRFConfig *c; |
2342
c19fb4f2df30
(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 |
|
c19fb4f2df30
(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 |
_cur_stage = stage; |
c19fb4f2df30
(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 |
_cur_spriteid = load_index; |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3753 |
for (c = _grfconfig; c != NULL; c = c->next) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3754 |
if (HASBIT(c->flags, GCF_DISABLED) || HASBIT(c->flags, GCF_NOT_FOUND)) continue; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3755 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3756 |
// TODO usererror() |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3757 |
if (!FioCheckFileExists(c->filename)) error("NewGRF file is missing '%s'", c->filename); |
3628
bd4a6601e5a2
(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
|
3758 |
|
5008
f95f0bd55c34
(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
|
3759 |
if (stage == GLS_LABELSCAN) InitNewGRFFile(c, _cur_spriteid); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3760 |
LoadNewGRFFile(c, slot++, stage); |
5645 | 3761 |
if (stage == GLS_ACTIVATION) { |
3762 |
ClearTemporaryNewGRFData(); |
|
3763 |
DEBUG(sprite, 2, "Currently %i sprites are loaded", _cur_spriteid); |
|
3764 |
} |
|
2342
c19fb4f2df30
(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 |
} |
c19fb4f2df30
(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 |
} |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3767 |
|
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3768 |
// Pre-calculate all refit masks after loading GRF files |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
3769 |
CalculateRefitMasks(); |
0 | 3770 |
} |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3771 |
|
5588
1bcb6b4c01d8
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5570
diff
changeset
|
3772 |
|
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5649
diff
changeset
|
3773 |