author | miham |
Wed, 17 Aug 2005 12:30:07 +0000 | |
changeset 2349 | df02d0ffb588 |
parent 2346 | 7e88b66abdbd |
child 2400 | 0b51bc385750 |
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" |
0 | 18 |
|
19 |
/* TTDPatch extended GRF format codec |
|
20 |
* (c) Petr Baudis 2004 (GPL'd) |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
21 |
* 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
|
22 |
* |
0 | 23 |
* Contains portions of documentation by TTDPatch team. |
24 |
* Thanks especially to Josef Drexler for the documentation as well as a lot |
|
25 |
* of help at #tycoon. Also thanks to Michael Blunck for is GRF files which |
|
26 |
* served as subject to the initial testing of this codec. */ |
|
27 |
||
455 | 28 |
|
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
|
29 |
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
|
30 |
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
|
31 |
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
|
32 |
extern int _traininfo_vehicle_pitch; |
0 | 33 |
|
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
|
34 |
static GRFFile *_cur_grffile; |
1477 | 35 |
GRFFile *_first_grffile; |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
455
diff
changeset
|
36 |
int _grffile_count; |
0 | 37 |
static int _cur_spriteid; |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
38 |
static int _cur_stage; |
0 | 39 |
|
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
|
40 |
/* 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
|
41 |
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
|
42 |
|
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
|
43 |
|
1477 | 44 |
typedef enum grfspec_feature { |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
45 |
GSF_TRAIN, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
46 |
GSF_ROAD, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
47 |
GSF_SHIP, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
48 |
GSF_AIRCRAFT, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
49 |
GSF_STATION, |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
50 |
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
|
51 |
GSF_TOWNHOUSE, |
1477 | 52 |
} grfspec_feature; |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
53 |
|
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
54 |
|
0 | 55 |
typedef void (*SpecialSpriteHandler)(byte *buf, int len); |
56 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
57 |
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
|
58 |
/* GSF_TRAIN */ NUM_TRAIN_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
59 |
/* GSF_ROAD */ NUM_ROAD_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
60 |
/* GSF_SHIP */ NUM_SHIP_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
61 |
/* GSF_AIRCRAFT */ NUM_AIRCRAFT_ENGINES |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
62 |
}; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
63 |
|
0 | 64 |
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
|
65 |
/* GSF_TRAIN */ 0, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
66 |
/* GSF_ROAD */ ROAD_ENGINES_INDEX, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
67 |
/* GSF_SHIP */ SHIP_ENGINES_INDEX, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
68 |
/* GSF_AIRCRAFT */ AIRCRAFT_ENGINES_INDEX, |
0 | 69 |
}; |
70 |
||
71 |
||
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
72 |
/* Debugging messages policy: |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
73 |
* |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
74 |
* 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
|
75 |
* (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
|
76 |
* |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
77 |
* 0..2 - dedicated to grfmsg() |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
78 |
* 3 |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
79 |
* 4 |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
80 |
* 5 |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
81 |
* 6 - action handler entry reporting - one per action |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
82 |
* 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
|
83 |
* 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
|
84 |
* 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
|
85 |
*/ |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
86 |
|
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
87 |
|
1477 | 88 |
typedef enum grfmsg_severity { |
0 | 89 |
GMS_NOTICE, |
90 |
GMS_WARN, |
|
91 |
GMS_ERROR, |
|
92 |
GMS_FATAL, |
|
1477 | 93 |
} grfmsg_severity; |
0 | 94 |
|
1477 | 95 |
static void CDECL grfmsg(grfmsg_severity severity, const char *str, ...) |
0 | 96 |
{ |
1477 | 97 |
static const char* const severitystr[] = { |
98 |
"Notice", |
|
99 |
"Warning", |
|
100 |
"Error", |
|
101 |
"Fatal" |
|
102 |
}; |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
103 |
int export_severity = 0; |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
51
diff
changeset
|
104 |
char buf[1024]; |
0 | 105 |
va_list va; |
106 |
||
107 |
va_start(va, str); |
|
1477 | 108 |
vsnprintf(buf, sizeof(buf), str, va); |
0 | 109 |
va_end(va); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
110 |
|
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
111 |
export_severity = 2 - (severity == GMS_FATAL ? 2 : severity); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
112 |
DEBUG(grf, export_severity) ("[%s][%s] %s", _cur_grffile->filename, severitystr[severity], buf); |
0 | 113 |
} |
114 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
115 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
116 |
#define check_length(real, wanted, where) \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
117 |
do { \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
118 |
if (real < wanted) { \ |
1439
c4b08bda7a43
(svn r1943) Show the sprite ID in the check_length() error message. Also show the correct sprite ID in the spriteskip notice.
pasky
parents:
1329
diff
changeset
|
119 |
grfmsg(GMS_ERROR, "%s/%d: Invalid special sprite length %d (expected %d)!", \ |
c4b08bda7a43
(svn r1943) Show the sprite ID in the check_length() error message. Also show the correct sprite ID in the spriteskip notice.
pasky
parents:
1329
diff
changeset
|
120 |
where, _cur_spriteid - _cur_grffile->sprite_offset, real, wanted); \ |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
121 |
return; \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
122 |
} \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
123 |
} while (0) |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
124 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
125 |
|
500
ef288590e096
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
490
diff
changeset
|
126 |
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
|
127 |
{ |
0 | 128 |
return *(*buf)++; |
129 |
} |
|
130 |
||
131 |
static uint16 grf_load_word(byte **buf) |
|
132 |
{ |
|
133 |
uint16 val; |
|
134 |
byte *p = *buf; |
|
135 |
val = p[0]; |
|
136 |
val |= p[1] << 8; |
|
137 |
*buf = p + 2; |
|
138 |
return val; |
|
139 |
} |
|
140 |
||
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
141 |
static uint16 grf_load_extended(byte** buf) |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
142 |
{ |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
143 |
uint16 val; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
144 |
val = grf_load_byte(buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
145 |
if (val == 0xFF) val = grf_load_word(buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
146 |
return val; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
147 |
} |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
148 |
|
2324 | 149 |
static uint32 grf_load_dword(byte **buf) |
0 | 150 |
{ |
151 |
uint32 val; |
|
152 |
byte *p = *buf; |
|
153 |
val = p[0]; |
|
154 |
val |= p[1] << 8; |
|
155 |
val |= p[2] << 16; |
|
156 |
val |= p[3] << 24; |
|
157 |
*buf = p + 4; |
|
158 |
return val; |
|
159 |
} |
|
160 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
161 |
|
1477 | 162 |
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
|
163 |
{ |
1477 | 164 |
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
|
165 |
|
1477 | 166 |
for (file = _first_grffile; file != NULL; file = file->next) { |
167 |
if (file->grfid == grfid) break; |
|
168 |
} |
|
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
|
169 |
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
|
170 |
} |
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
|
171 |
|
1477 | 172 |
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
|
173 |
{ |
1477 | 174 |
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
|
175 |
|
1477 | 176 |
for (file = _first_grffile; file != NULL; file = file->next) { |
177 |
if (strcmp(file->filename, filename) == 0) break; |
|
178 |
} |
|
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
|
179 |
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
|
180 |
} |
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
|
181 |
|
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
|
182 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
183 |
typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); |
0 | 184 |
|
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
|
185 |
#define FOR_EACH_OBJECT for (i = 0; i < numinfo; i++) |
0 | 186 |
|
187 |
static void dewagonize(int condition, int engine) |
|
188 |
{ |
|
189 |
EngineInfo *ei = &_engine_info[engine]; |
|
190 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
|
191 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
192 |
if (condition != 0) { |
0 | 193 |
ei->unk2 &= ~0x80; |
194 |
rvi->flags &= ~2; |
|
195 |
} else { |
|
196 |
ei->unk2 |= 0x80; |
|
197 |
rvi->flags |= 2; |
|
198 |
} |
|
199 |
} |
|
200 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
201 |
static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 202 |
{ |
203 |
EngineInfo *ei = &_engine_info[engine]; |
|
204 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
|
205 |
byte *buf = *bufp; |
|
206 |
int i; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
207 |
bool ret = false; |
0 | 208 |
|
209 |
switch (prop) { |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
210 |
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
|
211 |
FOR_EACH_OBJECT { |
0 | 212 |
uint8 tracktype = grf_load_byte(&buf); |
213 |
||
214 |
ei[i].railtype_climates &= 0xf; |
|
215 |
ei[i].railtype_climates |= tracktype << 4; |
|
216 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
217 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
218 |
case 0x08: { /* AI passenger service */ |
0 | 219 |
/* 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
|
220 |
FOR_EACH_OBJECT { |
0 | 221 |
grf_load_byte(&buf); |
222 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
223 |
ret = true; |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
224 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
225 |
case 0x09: { /* Speed */ |
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
|
226 |
FOR_EACH_OBJECT { |
0 | 227 |
uint16 speed = grf_load_word(&buf); |
228 |
||
229 |
rvi[i].max_speed = speed; |
|
230 |
dewagonize(speed, engine + i); |
|
231 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
232 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
233 |
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
|
234 |
FOR_EACH_OBJECT { |
0 | 235 |
uint16 power = grf_load_word(&buf); |
236 |
||
1894
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
237 |
if (rvi[i].flags & RVI_MULTIHEAD) |
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
238 |
power /= 2; |
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
239 |
|
0 | 240 |
rvi[i].power = power; |
241 |
dewagonize(power, engine + i); |
|
242 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
243 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
244 |
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
|
245 |
FOR_EACH_OBJECT { |
0 | 246 |
uint8 runcostfact = grf_load_byte(&buf); |
247 |
||
248 |
rvi[i].running_cost_base = runcostfact; |
|
249 |
dewagonize(runcostfact, engine + i); |
|
250 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
251 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
252 |
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
|
253 |
FOR_EACH_OBJECT { |
0 | 254 |
uint32 base = grf_load_dword(&buf); |
255 |
||
256 |
switch (base) { |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
257 |
case 0x4C30: |
0 | 258 |
rvi[i].engclass = 0; |
259 |
break; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
260 |
case 0x4C36: |
0 | 261 |
rvi[i].engclass = 1; |
262 |
break; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
263 |
case 0x4C3C: |
0 | 264 |
rvi[i].engclass = 2; |
265 |
break; |
|
266 |
} |
|
267 |
dewagonize(base, engine + i); |
|
268 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
269 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
270 |
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
|
271 |
FOR_EACH_OBJECT { |
0 | 272 |
uint8 spriteid = grf_load_byte(&buf); |
273 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
274 |
if (spriteid == 0xFD && rvi[i].image_index != 0xFD) |
0 | 275 |
_engine_original_sprites[engine + i] = rvi[i].image_index; |
276 |
rvi[i].image_index = spriteid; |
|
277 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
278 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
279 |
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
|
280 |
FOR_EACH_OBJECT { |
0 | 281 |
uint8 dual = grf_load_byte(&buf); |
282 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
283 |
if (dual != 0) { |
1894
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
284 |
if (!(rvi[i].flags & RVI_MULTIHEAD)) // adjust power if needed |
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
285 |
rvi[i].power /= 2; |
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
286 |
rvi[i].flags |= RVI_MULTIHEAD; |
0 | 287 |
} else { |
1894
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
288 |
if (rvi[i].flags & RVI_MULTIHEAD) // adjust power if needed |
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
289 |
rvi[i].power *= 2; |
0053e4f13db8
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
290 |
rvi[i].flags &= ~RVI_MULTIHEAD; |
0 | 291 |
} |
292 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
293 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
294 |
case 0x14: { /* Cargo capacity */ |
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
|
295 |
FOR_EACH_OBJECT { |
0 | 296 |
uint8 capacity = grf_load_byte(&buf); |
297 |
||
298 |
rvi[i].capacity = capacity; |
|
299 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
300 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
301 |
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
|
302 |
FOR_EACH_OBJECT { |
0 | 303 |
uint8 ctype = grf_load_byte(&buf); |
304 |
||
305 |
rvi[i].cargo_type = ctype; |
|
306 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
307 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
308 |
case 0x16: { /* Weight */ |
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
|
309 |
FOR_EACH_OBJECT { |
0 | 310 |
uint8 weight = grf_load_byte(&buf); |
311 |
||
312 |
rvi[i].weight = weight; |
|
313 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
314 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
315 |
case 0x17: { /* 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
|
316 |
FOR_EACH_OBJECT { |
0 | 317 |
uint8 cfactor = grf_load_byte(&buf); |
318 |
||
319 |
rvi[i].base_cost = cfactor; |
|
320 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
321 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
322 |
case 0x18: { /* AI rank */ |
0 | 323 |
/* TODO: _railveh_score should be merged to _rail_vehicle_info. */ |
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
|
324 |
FOR_EACH_OBJECT { |
0 | 325 |
grf_load_byte(&buf); |
326 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
327 |
ret = true; |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
328 |
} break; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
329 |
case 0x19: { /* Engine traction type */ |
0 | 330 |
/* TODO: What do the individual numbers mean? |
331 |
* XXX: And in what base are they, in fact? --pasky */ |
|
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
|
332 |
FOR_EACH_OBJECT { |
0 | 333 |
uint8 traction = grf_load_byte(&buf); |
334 |
int engclass; |
|
335 |
||
336 |
if (traction <= 0x07) |
|
337 |
engclass = 0; |
|
338 |
else if (traction <= 0x27) |
|
339 |
engclass = 1; |
|
340 |
else if (traction <= 0x31) |
|
341 |
engclass = 2; |
|
342 |
else |
|
343 |
break; |
|
344 |
||
345 |
rvi[i].engclass = engclass; |
|
346 |
} |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
347 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
348 |
case 0x1B: { /* Powered wagons power bonus */ |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
349 |
FOR_EACH_OBJECT { |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
350 |
uint16 wag_power = grf_load_word(&buf); |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
351 |
|
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
352 |
rvi[i].pow_wag_power = wag_power; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
353 |
} |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
354 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
355 |
case 0x1D: { /* Refit cargo */ |
440
778ed2e8de1c
(svn r649) Support for custom rail vehicle refit bitmasks. (pasky)
miham
parents:
439
diff
changeset
|
356 |
FOR_EACH_OBJECT { |
778ed2e8de1c
(svn r649) Support for custom rail vehicle refit bitmasks. (pasky)
miham
parents:
439
diff
changeset
|
357 |
uint32 refit_mask = grf_load_dword(&buf); |
778ed2e8de1c
(svn r649) Support for custom rail vehicle refit bitmasks. (pasky)
miham
parents:
439
diff
changeset
|
358 |
|
778ed2e8de1c
(svn r649) Support for custom rail vehicle refit bitmasks. (pasky)
miham
parents:
439
diff
changeset
|
359 |
_engine_refit_masks[engine + i] = refit_mask; |
778ed2e8de1c
(svn r649) Support for custom rail vehicle refit bitmasks. (pasky)
miham
parents:
439
diff
changeset
|
360 |
} |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
361 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
362 |
case 0x1E: { /* Callback */ |
1895
398f156479c8
(svn r2401) - Fix: [newgrf] Finish up callback mechanism, implement 'refit capacity' callback slightly more correct.
hackykid
parents:
1894
diff
changeset
|
363 |
FOR_EACH_OBJECT { |
398f156479c8
(svn r2401) - Fix: [newgrf] Finish up callback mechanism, implement 'refit capacity' callback slightly more correct.
hackykid
parents:
1894
diff
changeset
|
364 |
byte callbacks = grf_load_byte(&buf); |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
365 |
|
1895
398f156479c8
(svn r2401) - Fix: [newgrf] Finish up callback mechanism, implement 'refit capacity' callback slightly more correct.
hackykid
parents:
1894
diff
changeset
|
366 |
rvi[i].callbackmask = callbacks; |
398f156479c8
(svn r2401) - Fix: [newgrf] Finish up callback mechanism, implement 'refit capacity' callback slightly more correct.
hackykid
parents:
1894
diff
changeset
|
367 |
} |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
368 |
} break; |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
369 |
case 0x21: { /* Shorter vehicle */ |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
370 |
FOR_EACH_OBJECT { |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
371 |
byte shorten_factor = grf_load_byte(&buf); |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
372 |
|
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
373 |
rvi[i].shorten_factor = shorten_factor; |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
374 |
} |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
375 |
} break; |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
376 |
case 0x22: { /* Visual effect */ |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
377 |
// see note in engine.h about rvi->visual_effect |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
378 |
FOR_EACH_OBJECT { |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
379 |
byte visual = grf_load_byte(&buf); |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
380 |
|
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
381 |
rvi[i].visual_effect = visual; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
382 |
} |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
383 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
384 |
case 0x23: { /* Powered wagons weight bonus */ |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
385 |
FOR_EACH_OBJECT { |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
386 |
byte wag_weight = grf_load_byte(&buf); |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
387 |
|
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
388 |
rvi[i].pow_wag_weight = wag_weight; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
389 |
} |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
390 |
} break; |
0 | 391 |
/* TODO */ |
392 |
/* Fall-through for unimplemented one byte long properties. */ |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
393 |
case 0x1A: /* Sort order */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
394 |
case 0x1C: /* Refit cost */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
395 |
case 0x1F: /* Tractive effort */ |
1871
1e74cb21d312
(svn r2377) - Fix: [newgrf] Ignore action 0 prop 0x20 (air drag)
orudge
parents:
1862
diff
changeset
|
396 |
case 0x20: /* Air drag */ |
1872
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
397 |
case 0x24: /* High byte of vehicle weight */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
398 |
case 0x25: /* User-defined bit mask to set when checking veh. var. 42 */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
399 |
case 0x26: /* Retire vehicle early */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
400 |
{ |
0 | 401 |
/* 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
|
402 |
FOR_EACH_OBJECT { |
0 | 403 |
grf_load_byte(&buf); |
404 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
405 |
ret = true; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
406 |
} break; |
0 | 407 |
default: |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
408 |
ret = true; |
0 | 409 |
} |
410 |
*bufp = buf; |
|
411 |
return ret; |
|
412 |
} |
|
413 |
||
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
414 |
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
|
415 |
{ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
416 |
RoadVehicleInfo *rvi = &_road_vehicle_info[engine]; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
417 |
byte *buf = *bufp; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
418 |
int i; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
419 |
bool ret = false; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
420 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
421 |
switch (prop) { |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
422 |
case 0x08: { /* Speed */ |
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
|
423 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
424 |
uint8 speed = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
425 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
426 |
rvi[i].max_speed = speed; // ?? units |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
427 |
} |
1968
6e2e29505de0
(svn r2474) - Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong)
hackykid
parents:
1922
diff
changeset
|
428 |
} break; |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
429 |
case 0x09: { /* 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
|
430 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
431 |
uint8 runcost = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
432 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
433 |
rvi[i].running_cost = runcost; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
434 |
} |
1968
6e2e29505de0
(svn r2474) - Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong)
hackykid
parents:
1922
diff
changeset
|
435 |
} break; |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
436 |
case 0x0A: { /* Running cost base */ |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
437 |
/* TODO: I have no idea. --pasky */ |
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
|
438 |
FOR_EACH_OBJECT { |
1968
6e2e29505de0
(svn r2474) - Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong)
hackykid
parents:
1922
diff
changeset
|
439 |
grf_load_dword(&buf); |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
440 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
441 |
ret = true; |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
442 |
} break; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
443 |
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
|
444 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
445 |
uint8 spriteid = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
446 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
447 |
if (spriteid == 0xFF) |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
448 |
spriteid = 0xFD; // cars have different custom id in the GRF file |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
449 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
450 |
// This is currently not used but there's no reason |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
451 |
// in not having it here for the future. |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
452 |
if (spriteid == 0xFD && rvi[i].image_index != 0xFD) |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
453 |
_engine_original_sprites[ROAD_ENGINES_INDEX + engine + i] = rvi[i].image_index; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
454 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
455 |
rvi[i].image_index = spriteid; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
456 |
} |
1968
6e2e29505de0
(svn r2474) - Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong)
hackykid
parents:
1922
diff
changeset
|
457 |
} break; |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
458 |
case 0x0F: { /* Cargo capacity */ |
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
|
459 |
FOR_EACH_OBJECT { |
1968
6e2e29505de0
(svn r2474) - Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong)
hackykid
parents:
1922
diff
changeset
|
460 |
uint16 capacity = grf_load_byte(&buf); |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
461 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
462 |
rvi[i].capacity = capacity; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
463 |
} |
1968
6e2e29505de0
(svn r2474) - Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong)
hackykid
parents:
1922
diff
changeset
|
464 |
} break; |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
465 |
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
|
466 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
467 |
uint8 cargo = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
468 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
469 |
rvi[i].cargo_type = cargo; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
470 |
} |
1968
6e2e29505de0
(svn r2474) - Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong)
hackykid
parents:
1922
diff
changeset
|
471 |
} break; |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
472 |
case 0x11: { /* 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
|
473 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
474 |
uint8 cost_factor = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
475 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
476 |
rvi[i].base_cost = cost_factor; // ?? is it base_cost? |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
477 |
} |
1968
6e2e29505de0
(svn r2474) - Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong)
hackykid
parents:
1922
diff
changeset
|
478 |
} break; |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
479 |
case 0x12: { /* SFX */ |
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
|
480 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
481 |
uint8 sfx = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
482 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
483 |
rvi[i].sfx = sfx; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
484 |
} |
1968
6e2e29505de0
(svn r2474) - Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong)
hackykid
parents:
1922
diff
changeset
|
485 |
} break; |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
486 |
case 0x13: /* Power in 10hp */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
487 |
case 0x14: /* Weight in 1/4 tons */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
488 |
case 0x15: /* Speed in mph*0.8 */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
489 |
/* 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
|
490 |
* 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
|
491 |
* missing in OTTD yet. --pasky */ |
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
|
492 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
493 |
grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
494 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
495 |
ret = true; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
496 |
break; |
1968
6e2e29505de0
(svn r2474) - Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong)
hackykid
parents:
1922
diff
changeset
|
497 |
case 0x16: { /* Cargos available for refitting */ |
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
|
498 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
499 |
uint32 refit_mask = grf_load_dword(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
500 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
501 |
_engine_refit_masks[ROAD_ENGINES_INDEX + engine + i] = refit_mask; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
502 |
} |
1968
6e2e29505de0
(svn r2474) - Fix: [newgrf] Some road vehicle action 0 properties were loaded as the wrong type (int8,int16,int32) causing undefined results. (like cargo types being wrong)
hackykid
parents:
1922
diff
changeset
|
503 |
} break; |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
504 |
case 0x17: /* Callback */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
505 |
case 0x18: /* Tractive effort */ |
1872
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
506 |
case 0x19: /* Air drag */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
507 |
case 0x1A: /* Refit cost */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
508 |
case 0x1B: /* Retire vehicle early */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
509 |
{ |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
510 |
/* 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
|
511 |
FOR_EACH_OBJECT { |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
512 |
grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
513 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
514 |
ret = true; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
515 |
break; |
1873
c8637fc2977b
(svn r2379) - Fix: [newgrf] Note to self, check thoroughly before committing!
orudge
parents:
1872
diff
changeset
|
516 |
} |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
517 |
default: |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
518 |
ret = true; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
519 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
520 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
521 |
*bufp = buf; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
522 |
return ret; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
523 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
524 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
525 |
static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 526 |
{ |
527 |
ShipVehicleInfo *svi = &_ship_vehicle_info[engine]; |
|
528 |
byte *buf = *bufp; |
|
529 |
int i; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
530 |
bool ret = false; |
0 | 531 |
|
532 |
//printf("e %x prop %x?\n", engine, prop); |
|
533 |
switch (prop) { |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
534 |
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
|
535 |
FOR_EACH_OBJECT { |
0 | 536 |
uint8 spriteid = grf_load_byte(&buf); |
537 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
538 |
if (spriteid == 0xFF) |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
539 |
spriteid = 0xFD; // ships have different custom id in the GRF file |
0 | 540 |
|
541 |
// This is currently not used but there's no reason |
|
542 |
// in not having it here for the future. |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
543 |
if (spriteid == 0xFD && svi[i].image_index != 0xFD) |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
544 |
_engine_original_sprites[SHIP_ENGINES_INDEX + engine + i] = svi[i].image_index; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
545 |
|
0 | 546 |
svi[i].image_index = spriteid; |
547 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
548 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
549 |
case 0x09: { /* Refittable */ |
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
|
550 |
FOR_EACH_OBJECT { |
0 | 551 |
uint8 refittable = grf_load_byte(&buf); |
552 |
||
553 |
svi[i].refittable = refittable; |
|
554 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
555 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
556 |
case 0x0A: { /* 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
|
557 |
FOR_EACH_OBJECT { |
0 | 558 |
uint8 cost_factor = grf_load_byte(&buf); |
559 |
||
560 |
svi[i].base_cost = cost_factor; // ?? is it base_cost? |
|
561 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
562 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
563 |
case 0x0B: { /* Speed */ |
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
|
564 |
FOR_EACH_OBJECT { |
0 | 565 |
uint8 speed = grf_load_byte(&buf); |
566 |
||
567 |
svi[i].max_speed = speed; // ?? units |
|
568 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
569 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
570 |
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
|
571 |
FOR_EACH_OBJECT { |
0 | 572 |
uint8 cargo = grf_load_byte(&buf); |
573 |
||
574 |
// XXX: Need to consult this with patchman yet. |
|
575 |
#if 0 |
|
576 |
// Documentation claims this is already the |
|
577 |
// per-landscape cargo type id, but newships.grf |
|
578 |
// assume otherwise. |
|
579 |
cargo = local_cargo_id_ctype[cargo]; |
|
580 |
#endif |
|
581 |
svi[i].cargo_type = cargo; |
|
582 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
583 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
584 |
case 0x0D: { /* Cargo capacity */ |
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
|
585 |
FOR_EACH_OBJECT { |
0 | 586 |
uint16 capacity = grf_load_word(&buf); |
587 |
||
588 |
svi[i].capacity = capacity; |
|
589 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
590 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
591 |
case 0x0F: { /* 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
|
592 |
FOR_EACH_OBJECT { |
0 | 593 |
uint8 runcost = grf_load_byte(&buf); |
594 |
||
595 |
svi[i].running_cost = runcost; |
|
596 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
597 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
598 |
case 0x10: { /* SFX */ |
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
|
599 |
FOR_EACH_OBJECT { |
0 | 600 |
uint8 sfx = grf_load_byte(&buf); |
601 |
||
602 |
svi[i].sfx = sfx; |
|
603 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
604 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
605 |
case 0x11: { /* Cargos available for refitting */ |
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
|
606 |
FOR_EACH_OBJECT { |
0 | 607 |
uint32 refit_mask = grf_load_dword(&buf); |
608 |
||
609 |
_engine_refit_masks[SHIP_ENGINES_INDEX + engine + i] = refit_mask; |
|
610 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
611 |
} break; |
1872
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
612 |
case 0x12: /* Callback */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
613 |
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
|
614 |
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
|
615 |
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
|
616 |
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
|
617 |
{ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
618 |
/* TODO */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
619 |
FOR_EACH_OBJECT { |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
620 |
grf_load_byte(&buf); |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
621 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
622 |
ret = true; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
623 |
} break; |
0 | 624 |
default: |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
625 |
ret = true; |
0 | 626 |
} |
627 |
||
628 |
*bufp = buf; |
|
629 |
return ret; |
|
630 |
} |
|
631 |
||
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
|
632 |
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
|
633 |
{ |
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
|
634 |
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
|
635 |
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
|
636 |
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
|
637 |
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
|
638 |
|
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
|
639 |
//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
|
640 |
switch (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
|
641 |
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
|
642 |
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
|
643 |
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
|
644 |
|
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
|
645 |
if (spriteid == 0xFF) |
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
|
646 |
spriteid = 0xFD; // ships have different custom id in the GRF file |
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
|
647 |
|
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
|
648 |
// This is currently not used but there's no reason |
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
|
649 |
// in not having it here for the future. |
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
|
650 |
if (spriteid == 0xFD && avi[i].image_index != 0xFD) |
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
|
651 |
_engine_original_sprites[AIRCRAFT_ENGINES_INDEX + engine + i] = avi[i].image_index; |
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
|
652 |
|
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
|
653 |
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
|
654 |
} |
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
|
655 |
} break; |
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
|
656 |
case 0x09: { /* Helicopter */ |
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
|
657 |
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
|
658 |
uint8 heli = grf_load_byte(&buf); |
1180
04f306272df7
(svn r1682) - Fix: [newgrf] Helicopters from grf sets are now correctly recognized
dominik
parents:
922
diff
changeset
|
659 |
avi[i].subtype &= ~0x01; // remove old property |
1183
a9273fb4d48e
(svn r1685) - Fix: [newgrf] airplanes from grf sets are not treated as helicopters, as introduced in r1682
dominik
parents:
1180
diff
changeset
|
660 |
avi[i].subtype |= (heli == 0) ? 0 : 1; |
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
|
661 |
} |
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
|
662 |
} break; |
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
|
663 |
case 0x0A: { /* Large */ |
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
|
664 |
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
|
665 |
uint8 large = grf_load_byte(&buf); |
1180
04f306272df7
(svn r1682) - Fix: [newgrf] Helicopters from grf sets are now correctly recognized
dominik
parents:
922
diff
changeset
|
666 |
avi[i].subtype &= ~0x02; // remove old property |
1183
a9273fb4d48e
(svn r1685) - Fix: [newgrf] airplanes from grf sets are not treated as helicopters, as introduced in r1682
dominik
parents:
1180
diff
changeset
|
667 |
avi[i].subtype |= (large == 1) ? 2 : 0; |
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
|
668 |
} |
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
|
669 |
} break; |
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
|
670 |
case 0x0B: { /* 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
|
671 |
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
|
672 |
uint8 cost_factor = 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
|
673 |
|
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
|
674 |
avi[i].base_cost = cost_factor; // ?? is it base_cost? |
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
|
675 |
} |
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
|
676 |
} break; |
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
|
677 |
case 0x0C: { /* Speed */ |
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
|
678 |
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
|
679 |
uint8 speed = 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
|
680 |
|
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 |
avi[i].max_speed = speed; // ?? units |
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 |
} |
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
|
683 |
} break; |
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 |
case 0x0D: { /* Acceleration */ |
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
|
685 |
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
|
686 |
uint8 accel = 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
|
687 |
|
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 |
avi[i].acceleration = accel; |
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 |
} |
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 |
} break; |
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
|
691 |
case 0x0E: { /* 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
|
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 runcost = 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 |
|
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
|
695 |
avi[i].running_cost = runcost; |
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
|
696 |
} |
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
|
697 |
} break; |
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
|
698 |
case 0x0F: { /* Passenger capacity */ |
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
|
699 |
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
|
700 |
uint16 capacity = grf_load_word(&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
|
701 |
|
922
fc040662bd43
(svn r1410) Replaced all occurences of 'passanger' by 'passenger' in the code
celestar
parents:
542
diff
changeset
|
702 |
avi[i].passenger_capacity = capacity; |
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
|
703 |
} |
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
|
704 |
} break; |
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
|
705 |
case 0x11: { /* Mail capacity */ |
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
|
706 |
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
|
707 |
uint8 capacity = 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
|
708 |
|
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
|
709 |
avi[i].mail_capacity = capacity; |
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
|
710 |
} |
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
|
711 |
} break; |
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
|
712 |
case 0x12: { /* SFX */ |
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
|
713 |
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
|
714 |
uint8 sfx = 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
|
715 |
|
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
|
716 |
avi[i].sfx = sfx; |
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
|
717 |
} |
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
|
718 |
} break; |
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
|
719 |
case 0x13: { /* Cargos available for refitting */ |
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
|
720 |
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
|
721 |
uint32 refit_mask = grf_load_dword(&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
|
722 |
|
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
|
723 |
_engine_refit_masks[AIRCRAFT_ENGINES_INDEX + engine + i] = refit_mask; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
724 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
725 |
} break; |
1872
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
726 |
case 0x14: /* Callback */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
727 |
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
|
728 |
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
|
729 |
{ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
730 |
/* TODO */ |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
731 |
FOR_EACH_OBJECT { |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
732 |
grf_load_byte(&buf); |
5fe1a92bde30
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
733 |
} |
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
|
734 |
ret = true; |
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
|
735 |
} break; |
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
|
736 |
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
|
737 |
ret = true; |
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
|
738 |
} |
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
|
739 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
740 |
*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
|
741 |
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
|
742 |
} |
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
|
743 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
744 |
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
|
745 |
{ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
746 |
byte *buf = *bufp; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
747 |
int i; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
748 |
int ret = 0; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
749 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
750 |
/* This is one single huge TODO. It doesn't handle anything more than |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
751 |
* just waypoints for now. */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
752 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
753 |
//printf("sci %d %d [0x%02x]\n", stid, numinfo, prop); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
754 |
switch (prop) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
755 |
case 0x08: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
756 |
{ /* 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
|
757 |
FOR_EACH_OBJECT { |
1477 | 758 |
StationSpec *stat = &_cur_grffile->stations[stid + i]; |
438
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
759 |
uint32 classid; |
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
|
760 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
761 |
/* classid, for a change, is always little-endian */ |
438
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
762 |
classid = *(buf++) << 24; |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
763 |
classid |= *(buf++) << 16; |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
764 |
classid |= *(buf++) << 8; |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
765 |
classid |= *(buf++); |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
766 |
|
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
767 |
switch (classid) { |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
768 |
case 'DFLT': |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
769 |
stat->sclass = STAT_CLASS_DFLT; |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
770 |
break; |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
771 |
case 'WAYP': |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
772 |
stat->sclass = STAT_CLASS_WAYP; |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
773 |
break; |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
774 |
default: |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
775 |
/* TODO: No support for custom |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
776 |
* classes for now, so stuff |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
777 |
* everything to the single |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
778 |
* default one. --pasky */ |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
779 |
stat->sclass = STAT_CLASS_DFLT; |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
780 |
//stat->sclass = STAT_CLASS_CUSTOM; |
438
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
781 |
break; |
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
782 |
} |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
783 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
784 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
785 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
786 |
case 0x09: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
787 |
{ /* 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
|
788 |
FOR_EACH_OBJECT { |
1477 | 789 |
StationSpec *stat = &_cur_grffile->stations[stid + i]; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
790 |
int 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
|
791 |
|
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
792 |
stat->tiles = grf_load_byte(&buf); |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
793 |
for (t = 0; t < stat->tiles; t++) { |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
794 |
DrawTileSprites *dts = &stat->renderdata[t]; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
795 |
int seq_count = 0; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
796 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
797 |
if (t >= 8) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
798 |
grfmsg(GMS_WARN, "StationChangeInfo: Sprite %d>=8, skipping.", t); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
799 |
grf_load_dword(&buf); // at least something |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
800 |
continue; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
801 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
802 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
803 |
dts->ground_sprite = grf_load_dword(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
804 |
if (!dts->ground_sprite) { |
536 | 805 |
static const DrawTileSeqStruct empty = {0x80, 0, 0, 0, 0, 0, 0}; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
806 |
dts->seq = ∅ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
807 |
continue; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
808 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
809 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
810 |
dts->seq = NULL; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
811 |
while (buf < *bufp + len) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
812 |
DrawTileSeqStruct *dtss; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
813 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
814 |
// 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
|
815 |
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
|
816 |
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
|
817 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
818 |
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
|
819 |
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
|
820 |
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
|
821 |
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
|
822 |
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
|
823 |
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
|
824 |
dtss->unk = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
825 |
dtss->image = grf_load_dword(&buf) - 0x42d; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
826 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
827 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
828 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
829 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
830 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
831 |
case 0x0a: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
832 |
{ /* 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
|
833 |
FOR_EACH_OBJECT { |
1477 | 834 |
StationSpec *stat = &_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
|
835 |
byte srcid = grf_load_byte(&buf); |
1477 | 836 |
StationSpec *srcstat = &_cur_grffile->stations[srcid]; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
837 |
int 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
|
838 |
|
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
839 |
stat->tiles = srcstat->tiles; |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
840 |
for (t = 0; t < stat->tiles; t++) { |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
841 |
DrawTileSprites *dts = &stat->renderdata[t]; |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
842 |
DrawTileSprites *sdts = &srcstat->renderdata[t]; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
843 |
DrawTileSeqStruct const *sdtss = sdts->seq; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
844 |
int seq_count = 0; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
845 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
846 |
dts->ground_sprite = sdts->ground_sprite; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
847 |
if (!dts->ground_sprite) { |
536 | 848 |
static const DrawTileSeqStruct empty = {0x80, 0, 0, 0, 0, 0, 0}; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
849 |
dts->seq = ∅ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
850 |
continue; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
851 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
852 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
853 |
dts->seq = NULL; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
854 |
while (1) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
855 |
DrawTileSeqStruct *dtss; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
856 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
857 |
// 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
|
858 |
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
|
859 |
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
|
860 |
*dtss = *sdtss; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
861 |
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
|
862 |
sdtss++; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
863 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
864 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
865 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
866 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
867 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
868 |
case 0x0b: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
869 |
{ /* Callback */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
870 |
/* 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
|
871 |
FOR_EACH_OBJECT { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
872 |
grf_load_byte(&buf); |
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 |
ret = 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
875 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
876 |
} |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
877 |
case 0x0C: |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
878 |
{ /* Platforms number */ |
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
|
879 |
FOR_EACH_OBJECT { |
1477 | 880 |
StationSpec *stat = &_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
|
881 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
882 |
stat->allowed_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
|
883 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
884 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
885 |
} |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
886 |
case 0x0D: |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
887 |
{ /* Platforms length */ |
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
|
888 |
FOR_EACH_OBJECT { |
1477 | 889 |
StationSpec *stat = &_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
|
890 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
891 |
stat->allowed_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
|
892 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
893 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
894 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
895 |
case 0x0e: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
896 |
{ /* 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
|
897 |
FOR_EACH_OBJECT { |
1477 | 898 |
StationSpec *stat = &_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
|
899 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
900 |
while (buf < *bufp + len) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
901 |
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
|
902 |
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
|
903 |
StationLayout layout; |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
904 |
int l, p; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
905 |
|
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
906 |
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
|
907 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
908 |
//debug("l %d > %d ?", length, stat->lengths); |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
909 |
if (length > stat->lengths) { |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
910 |
stat->platforms = realloc(stat->platforms, length); |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
911 |
memset(stat->platforms + stat->lengths, 0, length - stat->lengths); |
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 |
stat->layouts = realloc(stat->layouts, length * sizeof(*stat->layouts)); |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
914 |
memset(stat->layouts + stat->lengths, 0, |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
915 |
(length - stat->lengths) * sizeof(*stat->layouts)); |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
916 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
917 |
stat->lengths = length; |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
918 |
} |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
919 |
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
|
920 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
921 |
//debug("p %d > %d ?", number, stat->platforms[l]); |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
922 |
if (number > stat->platforms[l]) { |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
923 |
stat->layouts[l] = realloc(stat->layouts[l], |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
924 |
number * sizeof(**stat->layouts)); |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
925 |
// We expect NULL being 0 here, but C99 guarantees that. |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
926 |
memset(stat->layouts[l] + stat->platforms[l], 0, |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
927 |
(number - stat->platforms[l]) * sizeof(**stat->layouts)); |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
928 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
929 |
stat->platforms[l] = number; |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
930 |
} |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
931 |
|
542 | 932 |
p = 0; |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
933 |
layout = malloc(length * number); |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
934 |
for (l = 0; l < length; l++) |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
935 |
for (p = 0; p < number; p++) |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
936 |
layout[l * number + p] = grf_load_byte(&buf); |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
937 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
938 |
l--; |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
939 |
p--; |
542 | 940 |
assert(p >= 0); |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
941 |
free(stat->layouts[l][p]); |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
942 |
stat->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
|
943 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
944 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
945 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
946 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
947 |
case 0x0f: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
948 |
{ /* Copy custom layout */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
949 |
/* 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
|
950 |
FOR_EACH_OBJECT { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
951 |
grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
952 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
953 |
ret = 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
954 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
955 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
956 |
case 0x10: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
957 |
{ /* Little/lots cargo threshold */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
958 |
/* 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
|
959 |
FOR_EACH_OBJECT { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
960 |
grf_load_word(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
961 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
962 |
ret = 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
963 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
964 |
} |
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
|
965 |
case 0x11: |
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
|
966 |
{ /* Pylon placement */ |
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
|
967 |
/* TODO; makes sense only for electrified tracks */ |
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
|
968 |
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
|
969 |
grf_load_word(&buf); |
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
|
970 |
} |
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
|
971 |
ret = 1; |
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
|
972 |
break; |
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
|
973 |
} |
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
|
974 |
case 0x12: |
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
|
975 |
{ /* Cargo types for random triggers */ |
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
|
976 |
/* TODO */ |
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
|
977 |
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
|
978 |
grf_load_dword(&buf); |
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
|
979 |
} |
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
|
980 |
ret = 1; |
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
|
981 |
break; |
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
|
982 |
} |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
983 |
default: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
984 |
ret = 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
985 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
986 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
987 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
988 |
*bufp = buf; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
989 |
return ret; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
990 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
991 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
992 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
993 |
/* Action 0x00 */ |
0 | 994 |
static void VehicleChangeInfo(byte *buf, int len) |
995 |
{ |
|
996 |
byte *bufend = buf + len; |
|
997 |
int i; |
|
998 |
||
999 |
/* <00> <feature> <num-props> <num-info> <id> (<property <new-info>)... |
|
1000 |
* |
|
1001 |
* B feature 0, 1, 2 or 3 for trains, road vehicles, ships or planes |
|
1002 |
* 4 for defining new train station sets |
|
1003 |
* B num-props how many properties to change per vehicle/station |
|
1004 |
* B num-info how many vehicles/stations to change |
|
1005 |
* B id ID of first vehicle/station to change, if num-info is |
|
1006 |
* greater than one, this one and the following |
|
1007 |
* vehicles/stations will be changed |
|
1008 |
* B property what property to change, depends on the feature |
|
1009 |
* 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
|
1010 |
/* TODO: Bridges, town houses. */ |
0 | 1011 |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1012 |
static const VCI_Handler handler[7] = { |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
1013 |
/* GSF_TRAIN */ RailVehicleChangeInfo, |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
1014 |
/* GSF_ROAD */ RoadVehicleChangeInfo, |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
1015 |
/* 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
|
1016 |
/* GSF_AIRCRAFT */ AircraftVehicleChangeInfo, |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1017 |
/* GSF_STATION */ StationChangeInfo, |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1018 |
/* GSF_BRIDGE */ NULL, |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1019 |
/* GSF_TOWNHOUSE */NULL, |
0 | 1020 |
}; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1021 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1022 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1023 |
uint8 numprops; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1024 |
uint8 numinfo; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1025 |
byte engine; |
542 | 1026 |
EngineInfo *ei = NULL; |
0 | 1027 |
|
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
|
1028 |
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
|
1029 |
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
|
1030 |
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
|
1031 |
} |
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
|
1032 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1033 |
check_length(len, 6, "VehicleChangeInfo"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1034 |
feature = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1035 |
numprops = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1036 |
numinfo = buf[3]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1037 |
engine = buf[4]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
1038 |
|
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
1039 |
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
|
1040 |
feature, numprops, engine, numinfo); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
1041 |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1042 |
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
|
1043 |
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
|
1044 |
return; |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1045 |
} |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1046 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1047 |
if (feature != GSF_STATION) |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1048 |
ei = &_engine_info[engine + _vehshifts[feature]]; |
542 | 1049 |
/* XXX - Should there not be a check to see if 'ei' is NULL |
1050 |
when it is used in the switch below?? -- TrueLight */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1051 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1052 |
buf += 5; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1053 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1054 |
while (numprops-- && buf < bufend) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1055 |
uint8 prop = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1056 |
|
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
|
1057 |
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
|
1058 |
// stations don't share those common properties |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1059 |
goto run_handler; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1060 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1061 |
switch (prop) { |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1062 |
case 0x00: { /* Introduction date */ |
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
|
1063 |
FOR_EACH_OBJECT { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1064 |
uint16 date = grf_load_word(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1065 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1066 |
ei[i].base_intro = date; |
0 | 1067 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1068 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1069 |
case 0x02: { /* Decay speed */ |
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
|
1070 |
FOR_EACH_OBJECT { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1071 |
uint8 decay = grf_load_byte(&buf); |
0 | 1072 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1073 |
ei[i].unk2 &= 0x80; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1074 |
ei[i].unk2 |= decay & 0x7f; |
0 | 1075 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1076 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1077 |
case 0x03: { /* Vehicle life */ |
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
|
1078 |
FOR_EACH_OBJECT { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1079 |
uint8 life = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1080 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1081 |
ei[i].lifelength = life; |
0 | 1082 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1083 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1084 |
case 0x04: { /* Model life */ |
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
|
1085 |
FOR_EACH_OBJECT { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1086 |
uint8 life = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1087 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1088 |
ei[i].base_life = life; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1089 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1090 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1091 |
case 0x06: { /* Climates available */ |
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
|
1092 |
FOR_EACH_OBJECT { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1093 |
uint8 climates = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1094 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1095 |
ei[i].railtype_climates &= 0xf0; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1096 |
ei[i].railtype_climates |= climates; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1097 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1098 |
} break; |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
1099 |
case 0x07: { /* Loading speed */ |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1100 |
/* TODO */ |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1101 |
/* Hyronymus explained me what does |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1102 |
* this mean and insists on having a |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1103 |
* credit ;-). --pasky */ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1104 |
/* TODO: This needs to be supported by |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1105 |
* LoadUnloadVehicle() first. */ |
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
|
1106 |
FOR_EACH_OBJECT { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1107 |
grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1108 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1109 |
goto ignoring; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1110 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1111 |
default: { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1112 |
run_handler: |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1113 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) { |
0 | 1114 |
ignoring: |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1115 |
grfmsg(GMS_NOTICE, "VehicleChangeInfo: Ignoring property %x (not implemented).", prop); |
0 | 1116 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1117 |
break; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1118 |
} |
0 | 1119 |
} |
1120 |
} |
|
1121 |
} |
|
1122 |
||
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
|
1123 |
#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
|
1124 |
|
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1125 |
/** |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1126 |
* Creates a spritegroup representing a callback result |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1127 |
* @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
|
1128 |
* @return A spritegroup representing that callback result |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1129 |
*/ |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1130 |
SpriteGroup NewCallBackResult(uint16 value) |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1131 |
{ |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1132 |
SpriteGroup group; |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1133 |
|
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1134 |
group.type = SGT_CALLBACK; |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1135 |
|
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1136 |
// 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
|
1137 |
// New style ones only have the highest bit set (allows 15-bit results, instead of just 8) |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1138 |
if ((value >> 8) == 0xFF) |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1139 |
value &= 0xFF; |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1140 |
else |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1141 |
value &= ~0x8000; |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1142 |
|
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1143 |
group.g.callback.result = value; |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1144 |
|
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1145 |
return group; |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1146 |
} |
0 | 1147 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1148 |
/* 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
|
1149 |
static void NewSpriteSet(byte *buf, int len) |
0 | 1150 |
{ |
1151 |
/* <01> <feature> <num-sets> <num-ent> |
|
1152 |
* |
|
1153 |
* B feature feature to define sprites for |
|
1154 |
* 0, 1, 2, 3: veh-type, 4: train stations |
|
1155 |
* B num-sets number of sprite sets |
|
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1156 |
* E num-ent how many entries per sprite set |
0 | 1157 |
* For vehicles, this is the number of different |
1158 |
* vehicle directions in each sprite set |
|
1159 |
* Set num-dirs=8, unless your sprites are symmetric. |
|
1160 |
* In that case, use num-dirs=4. |
|
1161 |
* For stations, must be 12 (hex) for the eighteen |
|
1162 |
* different sprites that make up a station */ |
|
1163 |
/* TODO: No stations support. */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1164 |
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
|
1165 |
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
|
1166 |
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
|
1167 |
uint i; |
0 | 1168 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1169 |
check_length(len, 4, "NewSpriteSet"); |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1170 |
buf++; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1171 |
feature = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1172 |
num_sets = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1173 |
num_ents = grf_load_extended(&buf); |
0 | 1174 |
|
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
|
1175 |
_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
|
1176 |
_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
|
1177 |
_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
|
1178 |
_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
|
1179 |
|
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
|
1180 |
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
|
1181 |
"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
|
1182 |
"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
|
1183 |
_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
|
1184 |
); |
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
|
1185 |
|
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
|
1186 |
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
|
1187 |
LoadNextSprite(_cur_spriteid++, _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
|
1188 |
} |
0 | 1189 |
} |
1190 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1191 |
/* 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
|
1192 |
static void NewSpriteGroup(byte *buf, int len) |
0 | 1193 |
{ |
1194 |
byte *bufend = buf + len; |
|
1195 |
||
1196 |
/* <02> <feature> <set-id> <type/num-entries> <feature-specific-data...> |
|
1197 |
* |
|
1198 |
* B feature see action 1 |
|
1199 |
* B set-id ID of this particular definition |
|
1200 |
* B type/num-entries |
|
1201 |
* if 80 or greater, this is a randomized or variational |
|
1202 |
* list definition, see below |
|
1203 |
* otherwise it specifies a number of entries, the exact |
|
1204 |
* meaning depends on the feature |
|
1205 |
* V feature-specific-data (huge mess, don't even look it up --pasky) */ |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1206 |
/* TODO: No 0x80-types (ugh). */ |
0 | 1207 |
/* TODO: Also, empty sprites aren't handled for now. Need to investigate |
1208 |
* the "opacity" rules for these, that is which sprite to fall back to |
|
1209 |
* when. --pasky */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1210 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1211 |
uint8 setid; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1212 |
/* XXX: For stations, these two are "little cargo" and "lotsa cargo" sets. */ |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1213 |
uint8 numloaded; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1214 |
uint8 numloading; |
1477 | 1215 |
SpriteGroup *group; |
1216 |
RealSpriteGroup *rg; |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1217 |
byte *loaded_ptr; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1218 |
byte *loading_ptr; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1219 |
int i; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
1220 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1221 |
check_length(len, 5, "NewSpriteGroup"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1222 |
feature = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1223 |
setid = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1224 |
numloaded = buf[3]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1225 |
numloading = buf[4]; |
0 | 1226 |
|
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1227 |
if (numloaded == 0x81 || numloaded == 0x82) { |
1477 | 1228 |
DeterministicSpriteGroup *dg; |
419
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1229 |
uint16 groupid; |
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1230 |
int i; |
0 | 1231 |
|
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1232 |
// Ok, this is gonna get a little wild, so hold your breath... |
0 | 1233 |
|
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1234 |
/* This stuff is getting actually evaluated in |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1235 |
* EvalDeterministicSpriteGroup(). */ |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1236 |
|
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1237 |
buf += 4; len -= 4; |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1238 |
check_length(len, 6, "NewSpriteGroup 0x81/0x82"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1239 |
|
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1240 |
if (setid >= _cur_grffile->spritegroups_count) { |
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1241 |
_cur_grffile->spritegroups_count = setid + 1; |
1477 | 1242 |
_cur_grffile->spritegroups = realloc(_cur_grffile->spritegroups, _cur_grffile->spritegroups_count * sizeof(*_cur_grffile->spritegroups)); |
0 | 1243 |
} |
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1244 |
|
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1245 |
group = &_cur_grffile->spritegroups[setid]; |
1477 | 1246 |
memset(group, 0, sizeof(*group)); |
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1247 |
group->type = SGT_DETERMINISTIC; |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1248 |
dg = &group->g.determ; |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1249 |
|
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1250 |
/* XXX: We don't free() anything, assuming that if there was |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1251 |
* some action here before, it got associated by action 3. |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1252 |
* We should perhaps keep some refcount? --pasky */ |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1253 |
|
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1254 |
dg->var_scope = numloaded == 0x82 ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1255 |
dg->variable = grf_load_byte(&buf); |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1256 |
|
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1257 |
dg->shift_num = grf_load_byte(&buf); |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1258 |
dg->and_mask = grf_load_byte(&buf); |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1259 |
dg->operation = dg->shift_num >> 6; /* w00t */ |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1260 |
dg->shift_num &= 0x3F; |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1261 |
if (dg->operation != DSG_OP_NONE) { |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1262 |
dg->add_val = grf_load_byte(&buf); |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1263 |
dg->divmod_val = grf_load_byte(&buf); |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1264 |
} |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1265 |
|
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1266 |
/* (groupid & 0x8000) means this is callback result. */ |
419
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1267 |
|
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1268 |
dg->num_ranges = grf_load_byte(&buf); |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1269 |
dg->ranges = calloc(dg->num_ranges, sizeof(*dg->ranges)); |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1270 |
for (i = 0; i < dg->num_ranges; i++) { |
419
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1271 |
groupid = grf_load_word(&buf); |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1272 |
if (groupid & 0x8000) { |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1273 |
dg->ranges[i].group = NewCallBackResult(groupid); |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1274 |
} else if (groupid >= _cur_grffile->spritegroups_count) { |
419
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1275 |
/* This doesn't exist for us. */ |
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
1276 |
grf_load_word(&buf); // skip range |
419
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1277 |
i--; dg->num_ranges--; |
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1278 |
continue; |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1279 |
} else { |
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1280 |
/* XXX: If multiple surreal sets attach a surreal |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1281 |
* set this way, we are in trouble. */ |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1282 |
dg->ranges[i].group = _cur_grffile->spritegroups[groupid]; |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1283 |
} |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1284 |
|
413
36afcda97345
(svn r610) -newgrf: Support for some basic deterministical spritegroups regarding stations. Waypoints look changes based on year now :^) (pasky).
darkvater
parents:
408
diff
changeset
|
1285 |
dg->ranges[i].low = grf_load_byte(&buf); |
36afcda97345
(svn r610) -newgrf: Support for some basic deterministical spritegroups regarding stations. Waypoints look changes based on year now :^) (pasky).
darkvater
parents:
408
diff
changeset
|
1286 |
dg->ranges[i].high = grf_load_byte(&buf); |
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1287 |
} |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1288 |
|
419
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1289 |
groupid = grf_load_word(&buf); |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1290 |
if (groupid & 0x8000) { |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1291 |
dg->default_group = malloc(sizeof(*dg->default_group)); |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1292 |
*dg->default_group = NewCallBackResult(groupid); |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1293 |
} else if (groupid >= _cur_grffile->spritegroups_count) { |
419
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1294 |
/* This spritegroup stinks. */ |
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
1295 |
free(dg->ranges), dg->ranges = NULL; |
419
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1296 |
grfmsg(GMS_WARN, "NewSpriteGroup(%02x:0x%x): Default groupid %04x is cargo callback or unknown, ignoring spritegroup.", setid, numloaded, groupid); |
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1297 |
return; |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1298 |
} else { |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1299 |
dg->default_group = malloc(sizeof(*dg->default_group)); |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1300 |
memcpy(dg->default_group, &_cur_grffile->spritegroups[groupid], sizeof(*dg->default_group)); |
419
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1301 |
} |
2fbd23a1cedc
(svn r616) -newgrf: Fixed crashing when trying to resolve references to unknown or callback result spritegroups in variational spritegroup handler of NewSpriteGroup() (pasky).
darkvater
parents:
418
diff
changeset
|
1302 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1303 |
return; |
0 | 1304 |
|
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
|
1305 |
} else if (numloaded == 0x80 || numloaded == 0x83) { |
1477 | 1306 |
RandomizedSpriteGroup *rg; |
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
|
1307 |
int i; |
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
|
1308 |
|
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
|
1309 |
/* This stuff is getting actually evaluated in |
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
|
1310 |
* EvalRandomizedSpriteGroup(). */ |
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
|
1311 |
|
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
|
1312 |
buf += 4; |
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
|
1313 |
len -= 4; |
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
|
1314 |
check_length(len, 6, "NewSpriteGroup 0x80/0x83"); |
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
|
1315 |
|
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
|
1316 |
if (setid >= _cur_grffile->spritegroups_count) { |
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
|
1317 |
_cur_grffile->spritegroups_count = setid + 1; |
1477 | 1318 |
_cur_grffile->spritegroups = realloc(_cur_grffile->spritegroups, _cur_grffile->spritegroups_count * sizeof(*_cur_grffile->spritegroups)); |
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
|
1319 |
} |
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
|
1320 |
|
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
|
1321 |
group = &_cur_grffile->spritegroups[setid]; |
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
|
1322 |
memset(group, 0, sizeof(*group)); |
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
|
1323 |
group->type = SGT_RANDOMIZED; |
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
|
1324 |
rg = &group->g.random; |
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
|
1325 |
|
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
|
1326 |
/* XXX: We don't free() anything, assuming that if there was |
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
|
1327 |
* some action here before, it got associated by action 3. |
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
|
1328 |
* We should perhaps keep some refcount? --pasky */ |
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
|
1329 |
|
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
|
1330 |
rg->var_scope = numloaded == 0x83 ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
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
|
1331 |
|
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
|
1332 |
rg->triggers = grf_load_byte(&buf); |
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
|
1333 |
rg->cmp_mode = rg->triggers & 0x80; |
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
|
1334 |
rg->triggers &= 0x7F; |
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
|
1335 |
|
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
|
1336 |
rg->lowest_randbit = grf_load_byte(&buf); |
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
|
1337 |
rg->num_groups = grf_load_byte(&buf); |
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
|
1338 |
|
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
|
1339 |
rg->groups = calloc(rg->num_groups, sizeof(*rg->groups)); |
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
|
1340 |
for (i = 0; i < rg->num_groups; i++) { |
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
|
1341 |
uint16 groupid = grf_load_word(&buf); |
448
5aa84112454c
(svn r658) Ignore callbackish randomized spritegroups - they would just crash us (pasky)
tron
parents:
445
diff
changeset
|
1342 |
|
5aa84112454c
(svn r658) Ignore callbackish randomized spritegroups - they would just crash us (pasky)
tron
parents:
445
diff
changeset
|
1343 |
if (groupid & 0x8000 || groupid >= _cur_grffile->spritegroups_count) { |
5aa84112454c
(svn r658) Ignore callbackish randomized spritegroups - they would just crash us (pasky)
tron
parents:
445
diff
changeset
|
1344 |
/* This doesn't exist for us. */ |
5aa84112454c
(svn r658) Ignore callbackish randomized spritegroups - they would just crash us (pasky)
tron
parents:
445
diff
changeset
|
1345 |
i--; |
5aa84112454c
(svn r658) Ignore callbackish randomized spritegroups - they would just crash us (pasky)
tron
parents:
445
diff
changeset
|
1346 |
rg->num_groups--; |
5aa84112454c
(svn r658) Ignore callbackish randomized spritegroups - they would just crash us (pasky)
tron
parents:
445
diff
changeset
|
1347 |
continue; |
5aa84112454c
(svn r658) Ignore callbackish randomized spritegroups - they would just crash us (pasky)
tron
parents:
445
diff
changeset
|
1348 |
} |
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
|
1349 |
/* XXX: If multiple surreal sets attach a surreal |
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
|
1350 |
* set this way, we are in trouble. */ |
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
|
1351 |
rg->groups[i] = _cur_grffile->spritegroups[groupid]; |
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
|
1352 |
} |
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
|
1353 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1354 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1355 |
} |
0 | 1356 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1357 |
if (!_cur_grffile->spriteset_start) { |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1358 |
grfmsg(GMS_ERROR, "NewSpriteGroup: No sprite set to work on! Skipping."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1359 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1360 |
} |
0 | 1361 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1362 |
if (_cur_grffile->spriteset_feature != feature) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1363 |
grfmsg(GMS_ERROR, "NewSpriteGroup: Group feature %x doesn't match set feature %x! Playing it risky and trying to use it anyway.", feature, _cur_grffile->spriteset_feature); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1364 |
// return; // XXX: we can't because of MB's newstats.grf --pasky |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1365 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1366 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1367 |
check_length(bufend - buf, 5, "NewSpriteGroup"); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1368 |
buf += 5; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1369 |
check_length(bufend - buf, 2 * numloaded, "NewSpriteGroup"); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1370 |
loaded_ptr = buf; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1371 |
loading_ptr = buf + 2 * numloaded; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1372 |
|
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1373 |
if (numloaded > 16) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1374 |
grfmsg(GMS_WARN, "NewSpriteGroup: More than 16 sprites in group %x, skipping the rest.", setid); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1375 |
numloaded = 16; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1376 |
} |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1377 |
if (numloading > 16) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1378 |
grfmsg(GMS_WARN, "NewSpriteGroup: More than 16 sprites in group %x, skipping the rest.", setid); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1379 |
numloading = 16; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1380 |
} |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1381 |
|
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1382 |
if (setid >= _cur_grffile->spritegroups_count) { |
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1383 |
_cur_grffile->spritegroups_count = setid + 1; |
1477 | 1384 |
_cur_grffile->spritegroups = realloc(_cur_grffile->spritegroups, _cur_grffile->spritegroups_count * sizeof(*_cur_grffile->spritegroups)); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1385 |
} |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1386 |
group = &_cur_grffile->spritegroups[setid]; |
1477 | 1387 |
memset(group, 0, sizeof(*group)); |
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1388 |
group->type = SGT_REAL; |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1389 |
rg = &group->g.real; |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1390 |
|
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1391 |
rg->sprites_per_set = _cur_grffile->spriteset_numents; |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1392 |
rg->loaded_count = numloaded; |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1393 |
rg->loading_count = numloading; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1394 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1395 |
DEBUG(grf, 6) ("NewSpriteGroup: New SpriteGroup 0x%02hhx, %u views, %u loaded, %u loading, sprites %u - %u", |
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1396 |
setid, rg->sprites_per_set, rg->loaded_count, rg->loading_count, |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1397 |
_cur_grffile->spriteset_start - _cur_grffile->sprite_offset, |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1398 |
_cur_grffile->spriteset_start + (_cur_grffile->spriteset_numents * (numloaded + numloading)) - _cur_grffile->sprite_offset); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1399 |
|
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1400 |
for (i = 0; i < numloaded; i++) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1401 |
uint16 spriteset_id = grf_load_word(&loaded_ptr); |
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1402 |
rg->loaded[i] = _cur_grffile->spriteset_start + spriteset_id * _cur_grffile->spriteset_numents; |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1403 |
DEBUG(grf, 8) ("NewSpriteGroup: + rg->loaded[%i] = %u (subset %u)", i, rg->loaded[i], spriteset_id); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1404 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1405 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1406 |
for (i = 0; i < numloading; i++) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1407 |
uint16 spriteset_id = grf_load_word(&loading_ptr); |
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1408 |
rg->loading[i] = _cur_grffile->spriteset_start + spriteset_id * _cur_grffile->spriteset_numents; |
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1409 |
DEBUG(grf, 8) ("NewSpriteGroup: + rg->loading[%i] = %u (subset %u)", i, rg->loading[i], spriteset_id); |
0 | 1410 |
} |
1411 |
} |
|
1412 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1413 |
/* 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
|
1414 |
static void NewVehicle_SpriteGroupMapping(byte *buf, int len) |
0 | 1415 |
{ |
1416 |
/* <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
|
1417 |
* id-list := [<id>] [id-list] |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1418 |
* cargo-list := <cargo-type> <cid> [cargo-list] |
0 | 1419 |
* |
1420 |
* B feature see action 0 |
|
1421 |
* B n-id bits 0-6: how many IDs this definition applies to |
|
1422 |
* bit 7: if set, this is a wagon override definition (see below) |
|
1423 |
* 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
|
1424 |
* B num-cid number of cargo IDs (sprite group IDs) in this definition |
0 | 1425 |
* can be zero, in that case the def-cid is used always |
1426 |
* 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
|
1427 |
* 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
|
1428 |
* 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
|
1429 |
/* TODO: Bridges, town houses. */ |
0 | 1430 |
/* TODO: Multiple cargo support could be useful even for trains/cars - |
1431 |
* cargo id 0xff is used for showing images in the build train list. */ |
|
1432 |
||
1433 |
static byte *last_engines; |
|
1434 |
static int last_engines_count; |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1435 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1436 |
uint8 idcount; |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1437 |
bool wagover; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1438 |
uint8 cidcount; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1439 |
int c, i; |
0 | 1440 |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1441 |
check_length(len, 7, "VehicleMapSpriteGroup"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1442 |
feature = buf[1]; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1443 |
idcount = buf[2] & 0x7F; |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1444 |
wagover = (buf[2] & 0x80) == 0x80; |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1445 |
check_length(len, 3 + idcount, "VehicleMapSpriteGroup"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1446 |
cidcount = buf[3 + idcount]; |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1447 |
check_length(len, 4 + idcount + cidcount * 3, "VehicleMapSpriteGroup"); |
0 | 1448 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1449 |
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
|
1450 |
feature, idcount, cidcount, wagover); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1451 |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1452 |
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
|
1453 |
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
|
1454 |
return; |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1455 |
} |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1456 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1457 |
|
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
1458 |
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
|
1459 |
// 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
|
1460 |
|
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
|
1461 |
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
|
1462 |
uint8 stid = buf[3 + i]; |
1477 | 1463 |
StationSpec *stat = &_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
|
1464 |
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
|
1465 |
|
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
|
1466 |
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
|
1467 |
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
|
1468 |
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
|
1469 |
|
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
|
1470 |
if (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
|
1471 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x, skipping.", |
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
|
1472 |
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
|
1473 |
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
|
1474 |
} |
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
|
1475 |
|
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
|
1476 |
if (ctype != 0xFF) { |
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
|
1477 |
/* TODO: No support for any other cargo. */ |
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
|
1478 |
continue; |
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
|
1479 |
} |
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
|
1480 |
|
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1481 |
stat->spritegroup[1] = _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
|
1482 |
} |
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
|
1483 |
} |
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
|
1484 |
|
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
|
1485 |
{ |
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
|
1486 |
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
|
1487 |
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
|
1488 |
|
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1489 |
if (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
|
1490 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x, skipping.", |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1491 |
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
|
1492 |
return; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1493 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1494 |
|
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
|
1495 |
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
|
1496 |
uint8 stid = buf[3 + i]; |
1477 | 1497 |
StationSpec *stat = &_cur_grffile->stations[stid]; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1498 |
|
408
63a8c0505aab
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
1499 |
stat->spritegroup[0] = _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
|
1500 |
stat->grfid = _cur_grffile->grfid; |
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
|
1501 |
SetCustomStation(stid, stat); |
438
79b5df3f394a
(svn r647) Cleanup custom station classes handling. (pasky)
miham
parents:
420
diff
changeset
|
1502 |
stat->sclass = STAT_CLASS_NONE; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1503 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1504 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1505 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1506 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1507 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1508 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1509 |
/* 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
|
1510 |
* 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
|
1511 |
* now. --octo */ |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1512 |
if (idcount == 0) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1513 |
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
|
1514 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1515 |
} |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1516 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1517 |
// FIXME: Tropicset contains things like: |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1518 |
// 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
|
1519 |
// what should we exactly do with that? --pasky |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1520 |
|
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1521 |
if (!_cur_grffile->spriteset_start || !_cur_grffile->spritegroups) { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1522 |
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
|
1523 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1524 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1525 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1526 |
if (!wagover && last_engines_count != idcount) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1527 |
last_engines = realloc(last_engines, idcount); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1528 |
last_engines_count = idcount; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1529 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1530 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1531 |
if (wagover) { |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1532 |
if (last_engines_count == 0) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1533 |
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
|
1534 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1535 |
} |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1536 |
DEBUG(grf, 6) ("VehicleMapSpriteGroup: WagonOverride: %u engines, %u wagons.", |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1537 |
last_engines_count, idcount); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1538 |
} |
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
|
1539 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1540 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1541 |
for (i = 0; i < idcount; i++) { |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1542 |
uint8 engine_id = buf[3 + i]; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1543 |
uint8 engine = engine_id + _vehshifts[feature]; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1544 |
byte *bp = &buf[4 + idcount]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1545 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1546 |
if (engine_id > _vehcounts[feature]) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1547 |
grfmsg(GMS_ERROR, "Id %u for feature %x is out of bounds.", |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1548 |
engine_id, feature); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1549 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1550 |
} |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1551 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1552 |
DEBUG(grf, 7) ("VehicleMapSpriteGroup: [%d] Engine %d...", i, engine); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1553 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1554 |
for (c = 0; c < cidcount; c++) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1555 |
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
|
1556 |
uint16 groupid = grf_load_word(&bp); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1557 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1558 |
DEBUG(grf, 8) ("VehicleMapSpriteGroup: * [%d] Cargo type %x, group id %x", c, ctype, groupid); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1559 |
|
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1560 |
if (groupid >= _cur_grffile->spritegroups_count) { |
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1561 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x, skipping.", groupid, _cur_grffile->spritegroups_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1562 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1563 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1564 |
|
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
|
1565 |
if (ctype == GC_INVALID) ctype = GC_PURCHASE; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1566 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1567 |
if (wagover) { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1568 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1569 |
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
|
1570 |
} else { |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1571 |
SetCustomEngineSprites(engine, ctype, &_cur_grffile->spritegroups[groupid]); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1572 |
last_engines[i] = engine; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1573 |
} |
0 | 1574 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1575 |
} |
0 | 1576 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1577 |
{ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1578 |
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
|
1579 |
uint16 groupid = grf_load_word(&bp); |
0 | 1580 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1581 |
DEBUG(grf, 8) ("-- Default group id %x", groupid); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1582 |
|
0 | 1583 |
for (i = 0; i < idcount; i++) { |
1584 |
uint8 engine = buf[3 + i] + _vehshifts[feature]; |
|
1585 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1586 |
// Don't tell me you don't love duplicated code! |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1587 |
if (groupid >= _cur_grffile->spritegroups_count) { |
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1588 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x, skipping.", groupid, _cur_grffile->spritegroups_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1589 |
return; |
0 | 1590 |
} |
1591 |
||
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1592 |
if (wagover) { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1593 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1594 |
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
|
1595 |
} else { |
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
|
1596 |
SetCustomEngineSprites(engine, GC_DEFAULT, &_cur_grffile->spritegroups[groupid]); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1597 |
last_engines[i] = engine; |
0 | 1598 |
} |
1599 |
} |
|
1600 |
} |
|
1601 |
} |
|
1602 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1603 |
/* Action 0x04 */ |
0 | 1604 |
static void VehicleNewName(byte *buf, int len) |
1605 |
{ |
|
1606 |
/* <04> <veh-type> <language-id> <num-veh> <offset> <data...> |
|
1607 |
* |
|
1608 |
* B veh-type see action 0 |
|
1609 |
* B language-id language ID with bit 7 cleared (see below) |
|
1610 |
* 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
|
1611 |
* B/W offset number of the first vehicle that gets a new name |
0 | 1612 |
* S data new texts, each of them zero-terminated, after |
1613 |
* which the next name begins. */ |
|
1614 |
/* TODO: No support for changing non-vehicle text. Perhaps we shouldn't |
|
1615 |
* implement it at all, but it could be useful for some "modpacks" |
|
1616 |
* (completely new scenarios changing all graphics and logically also |
|
1617 |
* factory names etc). We should then also support all languages (by |
|
1618 |
* name), not only the original four ones. --pasky */ |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1619 |
/* TODO: Support for custom station class/type names. */ |
0 | 1620 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1621 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1622 |
uint8 lang; |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1623 |
uint8 num; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1624 |
uint16 id; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1625 |
uint16 endid; |
1329 | 1626 |
const char* name; |
0 | 1627 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1628 |
check_length(len, 6, "VehicleNewName"); |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1629 |
buf++; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1630 |
feature = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1631 |
lang = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1632 |
num = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1633 |
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
|
1634 |
|
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1635 |
if (feature > 3) { |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1636 |
DEBUG(grf, 7) ("VehicleNewName: Unsupported feature %d, skipping", feature); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1637 |
return; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1638 |
} |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1639 |
|
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1640 |
id += _vehshifts[feature]; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1641 |
endid = id + num; |
0 | 1642 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1643 |
DEBUG(grf, 6) ("VehicleNewName: About to rename engines %d..%d (feature %d) in language 0x%x.", |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1644 |
id, endid, feature, lang); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1645 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1646 |
if (lang & 0x80) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1647 |
grfmsg(GMS_WARN, "VehicleNewName: No support for changing in-game texts. Skipping."); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1648 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1649 |
} |
0 | 1650 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1651 |
if (!(lang & 3)) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1652 |
/* XXX: If non-English name, silently skip it. */ |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1653 |
DEBUG(grf, 7) ("VehicleNewName: Skipping non-English name."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1654 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1655 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1656 |
|
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1657 |
name = (const char*)buf; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1658 |
len -= (lang & 0x80) ? 6 : 5; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1659 |
for (; id < endid && len > 0; id++) { |
1329 | 1660 |
int ofs = strlen(name) + 1; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1661 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1662 |
if (ofs < 128) { |
1329 | 1663 |
DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, name); |
1664 |
SetCustomEngineName(id, name); |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1665 |
} else { |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1666 |
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
|
1667 |
} |
1329 | 1668 |
name += ofs; |
1669 |
len -= ofs; |
|
0 | 1670 |
} |
1671 |
} |
|
1672 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1673 |
/* Action 0x05 */ |
0 | 1674 |
static void GraphicsNew(byte *buf, int len) |
1675 |
{ |
|
1676 |
/* <05> <graphics-type> <num-sprites> <other data...> |
|
1677 |
* |
|
1678 |
* 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
|
1679 |
* E num-sprites How many sprites are in this set? |
0 | 1680 |
* V other data Graphics type specific data. Currently unused. */ |
1681 |
/* TODO */ |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1682 |
|
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1683 |
uint8 type; |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1684 |
uint16 num; |
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1685 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1686 |
check_length(len, 2, "GraphicsNew"); |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1687 |
buf++; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1688 |
type = grf_load_byte(&buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1689 |
num = grf_load_extended(&buf); |
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1690 |
|
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1691 |
grfmsg(GMS_NOTICE, "GraphicsNew: Custom graphics (type %x) sprite block of length %d (unimplemented, ignoring).\n", |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1692 |
type, num); |
0 | 1693 |
} |
1694 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1695 |
/* Action 0x06 */ |
0 | 1696 |
static void CfgApply(byte *buf, int len) |
1697 |
{ |
|
1698 |
/* <06> <param-num> <param-size> <offset> ... <FF> |
|
1699 |
* |
|
1700 |
* B param-num Number of parameter to substitute (First = "zero") |
|
1701 |
* Ignored if that parameter was not specified in newgrf.cfg |
|
1702 |
* B param-size How many bytes to replace. If larger than 4, the |
|
1703 |
* bytes of the following parameter are used. In that |
|
1704 |
* case, nothing is applied unless *all* parameters |
|
1705 |
* were specified. |
|
1706 |
* B offset Offset into data from beginning of next sprite |
|
1707 |
* to place where parameter is to be stored. */ |
|
1708 |
/* TODO */ |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1709 |
grfmsg(GMS_NOTICE, "CfgApply: Ignoring (not implemented).\n"); |
0 | 1710 |
} |
1711 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1712 |
/* Action 0x07 */ |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1713 |
/* Action 0x09 */ |
0 | 1714 |
static void SkipIf(byte *buf, int len) |
1715 |
{ |
|
1716 |
/* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites> |
|
1717 |
* |
|
1718 |
* B param-num |
|
1719 |
* B param-size |
|
1720 |
* B condition-type |
|
1721 |
* V value |
|
1722 |
* B num-sprites */ |
|
1723 |
/* TODO: More params. More condition types. */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1724 |
uint8 param; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1725 |
uint8 paramsize; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1726 |
uint8 condtype; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1727 |
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
|
1728 |
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
|
1729 |
uint32 cond_val = 0; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1730 |
bool result; |
0 | 1731 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1732 |
check_length(len, 6, "SkipIf"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1733 |
param = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1734 |
paramsize = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1735 |
condtype = buf[3]; |
0 | 1736 |
|
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
|
1737 |
if (condtype < 2) { |
1611 | 1738 |
/* 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
|
1739 |
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
|
1740 |
} |
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
|
1741 |
|
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
|
1742 |
buf += 4; |
1611 | 1743 |
switch (paramsize) { |
1744 |
case 4: cond_val = grf_load_dword(&buf); break; |
|
1745 |
case 2: cond_val = grf_load_word(&buf); break; |
|
1746 |
case 1: cond_val = grf_load_byte(&buf); break; |
|
1747 |
default: break; |
|
1748 |
} |
|
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
|
1749 |
|
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
|
1750 |
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
|
1751 |
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
|
1752 |
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
|
1753 |
break; |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1754 |
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
|
1755 |
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
|
1756 |
break; |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1757 |
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
|
1758 |
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
|
1759 |
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
|
1760 |
break; |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1761 |
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
|
1762 |
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
|
1763 |
break; |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1764 |
case 0x88: { /* see if specified GRFID is active */ |
1611 | 1765 |
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
|
1766 |
} 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
|
1767 |
|
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
|
1768 |
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
|
1769 |
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
|
1770 |
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
|
1771 |
uint revision = 10; // special case: 2.0.1 is 2.0.10 |
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
|
1772 |
uint build = 49; |
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
|
1773 |
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
|
1774 |
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
|
1775 |
} |
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
|
1776 |
|
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1777 |
case 0x8D: /* TTD Version, 00=DOS, 01=Windows */ |
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1778 |
param_val = 1; |
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1779 |
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
|
1780 |
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
|
1781 |
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
|
1782 |
break; |
401
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1783 |
/* TODO */ |
37143866b5df
(svn r593) -newgrf: Support for two more TTD(Patch) version relate) SkipIf in-game variables (pasky).
darkvater
parents:
400
diff
changeset
|
1784 |
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
|
1785 |
default: |
2345 | 1786 |
if (param < 0x80) { |
1787 |
/* Parameter. */ |
|
1788 |
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
|
1789 |
} else { |
2345 | 1790 |
/* In-game variable. */ |
1791 |
grfmsg(GMS_WARN, "Unsupported in-game variable 0x%02X. Ignoring test.", param); |
|
1792 |
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
|
1793 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1794 |
} |
0 | 1795 |
|
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
|
1796 |
DEBUG(grf, 7) ("Test condtype %d, param %x, condval %x", condtype, param_val, cond_val); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1797 |
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
|
1798 |
case 0: result = !!(param_val & (1 << cond_val)); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1799 |
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
|
1800 |
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
|
1801 |
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
|
1802 |
/* 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
|
1803 |
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
|
1804 |
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
|
1805 |
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
|
1806 |
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
|
1807 |
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
|
1808 |
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
|
1809 |
case 5: result = (param_val > cond_val); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1810 |
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
|
1811 |
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
|
1812 |
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
|
1813 |
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
|
1814 |
break; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1815 |
default: |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1816 |
grfmsg(GMS_WARN, "Unsupported test %d. Ignoring.", condtype); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1817 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1818 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1819 |
|
1607
320079c7ac28
(svn r2111) So, result is bool therefore no need for this horrible == 0 thing.
pasky
parents:
1606
diff
changeset
|
1820 |
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
|
1821 |
grfmsg(GMS_NOTICE, "Not skipping sprites, test was false."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1822 |
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
|
1823 |
} |
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
|
1824 |
|
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
|
1825 |
numsprites = grf_load_byte(&buf); |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1826 |
grfmsg(GMS_NOTICE, "Skipping %d sprites, test was true.", numsprites); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1827 |
_skip_sprites = numsprites; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1828 |
if (_skip_sprites == 0) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1829 |
/* Zero means there are no sprites to skip, so |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1830 |
* we use -1 to indicate that all further |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1831 |
* sprites should be skipped. */ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1832 |
_skip_sprites = -1; |
0 | 1833 |
} |
1834 |
} |
|
1835 |
||
1836 |
static void GRFInfo(byte *buf, int len) |
|
1837 |
{ |
|
1838 |
/* <08> <version> <grf-id> <name> <info> |
|
1839 |
* |
|
1840 |
* B version newgrf version, currently 06 |
|
1841 |
* 4*B grf-id globally unique ID of this .grf file |
|
1842 |
* S name name of this .grf set |
|
1843 |
* S info string describing the set, and e.g. author and copyright */ |
|
1844 |
/* TODO: Check version. (We should have own versioning done somehow.) */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1845 |
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
|
1846 |
uint32 grfid; |
1329 | 1847 |
const char *name; |
1848 |
const char *info; |
|
0 | 1849 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1850 |
check_length(len, 9, "GRFInfo"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1851 |
version = buf[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
|
1852 |
/* this is de facto big endian - grf_load_dword() unsuitable */ |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1853 |
grfid = buf[2] << 24 | buf[3] << 16 | buf[4] << 8 | buf[5]; |
1329 | 1854 |
name = (const char*)(buf + 6); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1855 |
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
|
1856 |
|
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
|
1857 |
_cur_grffile->grfid = grfid; |
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
|
1858 |
_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
|
1859 |
|
2013
1b80954e9594
(svn r2521) -Codechange: Removed trailing "\n"s from DEBUG statements
celestar
parents:
1968
diff
changeset
|
1860 |
DEBUG(grf, 1) ("[%s] Loaded GRFv%d set %08lx - %s:\n%s", |
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
|
1861 |
_cur_grffile->filename, version, grfid, name, info); |
0 | 1862 |
} |
1863 |
||
1864 |
static void SpriteReplace(byte *buf, int len) |
|
1865 |
{ |
|
1866 |
/* <0A> <num-sets> <set1> [<set2> ...] |
|
1867 |
* <set>: <num-sprites> <first-sprite> |
|
1868 |
* |
|
1869 |
* B num-sets How many sets of sprites to replace. |
|
1870 |
* Each set: |
|
1871 |
* B num-sprites How many sprites are in this set |
|
1872 |
* 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
|
1873 |
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
|
1874 |
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
|
1875 |
|
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
|
1876 |
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
|
1877 |
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
|
1878 |
|
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
|
1879 |
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
|
1880 |
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
|
1881 |
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
|
1882 |
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
|
1883 |
|
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
|
1884 |
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
|
1885 |
"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
|
1886 |
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
|
1887 |
); |
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
|
1888 |
|
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
|
1889 |
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
|
1890 |
LoadNextSprite(first_sprite + j, _file_index); // XXX |
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
|
1891 |
} |
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
|
1892 |
} |
0 | 1893 |
} |
1894 |
||
1895 |
static void GRFError(byte *buf, int len) |
|
1896 |
{ |
|
1897 |
/* <0B> <severity> <language-id> <message-id> [<message...> 00] [<data...>] 00 [<parnum>] |
|
1898 |
* |
|
1899 |
* B severity 00: notice, contine loading grf file |
|
1900 |
* 01: warning, continue loading grf file |
|
1901 |
* 02: error, but continue loading grf file, and attempt |
|
1902 |
* loading grf again when loading or starting next game |
|
1903 |
* 03: error, abort loading and prevent loading again in |
|
1904 |
* the future (only when restarting the patch) |
|
1905 |
* B language-id see action 4, use 1F for built-in error messages |
|
1906 |
* B message-id message to show, see below |
|
1907 |
* S message for custom messages (message-id FF), text of the message |
|
1908 |
* not present for built-in messages. |
|
1909 |
* V data additional data for built-in (or custom) messages |
|
1910 |
* B parnum see action 6, only used with built-in message 03 */ |
|
1911 |
/* TODO: For now we just show the message, sometimes incomplete and never translated. */ |
|
1912 |
||
1913 |
static const char * const msgstr[4] = { |
|
1914 |
"Requires at least pseudo-TTDPatch version %s.", |
|
1915 |
"This file is for %s version of TTD.", |
|
1916 |
"Designed to be used with %s.", |
|
1917 |
"Invalid parameter %s.", |
|
1918 |
}; |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1919 |
uint8 severity; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1920 |
uint8 msgid; |
0 | 1921 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1922 |
check_length(len, 6, "GRFError"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1923 |
severity = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1924 |
msgid = buf[3]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1925 |
|
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
1926 |
// Undocumented TTDPatch feature. |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
1927 |
if ((severity & 0x80) == 0 && _cur_stage == 0) |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
1928 |
return; |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
1929 |
severity &= 0x7F; |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
1930 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1931 |
if (msgid == 0xFF) { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1932 |
grfmsg(severity, "%s", buf+4); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1933 |
} else { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1934 |
grfmsg(severity, msgstr[msgid], buf+4); |
0 | 1935 |
} |
1936 |
} |
|
1937 |
||
1938 |
static void GRFComment(byte *buf, int len) |
|
1939 |
{ |
|
1940 |
/* <0C> [<ignored...>] |
|
1941 |
* |
|
1942 |
* V ignored Anything following the 0C is ignored */ |
|
1943 |
} |
|
1944 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1945 |
/* Action 0x0D */ |
0 | 1946 |
static void ParamSet(byte *buf, int len) |
1947 |
{ |
|
1948 |
/* <0D> <target> <operation> <source1> <source2> [<data>] |
|
1949 |
* |
|
1950 |
* B target parameter number where result is stored |
|
1951 |
* B operation operation to perform, see below |
|
1952 |
* B source1 first source operand |
|
1953 |
* B source2 second source operand |
|
1954 |
* D data data to use in the calculation, not necessary |
|
1955 |
* if both source1 and source2 refer to actual parameters |
|
1956 |
* |
|
1957 |
* Operations |
|
1958 |
* 00 Set parameter equal to source1 |
|
1959 |
* 01 Addition, source1 + source2 |
|
1960 |
* 02 Subtraction, source1 - source2 |
|
1961 |
* 03 Unsigned multiplication, source1 * source2 (both unsigned) |
|
1962 |
* 04 Signed multiplication, source1 * source2 (both signed) |
|
1963 |
* 05 Unsigned bit shift, source1 by source2 (source2 taken to be a |
|
1964 |
* signed quantity; left shift if positive and right shift if |
|
1965 |
* negative, source1 is unsigned) |
|
1966 |
* 06 Signed bit shift, source1 by source2 |
|
1967 |
* (source2 like in 05, and source1 as well) |
|
1968 |
*/ |
|
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
|
1969 |
|
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
|
1970 |
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
|
1971 |
byte oper; |
2345 | 1972 |
uint32 src1; |
1973 |
uint32 src2; |
|
1974 |
uint32 data = 0; |
|
1975 |
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
|
1976 |
|
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
|
1977 |
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
|
1978 |
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
|
1979 |
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
|
1980 |
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
|
1981 |
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
|
1982 |
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
|
1983 |
|
2345 | 1984 |
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
|
1985 |
|
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
|
1986 |
/* 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
|
1987 |
* 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
|
1988 |
* 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
|
1989 |
* - 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
|
1990 |
* - 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
|
1991 |
* 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
|
1992 |
if (oper & 0x80) { |
2345 | 1993 |
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
|
1994 |
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
|
1995 |
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
|
1996 |
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
|
1997 |
} |
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
|
1998 |
|
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
|
1999 |
/* 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
|
2000 |
* 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
|
2001 |
* 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
|
2002 |
* 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
|
2003 |
* 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
|
2004 |
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
|
2005 |
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
|
2006 |
} else { |
2345 | 2007 |
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
|
2008 |
} |
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
|
2009 |
|
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
|
2010 |
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
|
2011 |
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
|
2012 |
} else { |
2345 | 2013 |
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
|
2014 |
} |
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
|
2015 |
|
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
|
2016 |
/* 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
|
2017 |
* 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
|
2018 |
* 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
|
2019 |
* 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
|
2020 |
* 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
|
2021 |
|
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 |
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
|
2023 |
case 0x00: |
2345 | 2024 |
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
|
2025 |
break; |
2345 | 2026 |
|
2027 |
case 0x01: |
|
2028 |
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
|
2029 |
break; |
2345 | 2030 |
|
2031 |
case 0x02: |
|
2032 |
res = src1 - src2; |
|
2033 |
break; |
|
2034 |
||
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
|
2035 |
case 0x03: |
2345 | 2036 |
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
|
2037 |
break; |
2345 | 2038 |
|
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
|
2039 |
case 0x04: |
2345 | 2040 |
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
|
2041 |
break; |
2345 | 2042 |
|
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
|
2043 |
case 0x05: |
2345 | 2044 |
if ((int32)src2 < 0) |
2045 |
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
|
2046 |
else |
2345 | 2047 |
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
|
2048 |
break; |
2345 | 2049 |
|
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
|
2050 |
case 0x06: |
2345 | 2051 |
if ((int32)src2 < 0) |
2052 |
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
|
2053 |
else |
2345 | 2054 |
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
|
2055 |
break; |
2345 | 2056 |
|
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
|
2057 |
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
|
2058 |
grfmsg(GMS_ERROR, "ParamSet: Unknown operation %d, skipping.", oper); |
2345 | 2059 |
return; |
2060 |
} |
|
2061 |
||
2062 |
switch (target) { |
|
2063 |
case 0x8E: // Y-Offset for train sprites |
|
2064 |
_traininfo_vehicle_pitch = res; |
|
2065 |
break; |
|
2066 |
||
2067 |
// TODO implement |
|
2068 |
case 0x8F: // Rail track type cost factors |
|
2069 |
case 0x93: // Tile refresh offset to left |
|
2070 |
case 0x94: // Tile refresh offset to right |
|
2071 |
case 0x95: // Tile refresh offset upwards |
|
2072 |
case 0x96: // Tile refresh offset downwards |
|
2073 |
case 0x97: // Snow line height |
|
2074 |
case 0x99: // Global ID offset |
|
2075 |
DEBUG(grf, 7) ("ParamSet: Skipping unimplemented target 0x%02X", target); |
|
2076 |
break; |
|
2077 |
||
2078 |
default: |
|
2079 |
if (target < 0x80) { |
|
2080 |
_cur_grffile->param[target] = res; |
|
2081 |
if (target + 1U > _cur_grffile->param_end) _cur_grffile->param_end = target + 1; |
|
2082 |
} else { |
|
2083 |
DEBUG(grf, 7) ("ParamSet: Skipping unknown target 0x%02X", target); |
|
2084 |
} |
|
2085 |
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
|
2086 |
} |
0 | 2087 |
} |
2088 |
||
2089 |
static void GRFInhibit(byte *buf, int len) |
|
2090 |
{ |
|
2091 |
/* <0E> <num> <grfids...> |
|
2092 |
* |
|
2093 |
* B num Number of GRFIDs that follow |
|
2094 |
* 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
|
2095 |
|
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
|
2096 |
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
|
2097 |
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
|
2098 |
|
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
|
2099 |
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
|
2100 |
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
|
2101 |
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
|
2102 |
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
|
2103 |
|
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
|
2104 |
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
|
2105 |
uint32 grfid = grf_load_dword(&buf); |
1477 | 2106 |
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
|
2107 |
|
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
|
2108 |
/* 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
|
2109 |
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
|
2110 |
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
|
2111 |
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
|
2112 |
} |
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
|
2113 |
} |
0 | 2114 |
} |
2115 |
||
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
|
2116 |
|
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
|
2117 |
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
|
2118 |
{ |
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
|
2119 |
/* 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
|
2120 |
|
1862
d07180add12f
(svn r2368) - Fix: Add 'multihead' TTDPatch option to OpenTTD newgrf flags-emulation (DBSETXLW doesn't complain about it anymore)
Darkvater
parents:
1802
diff
changeset
|
2121 |
_ttdpatch_flags[0] = (1 << 0x1B); /* multihead */ |
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2122 |
_ttdpatch_flags[1] = (1 << 0x08) /* mammothtrains */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2123 |
| (1 << 0x0B) /* subsidiaries */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2124 |
| (1 << 0x14) /* bridgespeedlimits */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2125 |
| (1 << 0x16) /* eternalgame */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2126 |
| (1 << 0x17) /* newtrains */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2127 |
| (1 << 0x18) /* newrvs */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2128 |
| (1 << 0x19) /* newships */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2129 |
| (1 << 0x1A) /* newplanes */ |
1862
d07180add12f
(svn r2368) - Fix: Add 'multihead' TTDPatch option to OpenTTD newgrf flags-emulation (DBSETXLW doesn't complain about it anymore)
Darkvater
parents:
1802
diff
changeset
|
2130 |
| (1 << 0x1B); /* signalsontrafficside */ |
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2131 |
/* Uncomment following if you want to fool the GRF file. |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2132 |
* Some GRF files will refuse to load without this |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2133 |
* but you can still squeeze something from them even |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2134 |
* without the support - i.e. USSet. --pasky */ |
1862
d07180add12f
(svn r2368) - Fix: Add 'multihead' TTDPatch option to OpenTTD newgrf flags-emulation (DBSETXLW doesn't complain about it anymore)
Darkvater
parents:
1802
diff
changeset
|
2135 |
//| (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
|
2136 |
|
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2137 |
_ttdpatch_flags[2] = (1 << 0x0D) /* buildonslopes */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2138 |
| (1 << 0x16) /* canals */ |
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
2139 |
| (1 << 0x17); /* newstartyear */ |
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
|
2140 |
} |
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
|
2141 |
|
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
|
2142 |
static void InitNewGRFFile(const char* filename, 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
|
2143 |
{ |
1477 | 2144 |
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
|
2145 |
|
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
|
2146 |
newfile = GetFileByFilename(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
|
2147 |
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
|
2148 |
/* 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
|
2149 |
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
|
2150 |
_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
|
2151 |
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
|
2152 |
} |
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
|
2153 |
|
1477 | 2154 |
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
|
2155 |
|
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
|
2156 |
if (newfile == 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
|
2157 |
error ("Out of memory"); |
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
|
2158 |
|
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
|
2159 |
newfile->filename = strdup(filename); |
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
|
2160 |
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
|
2161 |
|
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
|
2162 |
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
|
2163 |
_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
|
2164 |
_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
|
2165 |
} 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
|
2166 |
_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
|
2167 |
_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
|
2168 |
} |
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
|
2169 |
} |
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
|
2170 |
|
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
|
2171 |
|
0 | 2172 |
/* Here we perform initial decoding of some special sprites (as are they |
2173 |
* 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
|
2174 |
* partial implementation yet). */ |
0 | 2175 |
/* XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by |
2176 |
* a crafted invalid GRF file. We should tell that to the user somehow, or |
|
2177 |
* better make this more robust in the future. */ |
|
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
|
2178 |
static void DecodeSpecialSprite(const char* filename, uint num, uint stage) |
0 | 2179 |
{ |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
2180 |
/* 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
|
2181 |
* here. In TTDPatch, for some reason actions 1 and 2 are carried out |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
2182 |
* during stage 0, whilst action 3 is carried out during stage 1 (to |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
2183 |
* "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
|
2184 |
* 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
|
2185 |
* 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
|
2186 |
* in an earlier stage than associating, so... We just process actions |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
2187 |
* 1 and 2 in stage 1 now, let's hope that won't get us into problems. |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
2188 |
* --pasky */ |
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
|
2189 |
uint32 action_mask = (stage == 0) ? 0x0001FF40 : 0x0001FFBF; |
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
|
2190 |
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
|
2191 |
/* 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
|
2192 |
/* 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
|
2193 |
/* 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
|
2194 |
/* 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
|
2195 |
/* 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
|
2196 |
/* 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
|
2197 |
/* 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
|
2198 |
/* 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
|
2199 |
/* 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
|
2200 |
/* 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
|
2201 |
/* 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
|
2202 |
/* 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
|
2203 |
/* 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
|
2204 |
/* 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
|
2205 |
/* 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
|
2206 |
/* 0x0F */ NULL, // TODO implement |
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
|
2207 |
/* 0x10 */ NULL // TODO implement |
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
|
2208 |
}; |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
2209 |
|
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
|
2210 |
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
|
2211 |
byte action; |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
2212 |
|
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
|
2213 |
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
|
2214 |
|
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
|
2215 |
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
|
2216 |
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
|
2217 |
|
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
|
2218 |
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
|
2219 |
DEBUG(grf, 7) ("Skipping unknown action 0x%02X", action); |
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
|
2220 |
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
|
2221 |
return; |
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
|
2222 |
} |
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
|
2223 |
|
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
|
2224 |
if (!HASBIT(action_mask, action)) { |
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
|
2225 |
DEBUG(grf, 7) ("Skipping action 0x%02X in stage %d", action, 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
|
2226 |
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
|
2227 |
return; |
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
|
2228 |
} |
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
|
2229 |
|
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
|
2230 |
if (handlers[action] == NULL) { |
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
|
2231 |
DEBUG(grf, 7) ("Skipping unsupported Action 0x%02X", action); |
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
|
2232 |
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
|
2233 |
return; |
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
|
2234 |
} |
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
|
2235 |
|
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
|
2236 |
DEBUG(grf, 7) ("Handling action 0x%02X in stage %d", action, 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
|
2237 |
handlers[action](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
|
2238 |
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
|
2239 |
} |
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
|
2240 |
|
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
|
2241 |
|
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
|
2242 |
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
|
2243 |
{ |
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
|
2244 |
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
|
2245 |
|
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
|
2246 |
/* 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
|
2247 |
* 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
|
2248 |
* 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
|
2249 |
* 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
|
2250 |
* 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
|
2251 |
* |
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
|
2252 |
* 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
|
2253 |
* 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
|
2254 |
* 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
|
2255 |
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
|
2256 |
_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
|
2257 |
if (_cur_grffile == NULL) error("File ``%s'' lost in cache.\n", 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
|
2258 |
if (!(_cur_grffile->flags & 0x0001)) return; |
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
|
2259 |
} |
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
|
2260 |
|
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
|
2261 |
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
|
2262 |
_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
|
2263 |
|
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
|
2264 |
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
|
2265 |
|
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
|
2266 |
/* 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
|
2267 |
* 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
|
2268 |
* 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
|
2269 |
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
|
2270 |
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
|
2271 |
} 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
|
2272 |
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
|
2273 |
} |
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
|
2274 |
|
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
|
2275 |
_skip_sprites = 0; // 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
|
2276 |
|
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
|
2277 |
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
|
2278 |
byte type = 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
|
2279 |
|
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
|
2280 |
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
|
2281 |
if (_skip_sprites == 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
|
2282 |
DecodeSpecialSprite(filename, num, 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
|
2283 |
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
|
2284 |
} 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
|
2285 |
FioSkipBytes(num); |
1611 | 2286 |
} |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
2287 |
} 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
|
2288 |
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
|
2289 |
|
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
|
2290 |
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
|
2291 |
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
|
2292 |
|
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
|
2293 |
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
|
2294 |
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
|
2295 |
} 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
|
2296 |
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
|
2297 |
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
|
2298 |
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
|
2299 |
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
|
2300 |
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
|
2301 |
} 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
|
2302 |
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
|
2303 |
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
|
2304 |
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
|
2305 |
} |
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
|
2306 |
} |
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
|
2307 |
} |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
2308 |
} |
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
|
2309 |
|
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
|
2310 |
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
|
2311 |
} |
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
|
2312 |
} |
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
|
2313 |
|
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
|
2314 |
|
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
|
2315 |
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
|
2316 |
{ |
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
|
2317 |
static bool initialized = false; // XXX yikes |
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
|
2318 |
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
|
2319 |
|
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
|
2320 |
if (!initialized) { |
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
|
2321 |
InitializeGRFSpecial(); |
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
|
2322 |
initialized = true; |
0 | 2323 |
} |
2324 |
||
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
|
2325 |
/* 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
|
2326 |
* 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
|
2327 |
* 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
|
2328 |
_custom_sprites_base = 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
|
2329 |
for (stage = 0; stage < 2; 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
|
2330 |
uint 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
|
2331 |
|
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
|
2332 |
_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
|
2333 |
_cur_spriteid = 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
|
2334 |
for (j = 0; j != lengthof(_newgrf_files) && _newgrf_files[j] != NULL; 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
|
2335 |
if (!FiosCheckFileExists(_newgrf_files[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
|
2336 |
// TODO: usrerror() |
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
|
2337 |
error("NewGRF file missing: %s", _newgrf_files[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
|
2338 |
} |
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
|
2339 |
if (stage == 0) InitNewGRFFile(_newgrf_files[j], _cur_spriteid); |
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
|
2340 |
LoadNewGRFFile(_newgrf_files[j], file_index++, stage); // XXX different file indices in both stages? |
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
|
2341 |
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
|
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
|
2343 |
} |
0 | 2344 |
} |