author | peter1138 |
Sun, 07 May 2006 11:41:44 +0000 | |
changeset 3777 | bffc9d12cfba |
parent 3775 | f3f1ba3111fa |
child 3783 | 17a76f40e236 |
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" |
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
|
19 |
#include "bridge.h" |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
20 |
#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
|
21 |
#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
|
22 |
#include "vehicle.h" |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
23 |
#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
|
24 |
#include "table/sprites.h" |
0 | 25 |
|
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
26 |
#include "newgrf_spritegroup.h" |
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
27 |
|
0 | 28 |
/* TTDPatch extended GRF format codec |
29 |
* (c) Petr Baudis 2004 (GPL'd) |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
30 |
* 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
|
31 |
* |
0 | 32 |
* Contains portions of documentation by TTDPatch team. |
33 |
* Thanks especially to Josef Drexler for the documentation as well as a lot |
|
34 |
* of help at #tycoon. Also thanks to Michael Blunck for is GRF files which |
|
35 |
* served as subject to the initial testing of this codec. */ |
|
36 |
||
455 | 37 |
|
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
|
38 |
uint16 _custom_sprites_base; |
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
|
39 |
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
|
40 |
static uint _file_index; // XXX |
420
d3a089648ec3
(svn r617) -newgrf: Support for parameter 0x8E (train Y-pitch in info windows) both setting and testing. This should fix displaced wagons in DBSetXL as reported by DarkVater. (pasky)
darkvater
parents:
419
diff
changeset
|
41 |
extern int _traininfo_vehicle_pitch; |
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
|
42 |
SpriteID _signal_base = 0; |
0 | 43 |
|
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
|
44 |
static GRFFile *_cur_grffile; |
1477 | 45 |
GRFFile *_first_grffile; |
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
|
46 |
GRFConfig *_first_grfconfig; |
3707
2999a89e8abd
(svn r4650) - NewGRF: use the correct type for _cur_spriteid
peter1138
parents:
3704
diff
changeset
|
47 |
static SpriteID _cur_spriteid; |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
48 |
static int _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
|
49 |
static uint32 _nfo_line; |
0 | 50 |
|
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
|
51 |
/* 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
|
52 |
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
|
53 |
|
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
|
54 |
|
1477 | 55 |
typedef enum grfspec_feature { |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
56 |
GSF_TRAIN, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
57 |
GSF_ROAD, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
58 |
GSF_SHIP, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
59 |
GSF_AIRCRAFT, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
60 |
GSF_STATION, |
2438
eaef2b29fa3d
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
61 |
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
|
62 |
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
|
63 |
GSF_TOWNHOUSE, |
3620
b459e678a003
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
64 |
GSF_GLOBALVAR, |
b459e678a003
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
65 |
GSF_INDUSTRYTILES, |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
66 |
GSF_INDUSTRIES, |
3620
b459e678a003
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
67 |
GSF_CARGOS, |
b459e678a003
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
68 |
GSF_SOUNDFX, |
1477 | 69 |
} grfspec_feature; |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
70 |
|
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
71 |
|
0 | 72 |
typedef void (*SpecialSpriteHandler)(byte *buf, int len); |
73 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
74 |
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
|
75 |
/* GSF_TRAIN */ NUM_TRAIN_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
76 |
/* GSF_ROAD */ NUM_ROAD_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
77 |
/* GSF_SHIP */ NUM_SHIP_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
78 |
/* GSF_AIRCRAFT */ NUM_AIRCRAFT_ENGINES |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
79 |
}; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
80 |
|
0 | 81 |
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
|
82 |
/* GSF_TRAIN */ 0, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
83 |
/* GSF_ROAD */ ROAD_ENGINES_INDEX, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
84 |
/* GSF_SHIP */ SHIP_ENGINES_INDEX, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
85 |
/* GSF_AIRCRAFT */ AIRCRAFT_ENGINES_INDEX, |
0 | 86 |
}; |
87 |
||
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
|
88 |
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
|
89 |
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
|
90 |
}; |
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
|
91 |
|
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
92 |
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
|
93 |
static uint16 cargo_disallowed[TOTAL_NUM_ENGINES]; |
0 | 94 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
95 |
/* Debugging messages policy: |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
96 |
* |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
97 |
* These should be the severities used for direct DEBUG() calls |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
98 |
* (there is room for exceptions, but you have to have a good cause): |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
99 |
* |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
100 |
* 0..2 - dedicated to grfmsg() |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
101 |
* 3 |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
102 |
* 4 |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
103 |
* 5 |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
104 |
* 6 - action handler entry reporting - one per action |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
105 |
* 7 - basic action progress reporting - in loops, only single one allowed |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
106 |
* 8 - more detailed progress reporting - less important stuff, in deep loops etc |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
107 |
* 9 - extremely detailed progress reporting - detailed reports inside of deep loops and so |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
108 |
*/ |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
109 |
|
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
110 |
|
1477 | 111 |
typedef enum grfmsg_severity { |
0 | 112 |
GMS_NOTICE, |
113 |
GMS_WARN, |
|
114 |
GMS_ERROR, |
|
115 |
GMS_FATAL, |
|
1477 | 116 |
} grfmsg_severity; |
0 | 117 |
|
1477 | 118 |
static void CDECL grfmsg(grfmsg_severity severity, const char *str, ...) |
0 | 119 |
{ |
1477 | 120 |
static const char* const severitystr[] = { |
121 |
"Notice", |
|
122 |
"Warning", |
|
123 |
"Error", |
|
124 |
"Fatal" |
|
125 |
}; |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
126 |
int export_severity = 0; |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
51
diff
changeset
|
127 |
char buf[1024]; |
0 | 128 |
va_list va; |
129 |
||
130 |
va_start(va, str); |
|
1477 | 131 |
vsnprintf(buf, sizeof(buf), str, va); |
0 | 132 |
va_end(va); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
133 |
|
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
134 |
export_severity = 2 - (severity == GMS_FATAL ? 2 : severity); |
3557
5d12a78ce141
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
135 |
DEBUG(grf, export_severity) ("[%s:%d][%s] %s", _cur_grffile->filename, _nfo_line, severitystr[severity], buf); |
0 | 136 |
} |
137 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
138 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
139 |
#define check_length(real, wanted, where) \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
140 |
do { \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
141 |
if (real < wanted) { \ |
2849
73c752b82488
(svn r3397) - NewGRF fix: Show nfo sprite number instead of current sprite id for warning messages -- this makes this output more useful...
peter1138
parents:
2846
diff
changeset
|
142 |
grfmsg(GMS_ERROR, "%s: Invalid special sprite length %d (expected %d)!", \ |
73c752b82488
(svn r3397) - NewGRF fix: Show nfo sprite number instead of current sprite id for warning messages -- this makes this output more useful...
peter1138
parents:
2846
diff
changeset
|
143 |
where, real, wanted); \ |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
144 |
return; \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
145 |
} \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
146 |
} while (0) |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
147 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
148 |
|
500
ef288590e096
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
490
diff
changeset
|
149 |
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
|
150 |
{ |
0 | 151 |
return *(*buf)++; |
152 |
} |
|
153 |
||
154 |
static uint16 grf_load_word(byte **buf) |
|
155 |
{ |
|
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
|
156 |
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
|
157 |
return val | (grf_load_byte(buf) << 8); |
0 | 158 |
} |
159 |
||
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
160 |
static uint16 grf_load_extended(byte** buf) |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
161 |
{ |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
162 |
uint16 val; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
163 |
val = grf_load_byte(buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
164 |
if (val == 0xFF) val = grf_load_word(buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
165 |
return val; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
166 |
} |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
167 |
|
2324 | 168 |
static uint32 grf_load_dword(byte **buf) |
0 | 169 |
{ |
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
|
170 |
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
|
171 |
return val | (grf_load_word(buf) << 16); |
0 | 172 |
} |
173 |
||
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
|
174 |
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
|
175 |
{ |
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 |
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
|
177 |
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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
} |
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
|
184 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
185 |
|
1477 | 186 |
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
|
187 |
{ |
1477 | 188 |
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
|
189 |
|
1477 | 190 |
for (file = _first_grffile; file != NULL; file = file->next) { |
191 |
if (file->grfid == grfid) break; |
|
192 |
} |
|
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
|
193 |
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
|
194 |
} |
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
|
195 |
|
1477 | 196 |
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
|
197 |
{ |
1477 | 198 |
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
|
199 |
|
1477 | 200 |
for (file = _first_grffile; file != NULL; file = file->next) { |
201 |
if (strcmp(file->filename, filename) == 0) break; |
|
202 |
} |
|
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
|
203 |
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
|
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 |
|
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
|
206 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
207 |
typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); |
0 | 208 |
|
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
|
209 |
#define FOR_EACH_OBJECT for (i = 0; i < numinfo; i++) |
0 | 210 |
|
211 |
static void dewagonize(int condition, int engine) |
|
212 |
{ |
|
213 |
EngineInfo *ei = &_engine_info[engine]; |
|
214 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
|
215 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
216 |
if (condition != 0) { |
0 | 217 |
ei->unk2 &= ~0x80; |
218 |
rvi->flags &= ~2; |
|
219 |
} else { |
|
220 |
ei->unk2 |= 0x80; |
|
221 |
rvi->flags |= 2; |
|
222 |
} |
|
223 |
} |
|
224 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
225 |
static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 226 |
{ |
227 |
EngineInfo *ei = &_engine_info[engine]; |
|
228 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
|
229 |
byte *buf = *bufp; |
|
230 |
int i; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
231 |
bool ret = false; |
0 | 232 |
|
233 |
switch (prop) { |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
234 |
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
|
235 |
FOR_EACH_OBJECT { |
0 | 236 |
uint8 tracktype = grf_load_byte(&buf); |
237 |
||
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
|
238 |
switch (tracktype) { |
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 0: ei[i].railtype = RAILTYPE_RAIL; 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 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
|
241 |
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
|
242 |
default: |
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 |
grfmsg(GMS_WARN, "RailVehicleChangeInfo: Invalid track type %d specified, ignoring.", tracktype); |
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 |
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
|
245 |
} |
0 | 246 |
} |
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
|
247 |
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
|
248 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
249 |
case 0x08: /* AI passenger service */ |
0 | 250 |
/* TODO */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
251 |
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
|
252 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
253 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
254 |
|
3488
d1d5c0f3f69d
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
255 |
case 0x09: /* Speed (1 unit is 1 kmh) */ |
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
|
256 |
FOR_EACH_OBJECT { |
0 | 257 |
uint16 speed = grf_load_word(&buf); |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
258 |
if (speed == 0xFFFF) speed = 0; |
0 | 259 |
|
260 |
rvi[i].max_speed = speed; |
|
261 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
262 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
263 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
264 |
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
|
265 |
FOR_EACH_OBJECT { |
0 | 266 |
uint16 power = grf_load_word(&buf); |
267 |
||
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
268 |
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
|
269 |
|
0 | 270 |
rvi[i].power = power; |
271 |
dewagonize(power, engine + i); |
|
272 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
273 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
274 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
275 |
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
|
276 |
FOR_EACH_OBJECT { |
0 | 277 |
uint8 runcostfact = grf_load_byte(&buf); |
278 |
||
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
279 |
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
|
280 |
|
0 | 281 |
rvi[i].running_cost_base = runcostfact; |
282 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
283 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
284 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
285 |
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
|
286 |
FOR_EACH_OBJECT { |
0 | 287 |
uint32 base = grf_load_dword(&buf); |
288 |
||
289 |
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
|
290 |
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
|
291 |
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
|
292 |
case 0x4C3C: rvi[i].running_cost_class = 2; break; |
0 | 293 |
} |
294 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
295 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
296 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
297 |
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
|
298 |
FOR_EACH_OBJECT { |
0 | 299 |
uint8 spriteid = grf_load_byte(&buf); |
300 |
||
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
|
301 |
/* 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
|
302 |
* 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
|
303 |
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
|
304 |
|
0 | 305 |
rvi[i].image_index = spriteid; |
306 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
307 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
308 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
309 |
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
|
310 |
FOR_EACH_OBJECT { |
0 | 311 |
uint8 dual = grf_load_byte(&buf); |
312 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
313 |
if (dual != 0) { |
2836
b5e8424f5955
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
314 |
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
|
315 |
// 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
|
316 |
rvi[i].power /= 2; |
2836
b5e8424f5955
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
317 |
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
|
318 |
} |
1894
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
319 |
rvi[i].flags |= RVI_MULTIHEAD; |
0 | 320 |
} else { |
2836
b5e8424f5955
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
321 |
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
|
322 |
// 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
|
323 |
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
|
324 |
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
|
325 |
} |
1894
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
326 |
rvi[i].flags &= ~RVI_MULTIHEAD; |
0 | 327 |
} |
328 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
329 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
330 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
331 |
case 0x14: /* Cargo capacity */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
332 |
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
|
333 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
334 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
335 |
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
|
336 |
FOR_EACH_OBJECT { |
0 | 337 |
uint8 ctype = grf_load_byte(&buf); |
338 |
||
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
|
339 |
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
|
340 |
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
|
341 |
} else { |
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 |
grfmsg(GMS_NOTICE, "RailVehicleChangeInfo: Invalid cargo type %d, ignoring.", 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
|
343 |
} |
0 | 344 |
} |
3023
e56ff3134c77
(svn r3603) - NewGRF: Support loading of AI rank data
peter1138
parents:
3006
diff
changeset
|
345 |
break; |
e56ff3134c77
(svn r3603) - NewGRF: Support loading of AI rank data
peter1138
parents:
3006
diff
changeset
|
346 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
347 |
case 0x16: /* Weight */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
348 |
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
|
349 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
350 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
351 |
case 0x17: /* Cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
352 |
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
|
353 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
354 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
355 |
case 0x18: /* AI rank */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
356 |
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
|
357 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
358 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
359 |
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
|
360 |
/* 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
|
361 |
* 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
|
362 |
* 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
|
363 |
* 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
|
364 |
* 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
|
365 |
* 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
|
366 |
*/ |
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
|
367 |
FOR_EACH_OBJECT { |
0 | 368 |
uint8 traction = grf_load_byte(&buf); |
369 |
int engclass; |
|
370 |
||
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
371 |
if (traction <= 0x07) { |
0 | 372 |
engclass = 0; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
373 |
} else if (traction <= 0x27) { |
0 | 374 |
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
|
375 |
} 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
|
376 |
engclass = 2; |
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
|
377 |
ei[i].railtype = RAILTYPE_ELECTRIC; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
378 |
} else if (traction <= 0x41) { |
0 | 379 |
engclass = 2; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
380 |
} else { |
0 | 381 |
break; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
382 |
} |
0 | 383 |
|
384 |
rvi[i].engclass = engclass; |
|
385 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
386 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
387 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
388 |
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
|
389 |
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
|
390 |
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
|
391 |
|
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
|
392 |
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
|
393 |
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
|
394 |
} else { |
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 |
grfmsg(GMS_NOTICE, "RailVehicleChangeInfo: Invalid train engine ID %d, ignoring.", 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
|
396 |
} |
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 |
} |
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 |
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
|
399 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
400 |
case 0x1B: /* Powered wagons power bonus */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
401 |
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
|
402 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
403 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
404 |
case 0x1D: /* Refit cargo */ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
405 |
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
|
406 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
407 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
408 |
case 0x1E: /* Callback */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
409 |
FOR_EACH_OBJECT rvi[i].callbackmask = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
410 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
411 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
412 |
case 0x21: /* Shorter vehicle */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
413 |
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
|
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 0x22: /* Visual effect */ |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
417 |
// 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
|
418 |
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
|
419 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
420 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
421 |
case 0x23: /* Powered wagons weight bonus */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
422 |
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
|
423 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
424 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
425 |
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
|
426 |
FOR_EACH_OBJECT { |
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
427 |
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
|
428 |
|
2545
d1965652e523
(svn r3074) -NewGrf: Fix stupid typo in weight setting.
peter1138
parents:
2542
diff
changeset
|
429 |
if (weight > 4) { |
2542
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
430 |
grfmsg(GMS_NOTICE, "RailVehicleChangeInfo: Nonsensical weight of %d tons, ignoring.", weight << 8); |
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
431 |
} else { |
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
432 |
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
|
433 |
} |
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
434 |
} |
3089
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 |
|
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
437 |
case 0x27: /* Miscellaneous flags */ |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
438 |
FOR_EACH_OBJECT ei[i].misc_flags = grf_load_byte(&buf); |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
439 |
break; |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
440 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
441 |
case 0x28: /* Cargo classes allowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
442 |
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
|
443 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
444 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
445 |
case 0x29: /* Cargo classes disallowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
446 |
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
|
447 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
448 |
|
0 | 449 |
/* TODO */ |
450 |
/* 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
|
451 |
case 0x1C: /* Refit cost */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
452 |
case 0x1F: /* Tractive effort */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
453 |
case 0x20: /* Air drag */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
454 |
case 0x25: /* User-defined bit mask to set when checking veh. var. 42 */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
455 |
case 0x26: /* Retire vehicle early */ |
0 | 456 |
/* TODO */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
457 |
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
|
458 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
459 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
460 |
|
0 | 461 |
default: |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
462 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
463 |
break; |
0 | 464 |
} |
465 |
*bufp = buf; |
|
466 |
return ret; |
|
467 |
} |
|
468 |
||
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
469 |
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
|
470 |
{ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
471 |
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
|
472 |
RoadVehicleInfo *rvi = &_road_vehicle_info[engine]; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
473 |
byte *buf = *bufp; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
474 |
int i; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
475 |
bool ret = false; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
476 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
477 |
switch (prop) { |
3488
d1d5c0f3f69d
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
478 |
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
|
479 |
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
|
480 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
481 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
482 |
case 0x09: /* Running cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
483 |
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
|
484 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
485 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
486 |
case 0x0A: /* Running cost base */ |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
487 |
/* TODO: I have no idea. --pasky */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
488 |
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
|
489 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
490 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
491 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
492 |
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
|
493 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
494 |
uint8 spriteid = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
495 |
|
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
496 |
// 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
|
497 |
if (spriteid == 0xFF) spriteid = 0xFD; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
498 |
|
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
499 |
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
|
500 |
|
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
501 |
rvi[i].image_index = spriteid; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
502 |
} |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
503 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
504 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
505 |
case 0x0F: /* Cargo capacity */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
506 |
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
|
507 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
508 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
509 |
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
|
510 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
511 |
uint8 cargo = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
512 |
|
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
|
513 |
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
|
514 |
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
|
515 |
} else { |
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
|
516 |
grfmsg(GMS_NOTICE, "RoadVehicleChangeInfo: Invalid cargo type %d, ignoring.", 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
|
517 |
} |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
518 |
} |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
519 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
520 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
521 |
case 0x11: /* Cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
522 |
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
|
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 0x12: /* SFX */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
526 |
FOR_EACH_OBJECT rvi[i].sfx = 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 0x13: /* Power in 10hp */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
530 |
case 0x14: /* Weight in 1/4 tons */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
531 |
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
|
532 |
/* 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
|
533 |
* 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
|
534 |
* missing in OTTD yet. --pasky */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
535 |
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
|
536 |
ret = true; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
537 |
break; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
538 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
539 |
case 0x16: /* Cargos available for refitting */ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
540 |
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
|
541 |
break; |
f106b4538f41
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
542 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
543 |
case 0x17: /* Callback mask */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
544 |
FOR_EACH_OBJECT rvi[i].callbackmask = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
545 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
546 |
|
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
547 |
case 0x1C: /* Miscellaneous flags */ |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
548 |
FOR_EACH_OBJECT ei[i].misc_flags = grf_load_byte(&buf); |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
549 |
break; |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
550 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
551 |
case 0x1D: /* Cargo classes allowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
552 |
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
|
553 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
554 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
555 |
case 0x1E: /* Cargo classes disallowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
556 |
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
|
557 |
break; |
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 0x18: /* Tractive effort */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
560 |
case 0x19: /* Air drag */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
561 |
case 0x1A: /* Refit cost */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
562 |
case 0x1B: /* Retire vehicle early */ |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
563 |
/* TODO */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
564 |
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
|
565 |
ret = true; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
566 |
break; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
567 |
|
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
568 |
default: |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
569 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
570 |
break; |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
571 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
572 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
573 |
*bufp = buf; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
574 |
return ret; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
575 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
576 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
577 |
static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 578 |
{ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
579 |
EngineInfo *ei = &_engine_info[SHIP_ENGINES_INDEX + engine]; |
0 | 580 |
ShipVehicleInfo *svi = &_ship_vehicle_info[engine]; |
581 |
byte *buf = *bufp; |
|
582 |
int i; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
583 |
bool ret = false; |
0 | 584 |
|
585 |
//printf("e %x prop %x?\n", engine, prop); |
|
586 |
switch (prop) { |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
587 |
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
|
588 |
FOR_EACH_OBJECT { |
0 | 589 |
uint8 spriteid = grf_load_byte(&buf); |
590 |
||
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
591 |
// 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
|
592 |
if (spriteid == 0xFF) spriteid = 0xFD; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
593 |
|
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
594 |
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
|
595 |
|
0 | 596 |
svi[i].image_index = spriteid; |
597 |
} |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
598 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
599 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
600 |
case 0x09: /* Refittable */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
601 |
FOR_EACH_OBJECT svi[i].refittable = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
602 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
603 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
604 |
case 0x0A: /* Cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
605 |
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
|
606 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
607 |
|
3488
d1d5c0f3f69d
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
608 |
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
|
609 |
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
|
610 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
611 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
612 |
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
|
613 |
FOR_EACH_OBJECT { |
0 | 614 |
uint8 cargo = grf_load_byte(&buf); |
615 |
||
616 |
// XXX: Need to consult this with patchman yet. |
|
617 |
#if 0 |
|
618 |
// Documentation claims this is already the |
|
619 |
// per-landscape cargo type id, but newships.grf |
|
620 |
// assume otherwise. |
|
621 |
cargo = local_cargo_id_ctype[cargo]; |
|
622 |
#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
|
623 |
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
|
624 |
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
|
625 |
} else { |
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
|
626 |
grfmsg(GMS_NOTICE, "ShipVehicleChangeInfo: Invalid cargo type %d, ignoring.", 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
|
627 |
} |
0 | 628 |
} |
3006
f106b4538f41
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
629 |
break; |
f106b4538f41
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
630 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
631 |
case 0x0D: /* Cargo capacity */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
632 |
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
|
633 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
634 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
635 |
case 0x0F: /* Running cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
636 |
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
|
637 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
638 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
639 |
case 0x10: /* SFX */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
640 |
FOR_EACH_OBJECT svi[i].sfx = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
641 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
642 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
643 |
case 0x11: /* Cargos available for refitting */ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
644 |
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
|
645 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
646 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
647 |
case 0x12: /* Callback mask */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
648 |
FOR_EACH_OBJECT svi[i].callbackmask = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
649 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
650 |
|
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
651 |
case 0x17: /* Miscellaneous flags */ |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
652 |
FOR_EACH_OBJECT ei[i].misc_flags = grf_load_byte(&buf); |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
653 |
break; |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
654 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
655 |
case 0x18: /* Cargo classes allowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
656 |
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
|
657 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
658 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
659 |
case 0x19: /* Cargo classes disallowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
660 |
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
|
661 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
662 |
|
1872
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
663 |
case 0x13: /* Refit cost */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
664 |
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
|
665 |
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
|
666 |
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
|
667 |
/* TODO */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
668 |
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
|
669 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
670 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
671 |
|
0 | 672 |
default: |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
673 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
674 |
break; |
0 | 675 |
} |
676 |
||
677 |
*bufp = buf; |
|
678 |
return ret; |
|
679 |
} |
|
680 |
||
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
|
681 |
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
|
682 |
{ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
683 |
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
|
684 |
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
|
685 |
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
|
686 |
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
|
687 |
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
|
688 |
|
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
|
689 |
//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
|
690 |
switch (prop) { |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
691 |
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
|
692 |
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
|
693 |
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
|
694 |
|
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
695 |
// 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
|
696 |
if (spriteid == 0xFF) spriteid = 0xFD; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
697 |
|
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
698 |
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
|
699 |
|
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
|
700 |
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
|
701 |
} |
3006
f106b4538f41
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
702 |
break; |
f106b4538f41
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
703 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
704 |
case 0x09: /* Helicopter */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
705 |
FOR_EACH_OBJECT SB(avi[i].subtype, 0, 1, (grf_load_byte(&buf) != 0 ? 1 : 0)); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
706 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
707 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
708 |
case 0x0A: /* Large */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
709 |
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
|
710 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
711 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
712 |
case 0x0B: /* Cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
713 |
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
|
714 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
715 |
|
3488
d1d5c0f3f69d
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
716 |
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
|
717 |
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
|
718 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
719 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
720 |
case 0x0D: /* Acceleration */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
721 |
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
|
722 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
723 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
724 |
case 0x0E: /* Running cost factor */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
725 |
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
|
726 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
727 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
728 |
case 0x0F: /* Passenger capacity */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
729 |
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
|
730 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
731 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
732 |
case 0x11: /* Mail capacity */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
733 |
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
|
734 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
735 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
736 |
case 0x12: /* SFX */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
737 |
FOR_EACH_OBJECT avi[i].sfx = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
738 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
739 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
740 |
case 0x13: /* Cargos available for refitting */ |
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
741 |
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
|
742 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
743 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
744 |
case 0x14: /* Callback mask */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
745 |
FOR_EACH_OBJECT avi[i].callbackmask = grf_load_byte(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
746 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
747 |
|
3095
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
748 |
case 0x17: /* Miscellaneous flags */ |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
749 |
FOR_EACH_OBJECT ei[i].misc_flags = grf_load_byte(&buf); |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
750 |
break; |
2d4498efac3b
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
751 |
|
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
752 |
case 0x18: /* Cargo classes allowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
753 |
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
|
754 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
755 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
756 |
case 0x19: /* Cargo classes disallowed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
757 |
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
|
758 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
759 |
|
1872
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
760 |
case 0x15: /* Refit cost */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
761 |
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
|
762 |
/* TODO */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
763 |
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
|
764 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
765 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
766 |
|
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
|
767 |
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
|
768 |
ret = true; |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
769 |
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
|
770 |
} |
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
|
771 |
|
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
|
772 |
*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
|
773 |
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
|
774 |
} |
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
|
775 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
776 |
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
|
777 |
{ |
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
|
778 |
StationSpec **statspec; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
779 |
byte *buf = *bufp; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
780 |
int i; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
781 |
bool ret = false; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
782 |
|
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
|
783 |
if (stid + numinfo > MAX_STATIONS) { |
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
|
784 |
grfmsg(GMS_WARN, "StationChangeInfo: Station %u is invalid, max %u, ignoring.", stid + numinfo, MAX_STATIONS); |
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
|
785 |
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
|
786 |
} |
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
|
787 |
|
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
|
788 |
/* Allocate station specs if necessary */ |
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
|
789 |
if (_cur_grffile->stations == NULL) _cur_grffile->stations = calloc(MAX_STATIONS, sizeof(*_cur_grffile->stations)); |
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
|
790 |
|
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
|
791 |
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
|
792 |
|
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
|
793 |
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
|
794 |
/* 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
|
795 |
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
|
796 |
if (statspec[i] == NULL) { |
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
|
797 |
grfmsg(GMS_NOTICE, "StationChangeInfo: Attempt to modify undefined station %u, ignoring.", stid + 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
|
798 |
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
|
799 |
} |
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
|
800 |
} |
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
|
801 |
} |
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
|
802 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
803 |
switch (prop) { |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
804 |
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
|
805 |
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
|
806 |
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
|
807 |
|
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
|
808 |
/* Property 0x08 is special; it is where the station is allocated */ |
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
|
809 |
if (statspec[i] == NULL) statspec[i] = calloc(1, sizeof(*statspec[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
|
810 |
|
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
|
811 |
/* 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
|
812 |
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
|
813 |
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
|
814 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
815 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
816 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
817 |
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
|
818 |
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
|
819 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
3570
f9749bae861e
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
820 |
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
|
821 |
|
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
822 |
statspec->tiles = grf_load_extended(&buf); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
823 |
statspec->renderdata = calloc(statspec->tiles, sizeof(*statspec->renderdata)); |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
824 |
statspec->copied_renderdata = false; |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
825 |
|
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
826 |
for (t = 0; t < statspec->tiles; t++) { |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
827 |
DrawTileSprites *dts = &statspec->renderdata[t]; |
3570
f9749bae861e
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
828 |
uint seq_count = 0; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
829 |
|
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
|
830 |
dts->seq = NULL; |
3775
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
831 |
dts->ground_sprite = grf_load_dword(&buf); |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
832 |
if (dts->ground_sprite == 0) continue; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
833 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
834 |
while (buf < *bufp + len) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
835 |
DrawTileSeqStruct *dtss; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
836 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
837 |
// no relative bounding box support |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
838 |
dts->seq = realloc((void*)dts->seq, ++seq_count * sizeof(DrawTileSeqStruct)); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
839 |
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
|
840 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
841 |
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
|
842 |
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
|
843 |
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
|
844 |
dtss->delta_z = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
845 |
dtss->width = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
846 |
dtss->height = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
847 |
dtss->unk = 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
|
848 |
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
|
849 |
|
3775
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
850 |
/* Remap flags as ours collide */ |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
851 |
if (HASBIT(dtss->image, 31)) { |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
852 |
CLRBIT(dtss->image, 31); |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
853 |
SETBIT(dtss->image, 30); |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
854 |
} |
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
|
855 |
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
|
856 |
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
|
857 |
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
|
858 |
} |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
859 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
860 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
861 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
862 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
863 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
864 |
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
|
865 |
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
|
866 |
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
|
867 |
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
|
868 |
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
|
869 |
|
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
870 |
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
|
871 |
statspec->renderdata = srcstatspec->renderdata; |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
872 |
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
|
873 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
874 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
875 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
876 |
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
|
877 |
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
|
878 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
879 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
880 |
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
|
881 |
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
|
882 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
883 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
884 |
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
|
885 |
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
|
886 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
887 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
888 |
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
|
889 |
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
|
890 |
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
|
891 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
892 |
while (buf < *bufp + len) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
893 |
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
|
894 |
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
|
895 |
StationLayout layout; |
3570
f9749bae861e
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
896 |
uint l, p; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
897 |
|
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
898 |
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
|
899 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
900 |
//debug("l %d > %d ?", length, stat->lengths); |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
901 |
if (length > statspec->lengths) { |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
902 |
statspec->platforms = realloc(statspec->platforms, length); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
903 |
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
|
904 |
|
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
905 |
statspec->layouts = realloc(statspec->layouts, length * sizeof(*statspec->layouts)); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
906 |
memset(statspec->layouts + statspec->lengths, 0, |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
907 |
(length - statspec->lengths) * sizeof(*statspec->layouts)); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
908 |
|
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
909 |
statspec->lengths = length; |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
910 |
} |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
911 |
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
|
912 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
913 |
//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
|
914 |
if (number > statspec->platforms[l]) { |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
915 |
statspec->layouts[l] = realloc(statspec->layouts[l], |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
916 |
number * sizeof(**statspec->layouts)); |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
917 |
// 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
|
918 |
memset(statspec->layouts[l] + statspec->platforms[l], 0, |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
919 |
(number - statspec->platforms[l]) * sizeof(**statspec->layouts)); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
920 |
|
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
921 |
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
|
922 |
} |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
923 |
|
542 | 924 |
p = 0; |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
925 |
layout = malloc(length * number); |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
926 |
for (l = 0; l < length; l++) { |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
927 |
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
|
928 |
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
|
929 |
} |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
930 |
} |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
931 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
932 |
l--; |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
933 |
p--; |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
934 |
free(statspec->layouts[l][p]); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
935 |
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
|
936 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
937 |
} |
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 0x0F: /* Copy custom layout */ |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
941 |
/* TODO */ |
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
|
942 |
FOR_EACH_OBJECT { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
943 |
grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
944 |
} |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
945 |
ret = true; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
946 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
947 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
948 |
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
|
949 |
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
|
950 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
951 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
952 |
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
|
953 |
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
|
954 |
break; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
955 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
956 |
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
|
957 |
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
|
958 |
break; |
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
959 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
960 |
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
|
961 |
FOR_EACH_OBJECT statspec[i]->flags = grf_load_byte(&buf); |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
962 |
break; |
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
963 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
964 |
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
|
965 |
FOR_EACH_OBJECT statspec[i]->wires = grf_load_byte(&buf); |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
966 |
break; |
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
967 |
|
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
968 |
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
|
969 |
FOR_EACH_OBJECT statspec[i]->blocked = grf_load_byte(&buf); |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
970 |
break; |
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
971 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
972 |
default: |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
973 |
ret = true; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
974 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
975 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
976 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
977 |
*bufp = buf; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
978 |
return ret; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
979 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
980 |
|
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
|
981 |
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
|
982 |
{ |
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
|
983 |
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
|
984 |
int i; |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
985 |
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
|
986 |
|
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
|
987 |
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
|
988 |
case 0x08: /* Year of availability */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
989 |
FOR_EACH_OBJECT _bridge[brid + i].avail_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
|
990 |
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
|
991 |
|
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
|
992 |
case 0x09: /* Minimum length */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
993 |
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
|
994 |
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
|
995 |
|
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
|
996 |
case 0x0A: /* Maximum length */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
997 |
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
|
998 |
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
|
999 |
|
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
|
1000 |
case 0x0B: /* Cost factor */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1001 |
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
|
1002 |
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
|
1003 |
|
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
|
1004 |
case 0x0C: /* Maximum speed */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1005 |
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
|
1006 |
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
|
1007 |
|
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
|
1008 |
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
|
1009 |
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
|
1010 |
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
|
1011 |
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
|
1012 |
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
|
1013 |
|
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
|
1014 |
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
|
1015 |
/* Allocate memory for sprite table pointers and zero out */ |
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
|
1016 |
bridge->sprite_table = calloc(7, sizeof(*bridge->sprite_table)); |
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
|
1017 |
} |
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
|
1018 |
|
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
|
1019 |
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
|
1020 |
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
|
1021 |
|
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
|
1022 |
if (tableid >= 7) { // skip invalid data |
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
|
1023 |
grfmsg(GMS_WARN, "BridgeChangeInfo: Table %d >= 7, skipping.", 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
|
1024 |
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
|
1025 |
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
|
1026 |
} |
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
|
1027 |
|
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
|
1028 |
if (bridge->sprite_table[tableid] == NULL) { |
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
|
1029 |
bridge->sprite_table[tableid] = malloc(32 * sizeof(**bridge->sprite_table)); |
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
|
1030 |
} |
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
|
1031 |
|
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
|
1032 |
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
|
1033 |
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
|
1034 |
} |
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
|
1035 |
} |
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
|
1036 |
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
|
1037 |
|
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
|
1038 |
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
|
1039 |
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
|
1040 |
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
|
1041 |
|
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
|
1042 |
default: |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1043 |
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
|
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 |
|
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 |
*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
|
1047 |
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
|
1048 |
} |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1049 |
|
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1050 |
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
|
1051 |
{ |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1052 |
byte *buf = *bufp; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1053 |
int i; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1054 |
bool ret = false; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1055 |
|
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1056 |
switch (prop) { |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1057 |
case 0x08: /* Cost base factor */ |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1058 |
FOR_EACH_OBJECT { |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1059 |
byte factor = grf_load_byte(&buf); |
2508
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1060 |
uint price = gvid + i; |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1061 |
|
2508
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1062 |
if (price < NUM_PRICES) { |
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1063 |
SetPriceBaseMultiplier(price, factor); |
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1064 |
} else { |
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1065 |
grfmsg(GMS_WARN, "GlobalVarChangeInfo: Price %d out of range, ignoring.", price); |
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1066 |
} |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1067 |
} |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1068 |
break; |
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1069 |
|
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1070 |
default: |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1071 |
ret = true; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1072 |
} |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1073 |
|
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1074 |
*bufp = buf; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1075 |
return ret; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1076 |
} |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1077 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1078 |
/* Action 0x00 */ |
0 | 1079 |
static void VehicleChangeInfo(byte *buf, int len) |
1080 |
{ |
|
1081 |
byte *bufend = buf + len; |
|
1082 |
int i; |
|
1083 |
||
1084 |
/* <00> <feature> <num-props> <num-info> <id> (<property <new-info>)... |
|
1085 |
* |
|
1086 |
* B feature 0, 1, 2 or 3 for trains, road vehicles, ships or planes |
|
1087 |
* 4 for defining new train station sets |
|
1088 |
* B num-props how many properties to change per vehicle/station |
|
1089 |
* B num-info how many vehicles/stations to change |
|
1090 |
* B id ID of first vehicle/station to change, if num-info is |
|
1091 |
* greater than one, this one and the following |
|
1092 |
* vehicles/stations will be changed |
|
1093 |
* B property what property to change, depends on the feature |
|
1094 |
* 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
|
1095 |
/* TODO: Bridges, town houses. */ |
0 | 1096 |
|
2438
eaef2b29fa3d
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
1097 |
static const VCI_Handler handler[] = { |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
1098 |
/* GSF_TRAIN */ RailVehicleChangeInfo, |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
1099 |
/* GSF_ROAD */ RoadVehicleChangeInfo, |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
1100 |
/* GSF_SHIP */ ShipVehicleChangeInfo, |
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
|
1101 |
/* GSF_AIRCRAFT */ AircraftVehicleChangeInfo, |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1102 |
/* GSF_STATION */ StationChangeInfo, |
2438
eaef2b29fa3d
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
1103 |
/* GSF_CANAL */ NULL, |
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
|
1104 |
/* GSF_BRIDGE */ BridgeChangeInfo, |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1105 |
/* GSF_TOWNHOUSE */NULL, |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1106 |
/* GSF_GLOBALVAR */GlobalVarChangeInfo, |
0 | 1107 |
}; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1108 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1109 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1110 |
uint8 numprops; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1111 |
uint8 numinfo; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1112 |
byte engine; |
542 | 1113 |
EngineInfo *ei = NULL; |
0 | 1114 |
|
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
|
1115 |
if (len == 1) { |
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
|
1116 |
DEBUG(grf, 8) ("Silently ignoring one-byte special sprite 0x00."); |
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
|
1117 |
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
|
1118 |
} |
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
|
1119 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1120 |
check_length(len, 6, "VehicleChangeInfo"); |
3714
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1121 |
buf++; |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1122 |
feature = grf_load_byte(&buf); |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1123 |
numprops = grf_load_byte(&buf); |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1124 |
numinfo = grf_load_byte(&buf); |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1125 |
engine = grf_load_byte(&buf); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
1126 |
|
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
1127 |
DEBUG(grf, 6) ("VehicleChangeInfo: Feature %d, %d properties, to apply to %d+%d", |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
1128 |
feature, numprops, engine, numinfo); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
1129 |
|
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
|
1130 |
if (feature >= lengthof(handler) || handler[feature] == NULL) { |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1131 |
grfmsg(GMS_WARN, "VehicleChangeInfo: Unsupported feature %d, skipping.", feature); |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1132 |
return; |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1133 |
} |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1134 |
|
2439
c820a9751afc
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1135 |
if (feature <= GSF_AIRCRAFT) { |
c820a9751afc
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1136 |
if (engine + numinfo > _vehcounts[feature]) { |
c820a9751afc
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1137 |
grfmsg(GMS_ERROR, "VehicleChangeInfo: Last engine ID %d out of bounds (max %d), skipping.", engine + numinfo, _vehcounts[feature]); |
c820a9751afc
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1138 |
return; |
c820a9751afc
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1139 |
} |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1140 |
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
|
1141 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1142 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1143 |
while (numprops-- && buf < bufend) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1144 |
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
|
1145 |
bool ignoring = false; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1146 |
|
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1147 |
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
|
1148 |
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
|
1149 |
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
|
1150 |
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
|
1151 |
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
|
1152 |
/* 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
|
1153 |
switch (prop) { |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1154 |
case 0x00: /* Introduction date */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1155 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_word(&buf); |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1156 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1157 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1158 |
case 0x02: /* Decay speed */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1159 |
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
|
1160 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1161 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1162 |
case 0x03: /* Vehicle life */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1163 |
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
|
1164 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1165 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1166 |
case 0x04: /* Model life */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1167 |
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
|
1168 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1169 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1170 |
case 0x06: /* Climates available */ |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1171 |
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
|
1172 |
break; |
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1173 |
|
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1174 |
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
|
1175 |
/* TODO */ |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1176 |
/* 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
|
1177 |
* 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
|
1178 |
* credit ;-). --pasky */ |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1179 |
/* TODO: This needs to be supported by |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1180 |
* LoadUnloadVehicle() first. */ |
3089
e5d1c3984821
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1181 |
FOR_EACH_OBJECT 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
|
1182 |
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
|
1183 |
break; |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1184 |
|
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1185 |
default: |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1186 |
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
|
1187 |
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
|
1188 |
break; |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1189 |
} |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1190 |
break; |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1191 |
|
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1192 |
default: |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1193 |
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
|
1194 |
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
|
1195 |
break; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1196 |
} |
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1197 |
|
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1198 |
if (ignoring) |
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1199 |
grfmsg(GMS_NOTICE, "VehicleChangeInfo: Ignoring property 0x%02X (not implemented).", prop); |
0 | 1200 |
} |
1201 |
} |
|
1202 |
||
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
|
1203 |
#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
|
1204 |
|
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1205 |
/** |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1206 |
* Creates a spritegroup representing a callback result |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1207 |
* @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
|
1208 |
* @return A spritegroup representing that callback result |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1209 |
*/ |
2752 | 1210 |
static SpriteGroup* NewCallBackResultSpriteGroup(uint16 value) |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1211 |
{ |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
1212 |
SpriteGroup *group = AllocateSpriteGroup(); |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1213 |
|
2488
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1214 |
group->type = SGT_CALLBACK; |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1215 |
|
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1216 |
// 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
|
1217 |
// 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
|
1218 |
if ((value >> 8) == 0xFF) { |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1219 |
value &= ~0xFF00; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1220 |
} else { |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1221 |
value &= ~0x8000; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1222 |
} |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1223 |
|
2488
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1224 |
group->g.callback.result = value; |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1225 |
|
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1226 |
return group; |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1227 |
} |
0 | 1228 |
|
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
|
1229 |
/** |
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
|
1230 |
* 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
|
1231 |
* @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
|
1232 |
* @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
|
1233 |
* @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
|
1234 |
*/ |
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
|
1235 |
static 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
|
1236 |
{ |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
1237 |
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
|
1238 |
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
|
1239 |
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
|
1240 |
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
|
1241 |
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
|
1242 |
} |
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
|
1243 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1244 |
/* 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
|
1245 |
static void NewSpriteSet(byte *buf, int len) |
0 | 1246 |
{ |
1247 |
/* <01> <feature> <num-sets> <num-ent> |
|
1248 |
* |
|
1249 |
* B feature feature to define sprites for |
|
1250 |
* 0, 1, 2, 3: veh-type, 4: train stations |
|
1251 |
* B num-sets number of sprite sets |
|
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1252 |
* E num-ent how many entries per sprite set |
0 | 1253 |
* For vehicles, this is the number of different |
1254 |
* vehicle directions in each sprite set |
|
1255 |
* Set num-dirs=8, unless your sprites are symmetric. |
|
1256 |
* In that case, use num-dirs=4. |
|
1257 |
* For stations, must be 12 (hex) for the eighteen |
|
1258 |
* different sprites that make up a station */ |
|
1259 |
/* TODO: No stations support. */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1260 |
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
|
1261 |
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
|
1262 |
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
|
1263 |
uint i; |
0 | 1264 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1265 |
check_length(len, 4, "NewSpriteSet"); |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1266 |
buf++; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1267 |
feature = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1268 |
num_sets = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1269 |
num_ents = grf_load_extended(&buf); |
0 | 1270 |
|
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
|
1271 |
_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
|
1272 |
_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
|
1273 |
_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
|
1274 |
_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
|
1275 |
|
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
|
1276 |
DEBUG(grf, 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
|
1277 |
"New sprite set at %d of type %d, " |
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
|
1278 |
"consisting of %d sets with %d views each (total %d)", |
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
|
1279 |
_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
|
1280 |
); |
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
|
1281 |
|
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
|
1282 |
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
|
1283 |
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
|
1284 |
_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
|
1285 |
} |
0 | 1286 |
} |
1287 |
||
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
|
1288 |
/* 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
|
1289 |
* defined spritegroup. */ |
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
|
1290 |
static SpriteGroup* GetGroupFromGroupID(byte setid, byte type, uint16 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
|
1291 |
{ |
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
|
1292 |
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
|
1293 |
|
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
|
1294 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == 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
|
1295 |
grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty.", setid, type, 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
|
1296 |
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
|
1297 |
} |
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
|
1298 |
|
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
|
1299 |
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
|
1300 |
} |
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
|
1301 |
|
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
|
1302 |
/* Helper function to either create a callback or a result sprite group. */ |
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
|
1303 |
static SpriteGroup* CreateGroupFromGroupID(byte setid, byte type, uint16 spriteid, uint16 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
|
1304 |
{ |
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
|
1305 |
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
|
1306 |
|
3667
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1307 |
if (spriteid >= _cur_grffile->spriteset_numsets) { |
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1308 |
grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Sprite set %u invalid, max %u", setid, type, spriteid, _cur_grffile->spriteset_numsets); |
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1309 |
return NULL; |
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1310 |
} |
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1311 |
|
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
|
1312 |
/* 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
|
1313 |
* 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
|
1314 |
* 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
|
1315 |
if (_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites > _cur_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
|
1316 |
grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Real Sprite IDs 0x%04X - 0x%04X do not (all) exist (max 0x%04X), leaving empty.", |
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
|
1317 |
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
|
1318 |
_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
|
1319 |
_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
|
1320 |
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
|
1321 |
} |
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
|
1322 |
|
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
|
1323 |
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
|
1324 |
} |
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
|
1325 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1326 |
/* 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
|
1327 |
static void NewSpriteGroup(byte *buf, int len) |
0 | 1328 |
{ |
1329 |
/* <02> <feature> <set-id> <type/num-entries> <feature-specific-data...> |
|
1330 |
* |
|
1331 |
* B feature see action 1 |
|
1332 |
* B set-id ID of this particular definition |
|
1333 |
* B type/num-entries |
|
1334 |
* if 80 or greater, this is a randomized or variational |
|
1335 |
* list definition, see below |
|
1336 |
* otherwise it specifies a number of entries, the exact |
|
1337 |
* meaning depends on the feature |
|
1338 |
* 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
|
1339 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1340 |
uint8 setid; |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1341 |
uint8 type; |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1342 |
SpriteGroup *group = NULL; |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1343 |
byte *bufend = buf + len; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
1344 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1345 |
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
|
1346 |
buf++; |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1347 |
|
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1348 |
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
|
1349 |
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
|
1350 |
type = grf_load_byte(&buf); |
0 | 1351 |
|
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
|
1352 |
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
|
1353 |
// Allocate memory for new sprite group references. |
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1354 |
_cur_grffile->spritegroups = realloc(_cur_grffile->spritegroups, (setid + 1) * sizeof(*_cur_grffile->spritegroups)); |
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1355 |
// 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
|
1356 |
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
|
1357 |
_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
|
1358 |
} |
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
|
1359 |
|
3634
fba43afa3d38
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1360 |
if (feature != _cur_grffile->spriteset_feature) { |
fba43afa3d38
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1361 |
grfmsg(GMS_WARN, "NewSpriteGroup: sprite set feature 0x%02X does not match action feature 0x%02X, skipping.", |
fba43afa3d38
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1362 |
_cur_grffile->spriteset_feature, feature); |
fba43afa3d38
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1363 |
/* Clear this group's reference */ |
fba43afa3d38
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1364 |
_cur_grffile->spritegroups[setid] = NULL; |
fba43afa3d38
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1365 |
return; |
fba43afa3d38
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1366 |
} |
fba43afa3d38
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1367 |
|
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1368 |
switch (type) { |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1369 |
/* Deterministic Sprite Group */ |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1370 |
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
|
1371 |
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
|
1372 |
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
|
1373 |
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
|
1374 |
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
|
1375 |
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
|
1376 |
{ |
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
|
1377 |
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
|
1378 |
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
|
1379 |
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
|
1380 |
|
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
|
1381 |
/* 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
|
1382 |
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
|
1383 |
|
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1384 |
group = AllocateSpriteGroup(); |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1385 |
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
|
1386 |
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
|
1387 |
|
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
|
1388 |
switch (GB(type, 2, 2)) { |
3672
73caf2e829f8
(svn r4588) - NewGRF: silence a false compiler warning
peter1138
parents:
3668
diff
changeset
|
1389 |
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
|
1390 |
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
|
1391 |
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
|
1392 |
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
|
1393 |
} |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1394 |
|
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
|
1395 |
check_length(bufend - buf, 2 + (varsize * 3) + 2, "NewSpriteGroup (Deterministic) (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
|
1396 |
|
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
|
1397 |
/* 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
|
1398 |
* 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
|
1399 |
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
|
1400 |
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
|
1401 |
|
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
|
1402 |
if (group->g.determ.num_adjusts > 0) { |
3694
ba2b26464b85
(svn r4631) - NewGRF: fix incorrect length check
peter1138
parents:
3676
diff
changeset
|
1403 |
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
|
1404 |
} |
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
|
1405 |
|
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
|
1406 |
group->g.determ.num_adjusts++; |
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
|
1407 |
group->g.determ.adjusts = realloc(group->g.determ.adjusts, group->g.determ.num_adjusts * sizeof(*group->g.determ.adjusts)); |
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
|
1408 |
|
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
|
1409 |
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
|
1410 |
|
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
|
1411 |
/* The first var adjust doesn't have an operation specified, so we set it to add. */ |
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
|
1412 |
adjust->operation = group->g.determ.num_adjusts == 1 ? DSGA_OP_ADD : 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
|
1413 |
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
|
1414 |
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
|
1415 |
|
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
|
1416 |
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
|
1417 |
adjust->shift_num = GB(varadjust, 0, 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
|
1418 |
adjust->type = GB(varadjust, 6, 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
|
1419 |
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
|
1420 |
|
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
|
1421 |
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
|
1422 |
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
|
1423 |
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
|
1424 |
} 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
|
1425 |
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
|
1426 |
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
|
1427 |
} |
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
|
1428 |
|
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
|
1429 |
/* 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
|
1430 |
} 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
|
1431 |
|
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
|
1432 |
group->g.determ.num_ranges = 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
|
1433 |
group->g.determ.ranges = calloc(group->g.determ.num_ranges, sizeof(*group->g.determ.ranges)); |
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
|
1434 |
|
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
|
1435 |
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
|
1436 |
|
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
|
1437 |
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
|
1438 |
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
|
1439 |
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
|
1440 |
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
|
1441 |
} |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1442 |
|
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
|
1443 |
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
|
1444 |
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
|
1445 |
} |
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
|
1446 |
|
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1447 |
/* Randomized Sprite Group */ |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1448 |
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
|
1449 |
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
|
1450 |
{ |
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
|
1451 |
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
|
1452 |
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
|
1453 |
|
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
|
1454 |
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
|
1455 |
|
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1456 |
group = AllocateSpriteGroup(); |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1457 |
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
|
1458 |
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
|
1459 |
|
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
|
1460 |
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
|
1461 |
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
|
1462 |
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
|
1463 |
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
|
1464 |
group->g.random.num_groups = 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
|
1465 |
group->g.random.groups = calloc(group->g.random.num_groups, sizeof(*group->g.random.groups)); |
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
|
1466 |
|
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
|
1467 |
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
|
1468 |
|
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
|
1469 |
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
|
1470 |
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
|
1471 |
} |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1472 |
|
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1473 |
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
|
1474 |
} |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1475 |
|
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
|
1476 |
/* 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
|
1477 |
default: |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1478 |
{ |
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 |
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
|
1480 |
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
|
1481 |
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
|
1482 |
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
|
1483 |
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
|
1484 |
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
|
1485 |
{ |
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
|
1486 |
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
|
1487 |
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
|
1488 |
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
|
1489 |
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
|
1490 |
|
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
|
1491 |
if (_cur_grffile->spriteset_start == 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
|
1492 |
grfmsg(GMS_ERROR, "NewSpriteGroup: No sprite set to work on! Skipping."); |
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
|
1493 |
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
|
1494 |
} |
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
|
1495 |
|
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
|
1496 |
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
|
1497 |
|
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
|
1498 |
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
|
1499 |
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
|
1500 |
|
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
|
1501 |
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
|
1502 |
group->g.real.num_loading = 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
|
1503 |
if (num_loaded > 0) group->g.real.loaded = calloc(num_loaded, sizeof(*group->g.real.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
|
1504 |
if (num_loading > 0) group->g.real.loading = calloc(num_loading, sizeof(*group->g.real.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
|
1505 |
|
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
|
1506 |
DEBUG(grf, 6) ("NewSpriteGroup: New SpriteGroup 0x%02X, %u views, %u loaded, %u 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
|
1507 |
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
|
1508 |
|
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
|
1509 |
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
|
1510 |
uint16 spriteid = 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
|
1511 |
group->g.real.loaded[i] = CreateGroupFromGroupID(setid, type, spriteid, sprites); |
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
|
1512 |
DEBUG(grf, 8) ("NewSpriteGroup: + rg->loaded[%i] = subset %u", i, spriteid); |
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
|
1513 |
} |
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
|
1514 |
|
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
|
1515 |
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
|
1516 |
uint16 spriteid = 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
|
1517 |
group->g.real.loading[i] = CreateGroupFromGroupID(setid, type, spriteid, sprites); |
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
|
1518 |
DEBUG(grf, 8) ("NewSpriteGroup: + rg->loading[%i] = subset %u", i, spriteid); |
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
|
1519 |
} |
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
|
1520 |
|
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
|
1521 |
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
|
1522 |
} |
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
|
1523 |
|
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
|
1524 |
/* Loading of Tile Layout and Production Callback groups would happen here */ |
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
|
1525 |
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
|
1526 |
grfmsg(GMS_WARN, "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
|
1527 |
} |
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
|
1528 |
} |
0 | 1529 |
} |
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
|
1530 |
|
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
|
1531 |
_cur_grffile->spritegroups[setid] = group; |
0 | 1532 |
} |
1533 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1534 |
/* Action 0x03 */ |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1535 |
static void NewVehicle_SpriteGroupMapping(byte *buf, int len) |
0 | 1536 |
{ |
1537 |
/* <03> <feature> <n-id> <ids>... <num-cid> [<cargo-type> <cid>]... <def-cid> |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1538 |
* id-list := [<id>] [id-list] |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1539 |
* cargo-list := <cargo-type> <cid> [cargo-list] |
0 | 1540 |
* |
1541 |
* B feature see action 0 |
|
1542 |
* B n-id bits 0-6: how many IDs this definition applies to |
|
1543 |
* bit 7: if set, this is a wagon override definition (see below) |
|
1544 |
* 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
|
1545 |
* B num-cid number of cargo IDs (sprite group IDs) in this definition |
0 | 1546 |
* can be zero, in that case the def-cid is used always |
1547 |
* 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
|
1548 |
* 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
|
1549 |
* 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
|
1550 |
/* TODO: Bridges, town houses. */ |
0 | 1551 |
/* TODO: Multiple cargo support could be useful even for trains/cars - |
1552 |
* cargo id 0xff is used for showing images in the build train list. */ |
|
1553 |
||
1554 |
static byte *last_engines; |
|
1555 |
static int last_engines_count; |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1556 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1557 |
uint8 idcount; |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1558 |
bool wagover; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1559 |
uint8 cidcount; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1560 |
int c, i; |
0 | 1561 |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1562 |
check_length(len, 7, "VehicleMapSpriteGroup"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1563 |
feature = buf[1]; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1564 |
idcount = buf[2] & 0x7F; |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1565 |
wagover = (buf[2] & 0x80) == 0x80; |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1566 |
check_length(len, 3 + idcount, "VehicleMapSpriteGroup"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1567 |
cidcount = buf[3 + idcount]; |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1568 |
check_length(len, 4 + idcount + cidcount * 3, "VehicleMapSpriteGroup"); |
0 | 1569 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1570 |
DEBUG(grf, 6) ("VehicleMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d.", |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1571 |
feature, idcount, cidcount, wagover); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1572 |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1573 |
if (feature > GSF_STATION) { |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1574 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Unsupported feature %d, skipping.", feature); |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1575 |
return; |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1576 |
} |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1577 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1578 |
|
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
1579 |
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
|
1580 |
// 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
|
1581 |
|
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
|
1582 |
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
|
1583 |
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
|
1584 |
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
|
1585 |
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
|
1586 |
|
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
|
1587 |
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
|
1588 |
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
|
1589 |
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
|
1590 |
|
2516
b11f1229cefd
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1591 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1592 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: 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
|
1593 |
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
|
1594 |
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
|
1595 |
} |
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
|
1596 |
|
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
|
1597 |
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
|
1598 |
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
|
1599 |
|
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
|
1600 |
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
|
1601 |
} |
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
|
1602 |
} |
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
|
1603 |
|
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
|
1604 |
{ |
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
|
1605 |
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
|
1606 |
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
|
1607 |
|
2516
b11f1229cefd
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1608 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1609 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: 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
|
1610 |
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
|
1611 |
return; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1612 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1613 |
|
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
|
1614 |
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
|
1615 |
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
|
1616 |
StationSpec *statspec = _cur_grffile->stations[stid]; |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1617 |
|
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
|
1618 |
statspec->spritegroup[GC_DEFAULT] = _cur_grffile->spritegroups[groupid]; |
3775
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
1619 |
statspec->groundgroup = _cur_grffile->spritegroups[0]; |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1620 |
statspec->grfid = _cur_grffile->grfid; |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1621 |
statspec->localidx = stid; |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1622 |
SetCustomStationSpec(statspec); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1623 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1624 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1625 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1626 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1627 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1628 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1629 |
/* If ``n-id'' (or ``idcount'') is zero, this is a ``feature |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1630 |
* callback''. I have no idea how this works, so we will ignore it for |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1631 |
* now. --octo */ |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1632 |
if (idcount == 0) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1633 |
grfmsg(GMS_NOTICE, "NewMapping: Feature callbacks not implemented yet."); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1634 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1635 |
} |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1636 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1637 |
// FIXME: Tropicset contains things like: |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1638 |
// 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
|
1639 |
// what should we exactly do with that? --pasky |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1640 |
|
3635
59265706435c
(svn r4540) - NewGRF: don't treat integer values as boolean.
peter1138
parents:
3634
diff
changeset
|
1641 |
if (_cur_grffile->spriteset_start == 0 || _cur_grffile->spritegroups == 0) { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1642 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: No sprite set to work on! Skipping."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1643 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1644 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1645 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1646 |
if (!wagover && last_engines_count != idcount) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1647 |
last_engines = realloc(last_engines, idcount); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1648 |
last_engines_count = idcount; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1649 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1650 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1651 |
if (wagover) { |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1652 |
if (last_engines_count == 0) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1653 |
grfmsg(GMS_ERROR, "VehicleMapSpriteGroup: WagonOverride: No engine to do override with."); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1654 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1655 |
} |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1656 |
DEBUG(grf, 6) ("VehicleMapSpriteGroup: WagonOverride: %u engines, %u wagons.", |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1657 |
last_engines_count, idcount); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1658 |
} |
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
|
1659 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1660 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1661 |
for (i = 0; i < idcount; i++) { |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1662 |
uint8 engine_id = buf[3 + i]; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1663 |
uint8 engine = engine_id + _vehshifts[feature]; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1664 |
byte *bp = &buf[4 + idcount]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1665 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1666 |
if (engine_id > _vehcounts[feature]) { |
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1667 |
grfmsg(GMS_ERROR, "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
|
1668 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1669 |
} |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1670 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1671 |
DEBUG(grf, 7) ("VehicleMapSpriteGroup: [%d] Engine %d...", i, engine); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1672 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1673 |
for (c = 0; c < cidcount; c++) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1674 |
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
|
1675 |
uint16 groupid = grf_load_word(&bp); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1676 |
|
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1677 |
DEBUG(grf, 8) ("VehicleMapSpriteGroup: * [%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
|
1678 |
|
2516
b11f1229cefd
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1679 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1680 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: 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
|
1681 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1682 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1683 |
|
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
|
1684 |
if (ctype == GC_INVALID) ctype = GC_PURCHASE; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1685 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1686 |
if (wagover) { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1687 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
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
|
1688 |
SetWagonOverrideSprites(engine, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1689 |
} 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
|
1690 |
SetCustomEngineSprites(engine, ctype, _cur_grffile->spritegroups[groupid]); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1691 |
last_engines[i] = engine; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1692 |
} |
0 | 1693 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1694 |
} |
0 | 1695 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1696 |
{ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1697 |
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
|
1698 |
uint16 groupid = grf_load_word(&bp); |
0 | 1699 |
|
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1700 |
DEBUG(grf, 8) ("-- Default group id 0x%04X", groupid); |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1701 |
|
0 | 1702 |
for (i = 0; i < idcount; i++) { |
1703 |
uint8 engine = buf[3 + i] + _vehshifts[feature]; |
|
1704 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1705 |
// 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
|
1706 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1707 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: 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
|
1708 |
return; |
0 | 1709 |
} |
1710 |
||
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1711 |
if (wagover) { |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1712 |
/* 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
|
1713 |
* this indicates we have a helicopter rotor override. */ |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1714 |
if (feature == GSF_AIRCRAFT && engine == last_engines[i]) { |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1715 |
SetRotorOverrideSprites(engine, _cur_grffile->spritegroups[groupid]); |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1716 |
} else { |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1717 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1718 |
SetWagonOverrideSprites(engine, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1719 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1720 |
} 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
|
1721 |
SetCustomEngineSprites(engine, GC_DEFAULT, _cur_grffile->spritegroups[groupid]); |
3728
1ebf0a7a2492
(svn r4704) - NewGRF: in Action 0x03, set the engine type's GRF ID on the 'default' cargo type, not for each specific cargo. Fixes '(undefined string)' issues, as some engines weren't set properly.
peter1138
parents:
3715
diff
changeset
|
1722 |
SetEngineGRF(engine, _cur_grffile->grfid); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1723 |
last_engines[i] = engine; |
0 | 1724 |
} |
1725 |
} |
|
1726 |
} |
|
1727 |
} |
|
1728 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1729 |
/* Action 0x04 */ |
0 | 1730 |
static void VehicleNewName(byte *buf, int len) |
1731 |
{ |
|
1732 |
/* <04> <veh-type> <language-id> <num-veh> <offset> <data...> |
|
1733 |
* |
|
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1734 |
* B veh-type see action 0 (as 00..07, + 0A |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1735 |
* But IF veh-type = 48, then generic text |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1736 |
* 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
|
1737 |
with up to 64 language. |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1738 |
Otherwise, it is a mapping where set bits have meaning |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1739 |
0 = american, 1 = english, 2 = german, 3 = french, 4 = spanish |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1740 |
Bit 7 set means this is a generic text, not a vehicle one (or else) |
0 | 1741 |
* 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
|
1742 |
* 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
|
1743 |
* Byte : ID of vehicle to change |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1744 |
* Word : ID of string to change/add |
0 | 1745 |
* S data new texts, each of them zero-terminated, after |
1746 |
* which the next name begins. */ |
|
1747 |
/* TODO: No support for changing non-vehicle text. Perhaps we shouldn't |
|
1748 |
* implement it at all, but it could be useful for some "modpacks" |
|
1749 |
* (completely new scenarios changing all graphics and logically also |
|
1750 |
* 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
|
1751 |
* name), not only the original four ones. --pasky |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1752 |
* All of the above are coming. In Time. Some sooner than others :)*/ |
0 | 1753 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1754 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1755 |
uint8 lang; |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1756 |
uint8 num; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1757 |
uint16 id; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1758 |
uint16 endid; |
1329 | 1759 |
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
|
1760 |
bool new_scheme = _cur_grffile->grf_version >= 7; |
0 | 1761 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1762 |
check_length(len, 6, "VehicleNewName"); |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1763 |
buf++; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1764 |
feature = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1765 |
lang = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1766 |
num = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1767 |
id = (lang & 0x80) ? grf_load_word(&buf) : grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1768 |
|
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
|
1769 |
if (feature <= GSF_AIRCRAFT && id < _vehcounts[feature]) { |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1770 |
id += _vehshifts[feature]; |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1771 |
} |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1772 |
endid = id + num; |
0 | 1773 |
|
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1774 |
DEBUG(grf, 6) ("VehicleNewName: 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
|
1775 |
id, endid, feature, lang); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1776 |
|
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1777 |
name = (const char*)buf; /*transfer read value*/ |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1778 |
len -= (lang & 0x80) ? 6 : 5; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1779 |
for (; id < endid && len > 0; id++) { |
2458
c95808cd2ac9
(svn r2984) Use adequate types, this should aid portability a bit
tron
parents:
2456
diff
changeset
|
1780 |
size_t ofs = strlen(name) + 1; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1781 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1782 |
if (ofs < 128) { |
1329 | 1783 |
DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, name); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1784 |
|
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1785 |
switch (feature) { |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1786 |
case GSF_TRAIN: |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1787 |
case GSF_ROAD: |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1788 |
case GSF_SHIP: |
3614 | 1789 |
case GSF_AIRCRAFT: { |
3641
7dc47659e794
(svn r4550) - NewGRF: update string system to new rules: a grf version of less than 6 uses the old scheme, of 7 or more uses the new scheme. (Moving targets, yay...)
peter1138
parents:
3640
diff
changeset
|
1790 |
StringID string = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name); |
3614 | 1791 |
if (id < TOTAL_NUM_ENGINES) SetCustomEngineName(id, string); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1792 |
break; |
3614 | 1793 |
} |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1794 |
|
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
|
1795 |
default: |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1796 |
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
|
1797 |
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
|
1798 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
3761
5ed565b343cf
(svn r4752) - NewGRF: brokenness slipped through...
peter1138
parents:
3760
diff
changeset
|
1799 |
grfmsg(GMS_WARN, "VehicleNewName: 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
|
1800 |
} 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
|
1801 |
StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass; |
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
|
1802 |
SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name)); |
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
|
1803 |
} |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1804 |
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
|
1805 |
|
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
|
1806 |
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
|
1807 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
3761
5ed565b343cf
(svn r4752) - NewGRF: brokenness slipped through...
peter1138
parents:
3760
diff
changeset
|
1808 |
grfmsg(GMS_WARN, "VehicleNewName: 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
|
1809 |
} 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
|
1810 |
_cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name); |
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
|
1811 |
} |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1812 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1813 |
|
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1814 |
default: |
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1815 |
DEBUG(grf, 7) ("VehicleNewName: Unsupported ID (0x%04X)", id); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1816 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1817 |
} |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1818 |
break; |
3642
a247e07fafdf
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
1819 |
|
a247e07fafdf
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
1820 |
#if 0 |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1821 |
case GSF_CANAL : |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1822 |
case GSF_BRIDGE : |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1823 |
case GSF_TOWNHOUSE : |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1824 |
AddGRFString(_cur_spriteid, id, lang, name); |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1825 |
switch (GB(id, 8,8)) { |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1826 |
case 0xC9: /* House name */ |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1827 |
default: |
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1828 |
DEBUG(grf, 7) ("VehicleNewName: Unsupported ID (0x%04X)", id); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1829 |
} |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1830 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1831 |
|
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1832 |
case GSF_INDUSTRIES : |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1833 |
case 0x48 : /* for generic strings */ |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1834 |
AddGRFString(_cur_spriteid, id, lang, name); |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1835 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1836 |
default : |
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1837 |
DEBUG(grf,7) ("VehicleNewName: Unsupported feature (0x%02X)", feature); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1838 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1839 |
#endif |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1840 |
} |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1841 |
} else { |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1842 |
DEBUG(grf, 7) ("VehicleNewName: Too long a name (%d)", ofs); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1843 |
} |
1329 | 1844 |
name += ofs; |
1845 |
len -= ofs; |
|
0 | 1846 |
} |
1847 |
} |
|
1848 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1849 |
/* Action 0x05 */ |
0 | 1850 |
static void GraphicsNew(byte *buf, int len) |
1851 |
{ |
|
1852 |
/* <05> <graphics-type> <num-sprites> <other data...> |
|
1853 |
* |
|
1854 |
* 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
|
1855 |
* E num-sprites How many sprites are in this set? |
0 | 1856 |
* V other data Graphics type specific data. Currently unused. */ |
1857 |
/* TODO */ |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1858 |
|
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1859 |
uint8 type; |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1860 |
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
|
1861 |
SpriteID replace = 0; |
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1862 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1863 |
check_length(len, 2, "GraphicsNew"); |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1864 |
buf++; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1865 |
type = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1866 |
num = grf_load_extended(&buf); |
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1867 |
|
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
|
1868 |
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
|
1869 |
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
|
1870 |
if (num != 112 && num != 240) { |
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
|
1871 |
grfmsg(GMS_WARN, "GraphicsNews: Signal graphics sprite count must be 112 or 240, skipping."); |
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
|
1872 |
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
|
1873 |
} |
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
|
1874 |
_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
|
1875 |
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
|
1876 |
|
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
|
1877 |
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
|
1878 |
if (num != 48) { |
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
|
1879 |
grfmsg(GMS_WARN, "GraphicsNews: Catenary graphics sprite count must be 48, skipping."); |
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
|
1880 |
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
|
1881 |
} |
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
|
1882 |
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
|
1883 |
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
|
1884 |
|
3709
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1885 |
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
|
1886 |
if (num != 74) { |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1887 |
grfmsg(GMS_WARN, "GraphicsNews: Foundation graphics sprite count must be 74, skipping."); |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1888 |
return; |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1889 |
} |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1890 |
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
|
1891 |
break; |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1892 |
|
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1893 |
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
|
1894 |
if (num != 65) { |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1895 |
grfmsg(GMS_WARN, "GraphicsNews: Canal graphics sprite count must be 65, skipping."); |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1896 |
return; |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1897 |
} |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1898 |
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
|
1899 |
break; |
be60bcc248bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1900 |
|
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
|
1901 |
default: |
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
|
1902 |
grfmsg(GMS_NOTICE, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring).\n", |
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
|
1903 |
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
|
1904 |
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
|
1905 |
} |
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
|
1906 |
|
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
|
1907 |
if (replace == 0) { |
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
|
1908 |
grfmsg(GMS_NOTICE, "GraphicsNew: Loading %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, _cur_spriteid); |
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
|
1909 |
} else { |
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
|
1910 |
grfmsg(GMS_NOTICE, "GraphicsNew: Replacing %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, replace); |
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
|
1911 |
} |
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
|
1912 |
|
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
|
1913 |
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
|
1914 |
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
|
1915 |
_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
|
1916 |
} |
0 | 1917 |
} |
1918 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1919 |
/* Action 0x06 */ |
0 | 1920 |
static void CfgApply(byte *buf, int len) |
1921 |
{ |
|
1922 |
/* <06> <param-num> <param-size> <offset> ... <FF> |
|
1923 |
* |
|
1924 |
* B param-num Number of parameter to substitute (First = "zero") |
|
1925 |
* Ignored if that parameter was not specified in newgrf.cfg |
|
1926 |
* B param-size How many bytes to replace. If larger than 4, the |
|
1927 |
* bytes of the following parameter are used. In that |
|
1928 |
* case, nothing is applied unless *all* parameters |
|
1929 |
* were specified. |
|
1930 |
* B offset Offset into data from beginning of next sprite |
|
1931 |
* to place where parameter is to be stored. */ |
|
1932 |
/* TODO */ |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1933 |
grfmsg(GMS_NOTICE, "CfgApply: Ignoring (not implemented).\n"); |
0 | 1934 |
} |
1935 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1936 |
/* Action 0x07 */ |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1937 |
/* Action 0x09 */ |
0 | 1938 |
static void SkipIf(byte *buf, int len) |
1939 |
{ |
|
1940 |
/* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites> |
|
1941 |
* |
|
1942 |
* B param-num |
|
1943 |
* B param-size |
|
1944 |
* B condition-type |
|
1945 |
* V value |
|
1946 |
* B num-sprites */ |
|
1947 |
/* TODO: More params. More condition types. */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1948 |
uint8 param; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1949 |
uint8 paramsize; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1950 |
uint8 condtype; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1951 |
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
|
1952 |
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
|
1953 |
uint32 cond_val = 0; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1954 |
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
|
1955 |
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
|
1956 |
GRFLabel *choice = NULL; |
0 | 1957 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1958 |
check_length(len, 6, "SkipIf"); |
3714
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1959 |
buf++; |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1960 |
param = grf_load_byte(&buf); |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1961 |
paramsize = grf_load_byte(&buf); |
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1962 |
condtype = grf_load_byte(&buf); |
0 | 1963 |
|
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
|
1964 |
if (condtype < 2) { |
1611 | 1965 |
/* 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
|
1966 |
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
|
1967 |
} |
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
|
1968 |
|
1611 | 1969 |
switch (paramsize) { |
1970 |
case 4: cond_val = grf_load_dword(&buf); break; |
|
1971 |
case 2: cond_val = grf_load_word(&buf); break; |
|
1972 |
case 1: cond_val = grf_load_byte(&buf); break; |
|
1973 |
default: break; |
|
1974 |
} |
|
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
|
1975 |
|
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
|
1976 |
switch (param) { |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1977 |
case 0x83: /* current climate, 0=temp, 1=arctic, 2=trop, 3=toyland */ |
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
|
1978 |
param_val = _opt.landscape; |
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
|
1979 |
break; |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1980 |
case 0x84: /* .grf loading stage, 0=initialization, 1=activation */ |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1981 |
param_val = _cur_stage; |
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
|
1982 |
break; |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1983 |
case 0x85: /* TTDPatch flags, only for bit tests */ |
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
|
1984 |
param_val = _ttdpatch_flags[cond_val / 0x20]; |
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
|
1985 |
cond_val %= 0x20; |
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
|
1986 |
break; |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1987 |
case 0x86: /* road traffic side, bit 4 clear=left, set=right */ |
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
|
1988 |
param_val = _opt.road_side << 4; |
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
|
1989 |
break; |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1990 |
case 0x88: { /* see if specified GRFID is active */ |
1611 | 1991 |
param_val = (GetFileByGRFID(cond_val) != NULL); |
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
|
1992 |
} break; |
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
|
1993 |
|
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
|
1994 |
case 0x8B: { /* TTDPatch version */ |
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
|
1995 |
uint major = 2; |
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
|
1996 |
uint minor = 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
|
1997 |
uint revision = 10; // special case: 2.0.1 is 2.0.10 |
3704
cca1c74c0478
(svn r4645) - NewGRF: pretend to be the last alpha version of TTDPatch in our version value.
peter1138
parents:
3695
diff
changeset
|
1998 |
uint build = 73; |
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
|
1999 |
param_val = (major << 24) | (minor << 20) | (revision << 16) | (build * 10); |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
2000 |
break; |
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
|
2001 |
} |
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
|
2002 |
|
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
2003 |
case 0x8D: /* TTD Version, 00=DOS, 01=Windows */ |
2582
5766de903758
(svn r3119) Don't pretend to be the Windows version of TTD all the time. When being asked answer according to _use_dos_palette. (Suggestion by Belugas)
tron
parents:
2549
diff
changeset
|
2004 |
param_val = !_use_dos_palette; |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
2005 |
break; |
420
d3a089648ec3
(svn r617) -newgrf: Support for parameter 0x8E (train Y-pitch in info windows) both setting and testing. This should fix displaced wagons in DBSetXL as reported by DarkVater. (pasky)
darkvater
parents:
419
diff
changeset
|
2006 |
case 0x8E: |
d3a089648ec3
(svn r617) -newgrf: Support for parameter 0x8E (train Y-pitch in info windows) both setting and testing. This should fix displaced wagons in DBSetXL as reported by DarkVater. (pasky)
darkvater
parents:
419
diff
changeset
|
2007 |
param_val = _traininfo_vehicle_pitch; |
d3a089648ec3
(svn r617) -newgrf: Support for parameter 0x8E (train Y-pitch in info windows) both setting and testing. This should fix displaced wagons in DBSetXL as reported by DarkVater. (pasky)
darkvater
parents:
419
diff
changeset
|
2008 |
break; |
2614
0e69ad985358
(svn r3152) - NewGRF: [ 1340189 ] Action 7/9 new value : is it TTDPatch or OpenTTD? (belugas)
peter1138
parents:
2611
diff
changeset
|
2009 |
case 0x9D: /* TTD Platform, 00=TTDPatch, 01=OpenTTD */ |
0e69ad985358
(svn r3152) - NewGRF: [ 1340189 ] Action 7/9 new value : is it TTDPatch or OpenTTD? (belugas)
peter1138
parents:
2611
diff
changeset
|
2010 |
param_val = 1; |
0e69ad985358
(svn r3152) - NewGRF: [ 1340189 ] Action 7/9 new value : is it TTDPatch or OpenTTD? (belugas)
peter1138
parents:
2611
diff
changeset
|
2011 |
break; |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
2012 |
/* TODO */ |
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
2013 |
case 0x8F: /* Track type cost multipliers */ |
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
|
2014 |
default: |
2345 | 2015 |
if (param < 0x80) { |
2016 |
/* Parameter. */ |
|
2017 |
param_val = _cur_grffile->param[param]; |
|
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
|
2018 |
} else { |
2345 | 2019 |
/* In-game variable. */ |
2020 |
grfmsg(GMS_WARN, "Unsupported in-game variable 0x%02X. Ignoring test.", param); |
|
2021 |
return; |
|
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
|
2022 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2023 |
} |
0 | 2024 |
|
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
2025 |
DEBUG(grf, 7) ("Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2026 |
switch (condtype) { |
1606
4ec79f87951a
(svn r2110) - Fix: Fixed test for various flags (e.g. newtrains in usset). result is bool so !! any non-zero values before assigning them to it - they apparently didn't fit. ;-)
pasky
parents:
1542
diff
changeset
|
2027 |
case 0: result = !!(param_val & (1 << cond_val)); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2028 |
break; |
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
|
2029 |
case 1: result = !(param_val & (1 << cond_val)); |
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
|
2030 |
break; |
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
|
2031 |
/* TODO: For the following, make it to work with 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
|
2032 |
case 2: result = (param_val == cond_val); |
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
|
2033 |
break; |
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
|
2034 |
case 3: result = (param_val != cond_val); |
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
|
2035 |
break; |
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
|
2036 |
case 4: result = (param_val < cond_val); |
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
|
2037 |
break; |
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
|
2038 |
case 5: result = (param_val > cond_val); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2039 |
break; |
1606
4ec79f87951a
(svn r2110) - Fix: Fixed test for various flags (e.g. newtrains in usset). result is bool so !! any non-zero values before assigning them to it - they apparently didn't fit. ;-)
pasky
parents:
1542
diff
changeset
|
2040 |
case 6: result = !!param_val; /* GRFID is active (only for param-num=88) */ |
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
|
2041 |
break; |
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
|
2042 |
case 7: result = !param_val; /* GRFID is not active (only for param-num=88) */ |
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
|
2043 |
break; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2044 |
default: |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2045 |
grfmsg(GMS_WARN, "Unsupported test %d. Ignoring.", condtype); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2046 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2047 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2048 |
|
1607
320079c7ac28
(svn r2111) So, result is bool therefore no need for this horrible == 0 thing.
pasky
parents:
1606
diff
changeset
|
2049 |
if (!result) { |
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
|
2050 |
grfmsg(GMS_NOTICE, "Not skipping sprites, test was false."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2051 |
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
|
2052 |
} |
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
|
2053 |
|
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
|
2054 |
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
|
2055 |
|
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
|
2056 |
/* 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
|
2057 |
* 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
|
2058 |
* 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
|
2059 |
* 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
|
2060 |
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
|
2061 |
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
|
2062 |
|
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
|
2063 |
/* 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
|
2064 |
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
|
2065 |
/* 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
|
2066 |
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
|
2067 |
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
|
2068 |
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
|
2069 |
} |
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
|
2070 |
} |
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
|
2071 |
|
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
|
2072 |
if (choice != 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
|
2073 |
grfmsg(GMS_NOTICE, "Jumping to label 0x%0X at line %d, test was true.", choice->label, 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
|
2074 |
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
|
2075 |
_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
|
2076 |
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
|
2077 |
} |
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
|
2078 |
|
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
|
2079 |
grfmsg(GMS_NOTICE, "Skipping %d sprites, test was true.", numsprites); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2080 |
_skip_sprites = numsprites; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2081 |
if (_skip_sprites == 0) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2082 |
/* Zero means there are no sprites to skip, so |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2083 |
* we use -1 to indicate that all further |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2084 |
* sprites should be skipped. */ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2085 |
_skip_sprites = -1; |
0 | 2086 |
} |
2087 |
} |
|
2088 |
||
3640
b73687dd2b62
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2089 |
/* Action 0x08 */ |
0 | 2090 |
static void GRFInfo(byte *buf, int len) |
2091 |
{ |
|
2092 |
/* <08> <version> <grf-id> <name> <info> |
|
2093 |
* |
|
2094 |
* B version newgrf version, currently 06 |
|
2095 |
* 4*B grf-id globally unique ID of this .grf file |
|
2096 |
* S name name of this .grf set |
|
2097 |
* S info string describing the set, and e.g. author and copyright */ |
|
2098 |
/* TODO: Check version. (We should have own versioning done somehow.) */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2099 |
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
|
2100 |
uint32 grfid; |
1329 | 2101 |
const char *name; |
2102 |
const char *info; |
|
0 | 2103 |
|
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
|
2104 |
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
|
2105 |
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
|
2106 |
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
|
2107 |
name = (const char*)buf; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2108 |
info = name + strlen(name) + 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
|
2109 |
|
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
|
2110 |
_cur_grffile->grfid = grfid; |
3640
b73687dd2b62
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2111 |
_cur_grffile->grf_version = 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
|
2112 |
_cur_grffile->flags |= 0x0001; /* set active flag */ |
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
|
2113 |
|
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
|
2114 |
/* Do swap the GRFID for displaying purposes since people expect that */ |
2013
1b80954e9594
(svn r2521) -Codechange: Removed trailing "\n"s from DEBUG statements
celestar
parents:
1968
diff
changeset
|
2115 |
DEBUG(grf, 1) ("[%s] Loaded GRFv%d set %08lx - %s:\n%s", |
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
|
2116 |
_cur_grffile->filename, version, BSWAP32(grfid), name, info); |
0 | 2117 |
} |
2118 |
||
3640
b73687dd2b62
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2119 |
/* Action 0x0A */ |
0 | 2120 |
static void SpriteReplace(byte *buf, int len) |
2121 |
{ |
|
2122 |
/* <0A> <num-sets> <set1> [<set2> ...] |
|
2123 |
* <set>: <num-sprites> <first-sprite> |
|
2124 |
* |
|
2125 |
* B num-sets How many sets of sprites to replace. |
|
2126 |
* Each set: |
|
2127 |
* B num-sprites How many sprites are in this set |
|
2128 |
* 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
|
2129 |
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
|
2130 |
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
|
2131 |
|
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
|
2132 |
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
|
2133 |
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
|
2134 |
|
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
|
2135 |
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
|
2136 |
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
|
2137 |
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
|
2138 |
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
|
2139 |
|
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
|
2140 |
grfmsg(GMS_NOTICE, |
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
|
2141 |
"SpriteReplace: [Set %d] Changing %d sprites, beginning with %d", |
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
|
2142 |
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
|
2143 |
); |
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
|
2144 |
|
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
|
2145 |
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
|
2146 |
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
|
2147 |
_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
|
2148 |
} |
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
|
2149 |
} |
0 | 2150 |
} |
2151 |
||
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2152 |
/* Action 0x0B */ |
0 | 2153 |
static void GRFError(byte *buf, int len) |
2154 |
{ |
|
2155 |
/* <0B> <severity> <language-id> <message-id> [<message...> 00] [<data...>] 00 [<parnum>] |
|
2156 |
* |
|
2157 |
* B severity 00: notice, contine loading grf file |
|
2158 |
* 01: warning, continue loading grf file |
|
2159 |
* 02: error, but continue loading grf file, and attempt |
|
2160 |
* loading grf again when loading or starting next game |
|
2161 |
* 03: error, abort loading and prevent loading again in |
|
2162 |
* the future (only when restarting the patch) |
|
2163 |
* B language-id see action 4, use 1F for built-in error messages |
|
2164 |
* B message-id message to show, see below |
|
2165 |
* S message for custom messages (message-id FF), text of the message |
|
2166 |
* not present for built-in messages. |
|
2167 |
* V data additional data for built-in (or custom) messages |
|
2168 |
* B parnum see action 6, only used with built-in message 03 */ |
|
2169 |
/* TODO: For now we just show the message, sometimes incomplete and never translated. */ |
|
2170 |
||
2171 |
static const char * const msgstr[4] = { |
|
2172 |
"Requires at least pseudo-TTDPatch version %s.", |
|
2173 |
"This file is for %s version of TTD.", |
|
2174 |
"Designed to be used with %s.", |
|
2175 |
"Invalid parameter %s.", |
|
2176 |
}; |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2177 |
uint8 severity; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2178 |
uint8 msgid; |
0 | 2179 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2180 |
check_length(len, 6, "GRFError"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2181 |
severity = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2182 |
msgid = buf[3]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2183 |
|
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2184 |
// Undocumented TTDPatch feature. |
3588
a1adf8a40756
(svn r4474) - NewGRF: Skip non-fatal errors when not in stage 2.
peter1138
parents:
3577
diff
changeset
|
2185 |
if ((severity & 0x80) == 0 && _cur_stage < 2) { |
a1adf8a40756
(svn r4474) - NewGRF: Skip non-fatal errors when not in stage 2.
peter1138
parents:
3577
diff
changeset
|
2186 |
DEBUG(grf, 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
|
2187 |
return; |
3588
a1adf8a40756
(svn r4474) - NewGRF: Skip non-fatal errors when not in stage 2.
peter1138
parents:
3577
diff
changeset
|
2188 |
} |
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2189 |
severity &= 0x7F; |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2190 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
2191 |
if (msgid == 0xFF) { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2192 |
grfmsg(severity, "%s", buf+4); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2193 |
} else { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2194 |
grfmsg(severity, msgstr[msgid], buf+4); |
0 | 2195 |
} |
2196 |
} |
|
2197 |
||
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2198 |
/* Action 0x0C */ |
0 | 2199 |
static void GRFComment(byte *buf, int len) |
2200 |
{ |
|
2201 |
/* <0C> [<ignored...>] |
|
2202 |
* |
|
2203 |
* 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
|
2204 |
|
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
|
2205 |
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
|
2206 |
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
|
2207 |
|
3571 | 2208 |
ttd_strlcpy(comment, (char*)(buf + 1), minu(sizeof(comment), len)); |
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
|
2209 |
grfmsg(GMS_NOTICE, "GRFComment: %s", comment); |
0 | 2210 |
} |
2211 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2212 |
/* Action 0x0D */ |
0 | 2213 |
static void ParamSet(byte *buf, int len) |
2214 |
{ |
|
2215 |
/* <0D> <target> <operation> <source1> <source2> [<data>] |
|
2216 |
* |
|
2217 |
* B target parameter number where result is stored |
|
2218 |
* B operation operation to perform, see below |
|
2219 |
* B source1 first source operand |
|
2220 |
* B source2 second source operand |
|
2221 |
* D data data to use in the calculation, not necessary |
|
2222 |
* if both source1 and source2 refer to actual parameters |
|
2223 |
* |
|
2224 |
* Operations |
|
2225 |
* 00 Set parameter equal to source1 |
|
2226 |
* 01 Addition, source1 + source2 |
|
2227 |
* 02 Subtraction, source1 - source2 |
|
2228 |
* 03 Unsigned multiplication, source1 * source2 (both unsigned) |
|
2229 |
* 04 Signed multiplication, source1 * source2 (both signed) |
|
2230 |
* 05 Unsigned bit shift, source1 by source2 (source2 taken to be a |
|
2231 |
* signed quantity; left shift if positive and right shift if |
|
2232 |
* negative, source1 is unsigned) |
|
2233 |
* 06 Signed bit shift, source1 by source2 |
|
2234 |
* (source2 like in 05, and source1 as well) |
|
2235 |
*/ |
|
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
|
2236 |
|
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
|
2237 |
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
|
2238 |
byte oper; |
2345 | 2239 |
uint32 src1; |
2240 |
uint32 src2; |
|
2241 |
uint32 data = 0; |
|
2242 |
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
|
2243 |
|
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
|
2244 |
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
|
2245 |
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
|
2246 |
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
|
2247 |
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
|
2248 |
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
|
2249 |
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
|
2250 |
|
2345 | 2251 |
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
|
2252 |
|
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
|
2253 |
/* 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
|
2254 |
* 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
|
2255 |
* 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
|
2256 |
* - 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
|
2257 |
* - 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
|
2258 |
* 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
|
2259 |
if (oper & 0x80) { |
2345 | 2260 |
if (_cur_grffile->param_end < 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
|
2261 |
oper &= 0x7F; |
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
|
2262 |
else |
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
|
2263 |
return; |
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
|
2264 |
} |
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
|
2265 |
|
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
|
2266 |
/* The source1 and source2 operands refer to the grf parameter number |
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
|
2267 |
* like in action 6 and 7. In addition, they can refer to the special |
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
|
2268 |
* variables available in action 7, or they can be FF to use the 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
|
2269 |
* of <data>. If referring to parameters that are undefined, a 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
|
2270 |
* of 0 is used 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
|
2271 |
if (src1 == 0xFF) { |
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
|
2272 |
src1 = data; |
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
|
2273 |
} else { |
2345 | 2274 |
src1 = _cur_grffile->param_end >= src1 ? _cur_grffile->param[src1] : 0; |
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
|
2275 |
} |
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
|
2276 |
|
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
|
2277 |
if (src2 == 0xFF) { |
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
|
2278 |
src2 = data; |
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
|
2279 |
} else { |
2345 | 2280 |
src2 = _cur_grffile->param_end >= src2 ? _cur_grffile->param[src2] : 0; |
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
|
2281 |
} |
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
|
2282 |
|
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
|
2283 |
/* 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
|
2284 |
* 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
|
2285 |
* 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
|
2286 |
* 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
|
2287 |
* 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
|
2288 |
|
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
|
2289 |
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
|
2290 |
case 0x00: |
2345 | 2291 |
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
|
2292 |
break; |
2345 | 2293 |
|
2294 |
case 0x01: |
|
2295 |
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
|
2296 |
break; |
2345 | 2297 |
|
2298 |
case 0x02: |
|
2299 |
res = src1 - src2; |
|
2300 |
break; |
|
2301 |
||
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
|
2302 |
case 0x03: |
2345 | 2303 |
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
|
2304 |
break; |
2345 | 2305 |
|
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
|
2306 |
case 0x04: |
2345 | 2307 |
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
|
2308 |
break; |
2345 | 2309 |
|
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
|
2310 |
case 0x05: |
2345 | 2311 |
if ((int32)src2 < 0) |
2312 |
res = 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
|
2313 |
else |
2345 | 2314 |
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
|
2315 |
break; |
2345 | 2316 |
|
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
|
2317 |
case 0x06: |
2345 | 2318 |
if ((int32)src2 < 0) |
2319 |
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
|
2320 |
else |
2345 | 2321 |
res = (int32)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
|
2322 |
break; |
2345 | 2323 |
|
2442
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2324 |
case 0x07: /* Bitwise AND */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2325 |
res = src1 & src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2326 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2327 |
|
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2328 |
case 0x08: /* Bitwise OR */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2329 |
res = src1 | src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2330 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2331 |
|
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2332 |
case 0x09: /* Unsigned division */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2333 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2334 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2335 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2336 |
res = src1 / src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2337 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2338 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2339 |
|
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2340 |
case 0x0A: /* Signed divison */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2341 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2342 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2343 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2344 |
res = (int32)src1 / (int32)src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2345 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2346 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2347 |
|
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2348 |
case 0x0B: /* Unsigned modulo */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2349 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2350 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2351 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2352 |
res = src1 % src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2353 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2354 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2355 |
|
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2356 |
case 0x0C: /* Signed modulo */ |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2357 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2358 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2359 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2360 |
res = (int32)src1 % (int32)src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2361 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2362 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2363 |
|
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
|
2364 |
default: |
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
|
2365 |
grfmsg(GMS_ERROR, "ParamSet: Unknown operation %d, skipping.", oper); |
2345 | 2366 |
return; |
2367 |
} |
|
2368 |
||
2369 |
switch (target) { |
|
2370 |
case 0x8E: // Y-Offset for train sprites |
|
2371 |
_traininfo_vehicle_pitch = res; |
|
2372 |
break; |
|
2373 |
||
2374 |
// TODO implement |
|
2375 |
case 0x8F: // Rail track type cost factors |
|
2376 |
case 0x93: // Tile refresh offset to left |
|
2377 |
case 0x94: // Tile refresh offset to right |
|
2378 |
case 0x95: // Tile refresh offset upwards |
|
2379 |
case 0x96: // Tile refresh offset downwards |
|
2380 |
case 0x97: // Snow line height |
|
2381 |
case 0x99: // Global ID offset |
|
2382 |
DEBUG(grf, 7) ("ParamSet: Skipping unimplemented target 0x%02X", target); |
|
2383 |
break; |
|
2384 |
||
2385 |
default: |
|
2386 |
if (target < 0x80) { |
|
2387 |
_cur_grffile->param[target] = res; |
|
2388 |
if (target + 1U > _cur_grffile->param_end) _cur_grffile->param_end = target + 1; |
|
2389 |
} else { |
|
2390 |
DEBUG(grf, 7) ("ParamSet: Skipping unknown target 0x%02X", target); |
|
2391 |
} |
|
2392 |
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
|
2393 |
} |
0 | 2394 |
} |
2395 |
||
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2396 |
/* Action 0x0E */ |
0 | 2397 |
static void GRFInhibit(byte *buf, int len) |
2398 |
{ |
|
2399 |
/* <0E> <num> <grfids...> |
|
2400 |
* |
|
2401 |
* B num Number of GRFIDs that follow |
|
2402 |
* 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
|
2403 |
|
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
|
2404 |
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
|
2405 |
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
|
2406 |
|
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
|
2407 |
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
|
2408 |
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
|
2409 |
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
|
2410 |
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
|
2411 |
|
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
|
2412 |
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
|
2413 |
uint32 grfid = grf_load_dword(&buf); |
1477 | 2414 |
GRFFile *file = GetFileByGRFID(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
|
2415 |
|
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
|
2416 |
/* Unset activation flag */ |
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
|
2417 |
if (file != NULL) { |
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
|
2418 |
grfmsg(GMS_NOTICE, "GRFInhibit: Deactivating file ``%s''", file->filename); |
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
|
2419 |
file->flags &= 0xFFFE; |
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
|
2420 |
} |
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
|
2421 |
} |
0 | 2422 |
} |
2423 |
||
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2424 |
/* 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
|
2425 |
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
|
2426 |
{ |
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
|
2427 |
/* <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
|
2428 |
* |
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
|
2429 |
* 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
|
2430 |
* 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
|
2431 |
|
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
|
2432 |
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
|
2433 |
|
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
|
2434 |
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
|
2435 |
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
|
2436 |
|
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
|
2437 |
label = malloc(sizeof(*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
|
2438 |
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
|
2439 |
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
|
2440 |
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
|
2441 |
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
|
2442 |
|
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
|
2443 |
/* 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
|
2444 |
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
|
2445 |
_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
|
2446 |
} 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
|
2447 |
/* 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
|
2448 |
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
|
2449 |
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
|
2450 |
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
|
2451 |
} |
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 |
|
3630
0f7828d892ae
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
2453 |
grfmsg(GMS_NOTICE, "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
|
2454 |
} |
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
|
2455 |
|
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
|
2456 |
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
|
2457 |
{ |
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
|
2458 |
/* FIXME: We should rather reflect reality in _ttdpatch_flags[]. */ |
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
|
2459 |
|
2628
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2460 |
_ttdpatch_flags[0] = (_patches.always_small_airport ? (1 << 0x0C) : 0) /* keepsmallairport */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2461 |
| (1 << 0x0E) /* largestations */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2462 |
| (_patches.longbridges ? (1 << 0x0F) : 0) /* longbridges */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2463 |
| (1 << 0x12) /* presignals */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2464 |
| (1 << 0x13) /* extpresignals */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2465 |
| (_patches.never_expire_vehicles ? (1 << 0x16) : 0) /* enginespersist */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2466 |
| (1 << 0x1B); /* multihead */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2467 |
_ttdpatch_flags[1] = (_patches.mammoth_trains ? (1 << 0x08) : 0) /* mammothtrains */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2468 |
| (1 << 0x09) /* trainrefit */ |
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2469 |
| (1 << 0x14) /* bridgespeedlimits */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2470 |
| (1 << 0x16) /* eternalgame */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2471 |
| (1 << 0x17) /* newtrains */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2472 |
| (1 << 0x18) /* newrvs */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2473 |
| (1 << 0x19) /* newships */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2474 |
| (1 << 0x1A) /* newplanes */ |
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
|
2475 |
| (_patches.signal_side ? (1 << 0x1B) : 0) /* signalsontrafficside */ |
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
|
2476 |
| (1 << 0x1C); /* electrifiedrailway */ |
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
|
2477 |
|
2628
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2478 |
_ttdpatch_flags[2] = (_patches.build_on_slopes ? (1 << 0x0D) : 0) /* buildonslopes */ |
3777
bffc9d12cfba
(svn r4769) - Newstations: add newstations ttdpatch flag
peter1138
parents:
3775
diff
changeset
|
2479 |
| (1 << 0x12) /* newstations */ |
2628
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2480 |
| (_patches.build_on_slopes ? (1 << 0x15) : 0) /* buildoncoasts */ |
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2481 |
| (1 << 0x16) /* canals */ |
2456
93041d70867b
(svn r2982) Newgrf: Added patch option for wagon speed limits. This is enabled by default.
peter1138
parents:
2445
diff
changeset
|
2482 |
| (1 << 0x17) /* newstartyear */ |
2628
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2483 |
| (1 << 0x1A) /* newbridges */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2484 |
| (_patches.wagon_speed_limits ? (1 << 0x1D) : 0); /* wagonspeedlimits */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2485 |
_ttdpatch_flags[3] = (1 << 0x03) /* pathbasedsignalling */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2486 |
| (1 << 0x0C) /* enhancemultiplayer */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2487 |
| (1 << 0x0E) /* irregularstations */ |
396166c3a2a5
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2488 |
| (1 << 0x10); /* autoreplace */ |
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
|
2489 |
} |
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
|
2490 |
|
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2491 |
static void ResetCustomStations(void) |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2492 |
{ |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2493 |
StationSpec *statspec; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2494 |
GRFFile *file; |
2627
8c964f74bd7b
(svn r3169) Little bit of coding style fixing, and change from value to lengthof()
peter1138
parents:
2625
diff
changeset
|
2495 |
uint i; |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2496 |
uint t; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2497 |
|
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2498 |
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
|
2499 |
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
|
2500 |
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
|
2501 |
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
|
2502 |
statspec = file->stations[i]; |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2503 |
|
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2504 |
/* 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
|
2505 |
if (!statspec->copied_renderdata) { |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2506 |
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
|
2507 |
free((void*)statspec->renderdata[t].seq); |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2508 |
} |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2509 |
free(statspec->renderdata); |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2510 |
} |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2511 |
|
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2512 |
// TODO: Release platforms and layouts |
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
|
2513 |
|
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
|
2514 |
/* 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
|
2515 |
free(statspec); |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2516 |
} |
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
|
2517 |
|
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
|
2518 |
/* 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
|
2519 |
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
|
2520 |
file->stations = NULL; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2521 |
} |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2522 |
} |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2523 |
|
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
2524 |
/** |
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
|
2525 |
* 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
|
2526 |
* 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
|
2527 |
*/ |
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
|
2528 |
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
|
2529 |
{ |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2530 |
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
|
2531 |
|
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2532 |
CleanUpStrings(); |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2533 |
|
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
|
2534 |
// 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
|
2535 |
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
|
2536 |
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
|
2537 |
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
|
2538 |
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
|
2539 |
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
|
2540 |
|
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
|
2541 |
// 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
|
2542 |
// 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
|
2543 |
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
|
2544 |
if (_bridge[i].sprite_table != NULL) { |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2545 |
uint j; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2546 |
|
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2547 |
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
|
2548 |
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
|
2549 |
} |
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
|
2550 |
} |
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
|
2551 |
memcpy(&_bridge, &orig_bridge, sizeof(_bridge)); |
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
2552 |
|
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2553 |
// Reset refit/cargo class data |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2554 |
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
|
2555 |
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
|
2556 |
|
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
2557 |
// Unload sprite group data |
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
2558 |
UnloadWagonOverrides(); |
3695
aae28fa7190e
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
2559 |
UnloadRotorOverrideSprites(); |
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
2560 |
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
|
2561 |
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
|
2562 |
ResetEngineListOrder(); |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
2563 |
|
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
2564 |
// Reset price base data |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
2565 |
ResetPriceBaseMultipliers(); |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2566 |
|
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2567 |
// Reset station classes |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2568 |
ResetStationClasses(); |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2569 |
ResetCustomStations(); |
2812
f250489941f9
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
2570 |
|
f250489941f9
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
2571 |
// 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
|
2572 |
AddTypeToEngines(); |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2573 |
|
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2574 |
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
|
2575 |
} |
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
|
2576 |
|
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
|
2577 |
/** 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
|
2578 |
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
|
2579 |
{ |
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
|
2580 |
/* 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
|
2581 |
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
|
2582 |
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
|
2583 |
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
|
2584 |
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
|
2585 |
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
|
2586 |
} |
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
|
2587 |
_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
|
2588 |
|
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2589 |
/* 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
|
2590 |
free(_cur_grffile->spritegroups); |
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2591 |
_cur_grffile->spritegroups = NULL; |
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2592 |
_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
|
2593 |
} |
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
|
2594 |
|
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
|
2595 |
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
|
2596 |
{ |
1477 | 2597 |
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
|
2598 |
|
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
|
2599 |
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
|
2600 |
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
|
2601 |
/* 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
|
2602 |
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
|
2603 |
_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
|
2604 |
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
|
2605 |
} |
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
|
2606 |
|
1477 | 2607 |
newfile = calloc(1, sizeof(*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
|
2608 |
|
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2609 |
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
|
2610 |
|
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
|
2611 |
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
|
2612 |
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
|
2613 |
|
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
|
2614 |
/* 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
|
2615 |
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
|
2616 |
newfile->param_end = config->num_params; |
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
|
2617 |
memcpy(newfile->param, config->param, 0x80 * sizeof(newfile->param[0])); |
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
|
2618 |
|
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
|
2619 |
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
|
2620 |
_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
|
2621 |
_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
|
2622 |
} 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
|
2623 |
_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
|
2624 |
_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
|
2625 |
} |
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
|
2626 |
} |
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
|
2627 |
|
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2628 |
/** |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2629 |
* 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
|
2630 |
*/ |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2631 |
static void CalculateRefitMasks(void) |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2632 |
{ |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2633 |
EngineID engine; |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2634 |
|
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2635 |
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
|
2636 |
uint32 mask = 0; |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2637 |
uint32 not_mask = 0; |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2638 |
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
|
2639 |
byte i; |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2640 |
|
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2641 |
if (cargo_allowed[engine] != 0) { |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2642 |
// 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
|
2643 |
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
|
2644 |
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
|
2645 |
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
|
2646 |
} |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2647 |
} else { |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2648 |
// 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
|
2649 |
if (xor_mask == 0 && ( |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2650 |
GetEngine(engine)->type != VEH_Train || ( |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2651 |
RailVehInfo(engine)->capacity != 0 && |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2652 |
!(RailVehInfo(engine)->flags & RVI_WAGON) |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2653 |
) |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2654 |
)) { |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2655 |
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
|
2656 |
} |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2657 |
} |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2658 |
_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
|
2659 |
} |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2660 |
} |
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
|
2661 |
|
0 | 2662 |
/* Here we perform initial decoding of some special sprites (as are they |
2663 |
* 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
|
2664 |
* partial implementation yet). */ |
0 | 2665 |
/* XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by |
2666 |
* a crafted invalid GRF file. We should tell that to the user somehow, or |
|
2667 |
* better make this more robust in the future. */ |
|
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2935
diff
changeset
|
2668 |
static void DecodeSpecialSprite(uint num, uint stage) |
0 | 2669 |
{ |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
2670 |
/* 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
|
2671 |
* 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
|
2672 |
* 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
|
2673 |
* "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
|
2674 |
* 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
|
2675 |
* 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
|
2676 |
* 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
|
2677 |
* 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
|
2678 |
* --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
|
2679 |
/* 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
|
2680 |
* 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
|
2681 |
* In other stages we skip action 0x10 since it's already dealt with. */ |
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
|
2682 |
static const uint32 action_mask[] = {0x10000, 0x0000FB40, 0x0000FFBF}; |
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
|
2683 |
|
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
|
2684 |
static const SpecialSpriteHandler handlers[] = { |
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
|
2685 |
/* 0x00 */ VehicleChangeInfo, |
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
|
2686 |
/* 0x01 */ NewSpriteSet, |
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
|
2687 |
/* 0x02 */ NewSpriteGroup, |
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
|
2688 |
/* 0x03 */ NewVehicle_SpriteGroupMapping, |
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
|
2689 |
/* 0x04 */ VehicleNewName, |
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
|
2690 |
/* 0x05 */ GraphicsNew, |
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
|
2691 |
/* 0x06 */ CfgApply, |
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
|
2692 |
/* 0x07 */ SkipIf, |
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
|
2693 |
/* 0x08 */ GRFInfo, |
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
|
2694 |
/* 0x09 */ SkipIf, |
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
|
2695 |
/* 0x0A */ SpriteReplace, |
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
|
2696 |
/* 0x0B */ GRFError, |
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
|
2697 |
/* 0x0C */ GRFComment, |
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
|
2698 |
/* 0x0D */ ParamSet, |
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
|
2699 |
/* 0x0E */ GRFInhibit, |
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
|
2700 |
/* 0x0F */ NULL, // TODO implement |
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
|
2701 |
/* 0x10 */ DefineGotoLabel, |
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
|
2702 |
}; |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
2703 |
|
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
|
2704 |
byte* buf = malloc(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
|
2705 |
byte action; |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
2706 |
|
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
|
2707 |
if (buf == NULL) error("DecodeSpecialSprite: Could not allocate memory"); |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
2708 |
|
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
|
2709 |
FioReadBlock(buf, 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
|
2710 |
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
|
2711 |
|
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
|
2712 |
if (action >= lengthof(handlers)) { |
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
|
2713 |
DEBUG(grf, 7) ("Skipping unknown action 0x%02X", action); |
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
|
2714 |
} else if (!HASBIT(action_mask[stage], action)) { |
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
|
2715 |
DEBUG(grf, 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
|
2716 |
} else if (handlers[action] == NULL) { |
964bd8fe3ce2
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
2717 |
DEBUG(grf, 7) ("Skipping unsupported Action 0x%02X", action); |
964bd8fe3ce2
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
2718 |
} else { |
964bd8fe3ce2
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
2719 |
DEBUG(grf, 7) ("Handling action 0x%02X in stage %d", action, stage); |
964bd8fe3ce2
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
2720 |
handlers[action](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
|
2721 |
} |
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
|
2722 |
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
|
2723 |
} |
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
|
2724 |
|
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
|
2725 |
|
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
|
2726 |
static void LoadNewGRFFile(const char* filename, uint file_index, uint 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
|
2727 |
{ |
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
|
2728 |
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
|
2729 |
|
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
|
2730 |
/* 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
|
2731 |
* 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
|
2732 |
* 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
|
2733 |
* 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
|
2734 |
* 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
|
2735 |
* |
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
|
2736 |
* 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
|
2737 |
* 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
|
2738 |
* processed once at initialization. */ |
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
|
2739 |
if (stage != 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
|
2740 |
_cur_grffile = GetFileByFilename(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
|
2741 |
if (_cur_grffile == NULL) error("File ``%s'' lost in cache.\n", filename); |
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
|
2742 |
if (stage > 1 && !(_cur_grffile->flags & 0x0001)) 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
|
2743 |
} |
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
|
2744 |
|
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
|
2745 |
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
|
2746 |
_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
|
2747 |
|
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
|
2748 |
DEBUG(grf, 7) ("Reading NewGRF-file '%s'", 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
|
2749 |
|
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
|
2750 |
/* 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
|
2751 |
* 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
|
2752 |
* 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
|
2753 |
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
|
2754 |
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
|
2755 |
} 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
|
2756 |
error("Custom .grf has invalid format."); |
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
|
2757 |
} |
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
|
2758 |
|
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
|
2759 |
_skip_sprites = 0; // XXX |
3557
5d12a78ce141
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
2760 |
_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
|
2761 |
|
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
|
2762 |
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
|
2763 |
byte type = FioReadByte(); |
3557
5d12a78ce141
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
2764 |
_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
|
2765 |
|
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
|
2766 |
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
|
2767 |
if (_skip_sprites == 0) { |
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2935
diff
changeset
|
2768 |
DecodeSpecialSprite(num, 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
|
2769 |
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
|
2770 |
} 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
|
2771 |
FioSkipBytes(num); |
1611 | 2772 |
} |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
2773 |
} else { |
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
|
2774 |
if (_skip_sprites == 0) DEBUG(grf, 7) ("Skipping unexpected 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
|
2775 |
|
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
|
2776 |
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
|
2777 |
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
|
2778 |
|
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
|
2779 |
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
|
2780 |
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
|
2781 |
} 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
|
2782 |
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
|
2783 |
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
|
2784 |
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
|
2785 |
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
|
2786 |
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
|
2787 |
} 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
|
2788 |
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
|
2789 |
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
|
2790 |
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
|
2791 |
} |
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
|
2792 |
} |
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
|
2793 |
} |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
2794 |
} |
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
|
2795 |
|
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
|
2796 |
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
|
2797 |
} |
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
|
2798 |
} |
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
|
2799 |
|
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
|
2800 |
|
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
|
2801 |
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
|
2802 |
{ |
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
|
2803 |
uint 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
|
2804 |
|
2930
a3bfaa5a9222
(svn r3486) - NewGRF fix: Always reinitialize the ttdpatch flags as patch settings may have changed.
peter1138
parents:
2895
diff
changeset
|
2805 |
InitializeGRFSpecial(); |
0 | 2806 |
|
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
|
2807 |
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
|
2808 |
|
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
|
2809 |
/* 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
|
2810 |
* 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
|
2811 |
* and load information from it. */ |
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
|
2812 |
_custom_sprites_base = load_index; |
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
|
2813 |
for (stage = 0; stage <= 2; 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
|
2814 |
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
|
2815 |
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
|
2816 |
|
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
|
2817 |
_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
|
2818 |
_cur_spriteid = load_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
|
2819 |
for (c = _first_grfconfig; c != NULL; c = c->next) { |
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
|
2820 |
if (!FiosCheckFileExists(c->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
|
2821 |
// TODO: usrerror() |
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
|
2822 |
error("NewGRF file missing: %s", c->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
|
2823 |
} |
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
|
2824 |
|
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
|
2825 |
if (stage == 0) InitNewGRFFile(c, _cur_spriteid); |
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
|
2826 |
LoadNewGRFFile(c->filename, slot++, 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
|
2827 |
if (stage == 2) ClearTemporaryNewGRFData(); |
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
|
2828 |
DEBUG(spritecache, 2) ("Currently %i sprites are loaded", load_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
|
2829 |
} |
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
|
2830 |
} |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2831 |
|
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2832 |
// 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
|
2833 |
CalculateRefitMasks(); |
0 | 2834 |
} |