author | darkvater |
Fri, 12 Nov 2004 23:59:51 +0000 | |
changeset 369 | ab2266938fa8 |
parent 368 | 32aad6ad36e1 |
child 372 | 1cc9354e2362 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
||
3 |
#include <stdarg.h> |
|
4 |
||
5 |
#include "ttd.h" |
|
6 |
#include "gfx.h" |
|
7 |
#include "fileio.h" |
|
8 |
#include "engine.h" |
|
9 |
||
10 |
/* TTDPatch extended GRF format codec |
|
11 |
* (c) Petr Baudis 2004 (GPL'd) |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
12 |
* 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
|
13 |
* |
0 | 14 |
* Contains portions of documentation by TTDPatch team. |
15 |
* Thanks especially to Josef Drexler for the documentation as well as a lot |
|
16 |
* of help at #tycoon. Also thanks to Michael Blunck for is GRF files which |
|
17 |
* served as subject to the initial testing of this codec. */ |
|
18 |
||
19 |
extern int _skip_sprites; |
|
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
|
20 |
extern int _replace_sprites_count[16]; |
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
|
21 |
extern int _replace_sprites_offset[16]; |
0 | 22 |
|
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
|
23 |
struct GRFFile { |
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
|
24 |
char *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
|
25 |
uint32 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
|
26 |
uint16 flags; |
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
|
27 |
uint16 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
|
28 |
struct GRFFile *next; |
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
|
29 |
}; |
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
|
30 |
|
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
|
31 |
static struct GRFFile *_cur_grffile, *_first_grffile; |
0 | 32 |
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
|
33 |
static int _cur_stage; |
0 | 34 |
|
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
|
35 |
static int32 _paramlist[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
|
36 |
static int _param_max; |
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
|
37 |
|
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
|
38 |
/* 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
|
39 |
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
|
40 |
|
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 |
|
0 | 42 |
typedef void (*SpecialSpriteHandler)(byte *buf, int len); |
43 |
||
44 |
static const int _vehshifts[4] = { |
|
45 |
0, |
|
46 |
ROAD_ENGINES_INDEX, |
|
47 |
SHIP_ENGINES_INDEX, |
|
48 |
AIRCRAFT_ENGINES_INDEX, |
|
49 |
}; |
|
50 |
||
51 |
||
52 |
enum grfmsg_severity { |
|
53 |
GMS_NOTICE, |
|
54 |
GMS_WARN, |
|
55 |
GMS_ERROR, |
|
56 |
GMS_FATAL, |
|
57 |
}; |
|
58 |
||
59 |
static void CDECL grfmsg(enum grfmsg_severity severity, const char *str, ...) |
|
60 |
{ |
|
61 |
static const char * const severitystr[4] = { "Notice", "Warning", "Error", "Fatal" }; |
|
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
51
diff
changeset
|
62 |
char buf[1024]; |
0 | 63 |
va_list va; |
64 |
||
65 |
va_start(va, str); |
|
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
51
diff
changeset
|
66 |
vsprintf(buf, str, va); |
0 | 67 |
va_end(va); |
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
|
68 |
DEBUG(grf, 2) ("[%s][%s] %s", _cur_grffile->filename, severitystr[severity], buf); |
0 | 69 |
} |
70 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
71 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
72 |
#define check_length(real, wanted, where) \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
73 |
do { \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
74 |
if (real < wanted) { \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
75 |
grfmsg(GMS_ERROR, "%s: Invalid special sprite length %d (expected %d)!", where, real, wanted); \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
76 |
return; \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
77 |
} \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
78 |
} while (0) |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
79 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
80 |
|
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
81 |
static byte INLINE grf_load_byte(byte **buf) |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
82 |
{ |
0 | 83 |
return *(*buf)++; |
84 |
} |
|
85 |
||
86 |
static uint16 grf_load_word(byte **buf) |
|
87 |
{ |
|
88 |
uint16 val; |
|
89 |
byte *p = *buf; |
|
90 |
val = p[0]; |
|
91 |
val |= p[1] << 8; |
|
92 |
*buf = p + 2; |
|
93 |
return val; |
|
94 |
} |
|
95 |
||
96 |
static uint16 grf_load_dword(byte **buf) |
|
97 |
{ |
|
98 |
uint32 val; |
|
99 |
byte *p = *buf; |
|
100 |
val = p[0]; |
|
101 |
val |= p[1] << 8; |
|
102 |
val |= p[2] << 16; |
|
103 |
val |= p[3] << 24; |
|
104 |
*buf = p + 4; |
|
105 |
return val; |
|
106 |
} |
|
107 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
108 |
|
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
|
109 |
static struct GRFFile *GetFileByGRFID(uint32 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
|
110 |
{ |
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
|
111 |
struct GRFFile *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
|
112 |
|
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
|
113 |
file = _first_grffile; |
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
|
114 |
while ((file != NULL) && (file->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
|
115 |
file = file->next; |
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
|
116 |
|
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
|
117 |
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
|
118 |
} |
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
|
119 |
|
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
120 |
static struct 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
|
121 |
{ |
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
|
122 |
struct GRFFile *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
|
123 |
|
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
|
124 |
file = _first_grffile; |
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
|
125 |
while ((file != NULL) && strcmp(file->filename, filename)) |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
126 |
file = file->next; |
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
|
127 |
|
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
|
128 |
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
|
129 |
} |
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
|
130 |
|
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
|
131 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
132 |
typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); |
0 | 133 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
134 |
#define FOR_EACH_ENGINE for (i = 0; i < numinfo; i++) |
0 | 135 |
|
136 |
static void dewagonize(int condition, int engine) |
|
137 |
{ |
|
138 |
EngineInfo *ei = &_engine_info[engine]; |
|
139 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
|
140 |
||
141 |
if (condition) { |
|
142 |
ei->unk2 &= ~0x80; |
|
143 |
rvi->flags &= ~2; |
|
144 |
} else { |
|
145 |
ei->unk2 |= 0x80; |
|
146 |
rvi->flags |= 2; |
|
147 |
} |
|
148 |
} |
|
149 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
150 |
static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 151 |
{ |
152 |
EngineInfo *ei = &_engine_info[engine]; |
|
153 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
|
154 |
byte *buf = *bufp; |
|
155 |
int i; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
156 |
bool ret = false; |
0 | 157 |
|
158 |
switch (prop) { |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
159 |
case 0x05: { /* Track type */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
160 |
FOR_EACH_ENGINE { |
0 | 161 |
uint8 tracktype = grf_load_byte(&buf); |
162 |
||
163 |
ei[i].railtype_climates &= 0xf; |
|
164 |
ei[i].railtype_climates |= tracktype << 4; |
|
165 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
166 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
167 |
case 0x08: { /* AI passenger service */ |
0 | 168 |
/* TODO */ |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
169 |
FOR_EACH_ENGINE { |
0 | 170 |
grf_load_byte(&buf); |
171 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
172 |
ret = true; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
173 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
174 |
case 0x09: { /* Speed */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
175 |
FOR_EACH_ENGINE { |
0 | 176 |
uint16 speed = grf_load_word(&buf); |
177 |
||
178 |
rvi[i].max_speed = speed; |
|
179 |
dewagonize(speed, engine + i); |
|
180 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
181 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
182 |
case 0x0B: { /* Power */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
183 |
FOR_EACH_ENGINE { |
0 | 184 |
uint16 power = grf_load_word(&buf); |
185 |
||
186 |
rvi[i].power = power; |
|
187 |
dewagonize(power, engine + i); |
|
188 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
189 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
190 |
case 0x0D: { /* Running cost factor */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
191 |
FOR_EACH_ENGINE { |
0 | 192 |
uint8 runcostfact = grf_load_byte(&buf); |
193 |
||
194 |
rvi[i].running_cost_base = runcostfact; |
|
195 |
dewagonize(runcostfact, engine + i); |
|
196 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
197 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
198 |
case 0x0E: { /* Running cost base */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
199 |
FOR_EACH_ENGINE { |
0 | 200 |
uint32 base = grf_load_dword(&buf); |
201 |
||
202 |
switch (base) { |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
203 |
case 0x4C30: |
0 | 204 |
rvi[i].engclass = 0; |
205 |
break; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
206 |
case 0x4C36: |
0 | 207 |
rvi[i].engclass = 1; |
208 |
break; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
209 |
case 0x4C3C: |
0 | 210 |
rvi[i].engclass = 2; |
211 |
break; |
|
212 |
} |
|
213 |
dewagonize(base, engine + i); |
|
214 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
215 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
216 |
case 0x12: { /* Sprite ID */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
217 |
FOR_EACH_ENGINE { |
0 | 218 |
uint8 spriteid = grf_load_byte(&buf); |
219 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
220 |
if (spriteid == 0xFD && rvi[i].image_index != 0xFD) |
0 | 221 |
_engine_original_sprites[engine + i] = rvi[i].image_index; |
222 |
rvi[i].image_index = spriteid; |
|
223 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
224 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
225 |
case 0x13: { /* Dual-headed */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
226 |
FOR_EACH_ENGINE { |
0 | 227 |
uint8 dual = grf_load_byte(&buf); |
228 |
||
229 |
if (dual) { |
|
230 |
rvi[i].flags |= 1; |
|
231 |
} else { |
|
232 |
rvi[i].flags &= ~1; |
|
233 |
} |
|
234 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
235 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
236 |
case 0x14: { /* Cargo capacity */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
237 |
FOR_EACH_ENGINE { |
0 | 238 |
uint8 capacity = grf_load_byte(&buf); |
239 |
||
240 |
rvi[i].capacity = capacity; |
|
241 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
242 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
243 |
case 0x15: { /* Cargo type */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
244 |
FOR_EACH_ENGINE { |
0 | 245 |
uint8 ctype = grf_load_byte(&buf); |
246 |
||
247 |
rvi[i].cargo_type = ctype; |
|
248 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
249 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
250 |
case 0x16: { /* Weight */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
251 |
FOR_EACH_ENGINE { |
0 | 252 |
uint8 weight = grf_load_byte(&buf); |
253 |
||
254 |
rvi[i].weight = weight; |
|
255 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
256 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
257 |
case 0x17: { /* Cost factor */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
258 |
FOR_EACH_ENGINE { |
0 | 259 |
uint8 cfactor = grf_load_byte(&buf); |
260 |
||
261 |
rvi[i].base_cost = cfactor; |
|
262 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
263 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
264 |
case 0x18: { /* AI rank */ |
0 | 265 |
/* TODO: _railveh_score should be merged to _rail_vehicle_info. */ |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
266 |
FOR_EACH_ENGINE { |
0 | 267 |
grf_load_byte(&buf); |
268 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
269 |
ret = true; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
270 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
271 |
case 0x19: { /* Engine traction type */ |
0 | 272 |
/* TODO: What do the individual numbers mean? |
273 |
* XXX: And in what base are they, in fact? --pasky */ |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
274 |
FOR_EACH_ENGINE { |
0 | 275 |
uint8 traction = grf_load_byte(&buf); |
276 |
int engclass; |
|
277 |
||
278 |
if (traction <= 0x07) |
|
279 |
engclass = 0; |
|
280 |
else if (traction <= 0x27) |
|
281 |
engclass = 1; |
|
282 |
else if (traction <= 0x31) |
|
283 |
engclass = 2; |
|
284 |
else |
|
285 |
break; |
|
286 |
||
287 |
rvi[i].engclass = engclass; |
|
288 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
289 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
290 |
|
0 | 291 |
/* TODO */ |
292 |
/* Fall-through for unimplemented four bytes long properties. */ |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
293 |
case 0x1D: /* Refit cargo */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
294 |
FOR_EACH_ENGINE { |
0 | 295 |
grf_load_word(&buf); |
296 |
} |
|
297 |
/* Fall-through for unimplemented two bytes long properties. */ |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
298 |
case 0x1B: /* Powered wagons power bonus */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
299 |
FOR_EACH_ENGINE { |
0 | 300 |
grf_load_byte(&buf); |
301 |
} |
|
302 |
/* 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
|
303 |
case 0x1A: /* Sort order */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
304 |
case 0x1C: /* Refit cost */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
305 |
case 0x1E: /* Callback */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
306 |
case 0x1F: /* Tractive effort */ |
0 | 307 |
case 0x21: /* Shorter tenders */ |
308 |
case 0x22: /* Visual */ |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
309 |
case 0x23: {/* Powered wagons weight bonus */ |
0 | 310 |
/* TODO */ |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
311 |
FOR_EACH_ENGINE { |
0 | 312 |
grf_load_byte(&buf); |
313 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
314 |
ret = true; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
315 |
} break; |
0 | 316 |
default: |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
317 |
ret = true; |
0 | 318 |
} |
319 |
*bufp = buf; |
|
320 |
return ret; |
|
321 |
} |
|
322 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
323 |
static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 324 |
{ |
325 |
ShipVehicleInfo *svi = &_ship_vehicle_info[engine]; |
|
326 |
byte *buf = *bufp; |
|
327 |
int i; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
328 |
bool ret = false; |
0 | 329 |
|
330 |
//printf("e %x prop %x?\n", engine, prop); |
|
331 |
switch (prop) { |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
332 |
case 0x08: { /* Sprite ID */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
333 |
FOR_EACH_ENGINE { |
0 | 334 |
uint8 spriteid = grf_load_byte(&buf); |
335 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
336 |
if (spriteid == 0xFF) |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
337 |
spriteid = 0xFD; // ships have different custom id in the GRF file |
0 | 338 |
|
339 |
// This is currently not used but there's no reason |
|
340 |
// 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
|
341 |
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
|
342 |
_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
|
343 |
|
0 | 344 |
svi[i].image_index = spriteid; |
345 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
346 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
347 |
case 0x09: { /* Refittable */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
348 |
FOR_EACH_ENGINE { |
0 | 349 |
uint8 refittable = grf_load_byte(&buf); |
350 |
||
351 |
svi[i].refittable = refittable; |
|
352 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
353 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
354 |
case 0x0A: { /* Cost factor */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
355 |
FOR_EACH_ENGINE { |
0 | 356 |
uint8 cost_factor = grf_load_byte(&buf); |
357 |
||
358 |
svi[i].base_cost = cost_factor; // ?? is it base_cost? |
|
359 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
360 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
361 |
case 0x0B: { /* Speed */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
362 |
FOR_EACH_ENGINE { |
0 | 363 |
uint8 speed = grf_load_byte(&buf); |
364 |
||
365 |
svi[i].max_speed = speed; // ?? units |
|
366 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
367 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
368 |
case 0x0C: { /* Cargo type */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
369 |
FOR_EACH_ENGINE { |
0 | 370 |
uint8 cargo = grf_load_byte(&buf); |
371 |
||
372 |
// XXX: Need to consult this with patchman yet. |
|
373 |
#if 0 |
|
374 |
// Documentation claims this is already the |
|
375 |
// per-landscape cargo type id, but newships.grf |
|
376 |
// assume otherwise. |
|
377 |
cargo = local_cargo_id_ctype[cargo]; |
|
378 |
#endif |
|
379 |
svi[i].cargo_type = cargo; |
|
380 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
381 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
382 |
case 0x0D: { /* Cargo capacity */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
383 |
FOR_EACH_ENGINE { |
0 | 384 |
uint16 capacity = grf_load_word(&buf); |
385 |
||
386 |
svi[i].capacity = capacity; |
|
387 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
388 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
389 |
case 0x0F: { /* Running cost factor */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
390 |
FOR_EACH_ENGINE { |
0 | 391 |
uint8 runcost = grf_load_byte(&buf); |
392 |
||
393 |
svi[i].running_cost = runcost; |
|
394 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
395 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
396 |
case 0x10: { /* SFX */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
397 |
FOR_EACH_ENGINE { |
0 | 398 |
uint8 sfx = grf_load_byte(&buf); |
399 |
||
400 |
svi[i].sfx = sfx; |
|
401 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
402 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
403 |
case 0x11: { /* Cargos available for refitting */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
404 |
FOR_EACH_ENGINE { |
0 | 405 |
uint32 refit_mask = grf_load_dword(&buf); |
406 |
||
407 |
_engine_refit_masks[SHIP_ENGINES_INDEX + engine + i] = refit_mask; |
|
408 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
409 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
410 |
case 0x12: { /* Callback TODO */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
411 |
ret = true; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
412 |
} break; |
0 | 413 |
default: |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
414 |
ret = true; |
0 | 415 |
} |
416 |
||
417 |
*bufp = buf; |
|
418 |
return ret; |
|
419 |
} |
|
420 |
||
421 |
#undef shift_buf |
|
422 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
423 |
/* Action 0x00 */ |
0 | 424 |
static void VehicleChangeInfo(byte *buf, int len) |
425 |
{ |
|
426 |
byte *bufend = buf + len; |
|
427 |
int i; |
|
428 |
||
429 |
/* <00> <feature> <num-props> <num-info> <id> (<property <new-info>)... |
|
430 |
* |
|
431 |
* B feature 0, 1, 2 or 3 for trains, road vehicles, ships or planes |
|
432 |
* 4 for defining new train station sets |
|
433 |
* B num-props how many properties to change per vehicle/station |
|
434 |
* B num-info how many vehicles/stations to change |
|
435 |
* B id ID of first vehicle/station to change, if num-info is |
|
436 |
* greater than one, this one and the following |
|
437 |
* vehicles/stations will be changed |
|
438 |
* B property what property to change, depends on the feature |
|
439 |
* V new-info new bytes of info (variable size; depends on properties) */ |
|
440 |
/* TODO: Only trains and ships are supported for now. */ |
|
441 |
||
442 |
static const VCI_Handler handler[5] = { |
|
443 |
RailVehicleChangeInfo, |
|
444 |
NULL, |
|
445 |
ShipVehicleChangeInfo, |
|
446 |
NULL, |
|
447 |
NULL, |
|
448 |
}; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
449 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
450 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
451 |
uint8 numprops; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
452 |
uint8 numinfo; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
453 |
byte engine; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
454 |
EngineInfo *ei; |
0 | 455 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
456 |
check_length(len, 6, "VehicleChangeInfo"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
457 |
feature = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
458 |
numprops = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
459 |
numinfo = buf[3]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
460 |
engine = buf[4]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
461 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
462 |
if (feature != 0 && feature != 2) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
463 |
grfmsg(GMS_WARN, "VehicleChangeInfo: Unsupported vehicle type %x, skipping.", feature); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
464 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
465 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
466 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
467 |
ei = &_engine_info[engine + _vehshifts[feature]]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
468 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
469 |
buf += 5; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
470 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
471 |
while (numprops-- && buf < bufend) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
472 |
uint8 prop = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
473 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
474 |
switch (prop) { |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
475 |
case 0x00: { /* Introduction date */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
476 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
477 |
uint16 date = grf_load_word(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
478 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
479 |
ei[i].base_intro = date; |
0 | 480 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
481 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
482 |
case 0x02: { /* Decay speed */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
483 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
484 |
uint8 decay = grf_load_byte(&buf); |
0 | 485 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
486 |
ei[i].unk2 &= 0x80; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
487 |
ei[i].unk2 |= decay & 0x7f; |
0 | 488 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
489 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
490 |
case 0x03: { /* Vehicle life */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
491 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
492 |
uint8 life = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
493 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
494 |
ei[i].lifelength = life; |
0 | 495 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
496 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
497 |
case 0x04: { /* Model life */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
498 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
499 |
uint8 life = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
500 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
501 |
ei[i].base_life = life; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
502 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
503 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
504 |
case 0x06: { /* Climates available */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
505 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
506 |
uint8 climates = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
507 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
508 |
ei[i].railtype_climates &= 0xf0; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
509 |
ei[i].railtype_climates |= climates; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
510 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
511 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
512 |
case 0x07: { /* Loading spee */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
513 |
/* TODO */ |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
514 |
/* Hyronymus explained me what does |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
515 |
* this mean and insists on having a |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
516 |
* credit ;-). --pasky */ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
517 |
/* TODO: This needs to be supported by |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
518 |
* LoadUnloadVehicle() first. */ |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
519 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
520 |
grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
521 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
522 |
goto ignoring; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
523 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
524 |
default: { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
525 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) { |
0 | 526 |
ignoring: |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
527 |
grfmsg(GMS_NOTICE, "VehicleChangeInfo: Ignoring property %x (not implemented).", prop); |
0 | 528 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
529 |
break; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
530 |
} |
0 | 531 |
} |
532 |
} |
|
533 |
#undef shift_buf |
|
534 |
} |
|
535 |
||
536 |
||
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
537 |
/* A sprite group contains all sprites of a given vehicle (or multiple |
0 | 538 |
* vehicles) when carrying given cargo. It consists of several sprite sets. |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
539 |
* Group ids are refered as "cargo id"s by TTDPatch documentation, |
0 | 540 |
* contributing to the global confusion. |
541 |
* |
|
542 |
* A sprite set contains all sprites of a given vehicle carrying given cargo at |
|
543 |
* a given *stage* - that is usually its load stage. Ie. you can have a |
|
544 |
* spriteset for an empty wagon, wagon full of coal, half-filled wagon etc. |
|
545 |
* Each spriteset contains eight sprites (one per direction) or four sprites if |
|
546 |
* the vehicle is symmetric. */ |
|
547 |
||
548 |
static int _spriteset_start; |
|
549 |
static int _spriteset_numsets; |
|
550 |
static int _spriteset_numents; |
|
551 |
static int _spriteset_feature; |
|
552 |
||
553 |
static int _spritesset_count; |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
554 |
static struct SpriteGroup *_spritesset; |
0 | 555 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
556 |
/* 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
|
557 |
static void NewSpriteSet(byte *buf, int len) |
0 | 558 |
{ |
559 |
/* <01> <feature> <num-sets> <num-ent> |
|
560 |
* |
|
561 |
* B feature feature to define sprites for |
|
562 |
* 0, 1, 2, 3: veh-type, 4: train stations |
|
563 |
* B num-sets number of sprite sets |
|
564 |
* B num-ent how many entries per sprite set |
|
565 |
* For vehicles, this is the number of different |
|
566 |
* vehicle directions in each sprite set |
|
567 |
* Set num-dirs=8, unless your sprites are symmetric. |
|
568 |
* In that case, use num-dirs=4. |
|
569 |
* For stations, must be 12 (hex) for the eighteen |
|
570 |
* different sprites that make up a station */ |
|
571 |
/* TODO: No stations support. */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
572 |
uint8 feature; |
0 | 573 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
574 |
check_length(len, 4, "SpriteNewSet"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
575 |
feature = buf[1]; |
0 | 576 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
577 |
if (feature == 4) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
578 |
_spriteset_start = 0; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
579 |
grfmsg(GMS_WARN, "SpriteNewSet: Stations unsupported, skipping."); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
580 |
return; |
0 | 581 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
582 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
583 |
_spriteset_start = _cur_spriteid + 1; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
584 |
_spriteset_feature = feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
585 |
_spriteset_numsets = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
586 |
_spriteset_numents = buf[3]; |
0 | 587 |
} |
588 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
589 |
/* 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
|
590 |
static void NewSpriteGroup(byte *buf, int len) |
0 | 591 |
{ |
592 |
byte *bufend = buf + len; |
|
593 |
||
594 |
/* <02> <feature> <set-id> <type/num-entries> <feature-specific-data...> |
|
595 |
* |
|
596 |
* B feature see action 1 |
|
597 |
* B set-id ID of this particular definition |
|
598 |
* B type/num-entries |
|
599 |
* if 80 or greater, this is a randomized or variational |
|
600 |
* list definition, see below |
|
601 |
* otherwise it specifies a number of entries, the exact |
|
602 |
* meaning depends on the feature |
|
603 |
* V feature-specific-data (huge mess, don't even look it up --pasky) */ |
|
604 |
/* TODO: Only trains supported now. No 0x80-types (ugh). */ |
|
605 |
/* TODO: Also, empty sprites aren't handled for now. Need to investigate |
|
606 |
* the "opacity" rules for these, that is which sprite to fall back to |
|
607 |
* when. --pasky */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
608 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
609 |
uint8 setid; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
610 |
uint8 numloaded; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
611 |
uint8 numloading; |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
612 |
struct SpriteGroup *group; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
613 |
int i; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
614 |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
615 |
check_length(len, 5, "SpriteNewGroup"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
616 |
feature = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
617 |
setid = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
618 |
numloaded = buf[3]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
619 |
numloading = buf[4]; |
0 | 620 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
621 |
if (feature == 4) { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
622 |
grfmsg(GMS_WARN, "SpriteNewGroup: Stations unsupported, skipping."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
623 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
624 |
} |
0 | 625 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
626 |
if (numloaded == 0x81) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
627 |
// XXX: This is _VERY_ ad hoc just to handle Dm3. And that is |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
628 |
// a semi-futile ask because the great Patchman himself says |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
629 |
// this is just buggy. It dereferences last (first) byte of |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
630 |
// a schedule list pointer of the vehicle and if it's 0xff |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
631 |
// it uses group 01, otherwise it uses group 00. Now |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
632 |
// if _you_ understand _that_... We just assume it is never |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
633 |
// 0xff and therefore go for group 00. --pasky |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
634 |
uint8 var = buf[4]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
635 |
//uint8 shiftnum = buf[5]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
636 |
//uint8 andmask = buf[6]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
637 |
uint8 nvar = buf[7]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
638 |
//uint32 val; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
639 |
uint16 def; |
0 | 640 |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
641 |
grfmsg(GMS_WARN, "SpriteNewGroup(0x81): Unsupported variable %x. Using default cid.", var); |
0 | 642 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
643 |
//val = (0xff << shiftnum) & andmask; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
644 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
645 |
//Go for the default. |
0 | 646 |
if (setid >= _spritesset_count) { |
647 |
_spritesset_count = setid + 1; |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
648 |
_spritesset = realloc(_spritesset, _spritesset_count * sizeof(struct SpriteGroup)); |
0 | 649 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
650 |
buf += 8 + nvar * 4; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
651 |
def = grf_load_word(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
652 |
_spritesset[setid] = _spritesset[def]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
653 |
return; |
0 | 654 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
655 |
} else if (numloaded & 0x80) { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
656 |
grfmsg(GMS_WARN, "SpriteNewGroup(0x%x): Unsupported special group.", numloaded); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
657 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
658 |
} |
0 | 659 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
660 |
if (!_spriteset_start) { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
661 |
grfmsg(GMS_WARN, "SpriteNewGroup: No sprite set to work on! Skipping."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
662 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
663 |
} |
0 | 664 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
665 |
if (_spriteset_feature != feature) { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
666 |
grfmsg(GMS_WARN, "SpriteNewGroup: Group feature %x doesn't match set feature %x! Skipping.", feature, _spriteset_feature); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
667 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
668 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
669 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
670 |
if (setid >= _spritesset_count) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
671 |
_spritesset_count = setid + 1; |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
672 |
_spritesset = realloc(_spritesset, _spritesset_count * sizeof(struct SpriteGroup)); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
673 |
} |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
674 |
group = &_spritesset[setid]; |
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
675 |
memset(group, 0, sizeof(struct SpriteGroup)); |
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
676 |
group->sprites_per_set = _spriteset_numents; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
677 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
678 |
buf += 5; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
679 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
680 |
for (i = 0; buf < bufend && i < numloaded; i++) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
681 |
uint16 spriteset_id = grf_load_word(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
682 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
683 |
if (_spritesset[setid].loaded_count > 16) { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
684 |
grfmsg(GMS_WARN, "SpriteNewGroup: More than 16 sprites in group %x, skipping.", setid); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
685 |
return; |
0 | 686 |
} |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
687 |
group->loaded[group->loaded_count++] |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
688 |
= _spriteset_start + spriteset_id * _spriteset_numents; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
689 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
690 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
691 |
for (i = 0; buf < bufend && i < numloading; i++) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
692 |
uint16 spriteset_id = grf_load_word(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
693 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
694 |
if (_spritesset[setid].loading_count > 16) { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
695 |
grfmsg(GMS_WARN, "SpriteNewGroup: More than 16 sprites in group %x, skipping.", setid); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
696 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
697 |
} |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
698 |
group->loading[group->loading_count++] = _spriteset_start + spriteset_id * _spriteset_numents; |
0 | 699 |
} |
700 |
} |
|
701 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
702 |
/* 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
|
703 |
static void NewVehicle_SpriteGroupMapping(byte *buf, int len) |
0 | 704 |
{ |
705 |
/* <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
|
706 |
* id-list := [<id>] [id-list] |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
707 |
* cargo-list := <cargo-type> <cid> [cargo-list] |
0 | 708 |
* |
709 |
* B feature see action 0 |
|
710 |
* B n-id bits 0-6: how many IDs this definition applies to |
|
711 |
* bit 7: if set, this is a wagon override definition (see below) |
|
712 |
* 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
|
713 |
* B num-cid number of cargo IDs (sprite group IDs) in this definition |
0 | 714 |
* can be zero, in that case the def-cid is used always |
715 |
* 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
|
716 |
* 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
|
717 |
* W def-cid default cargo ID (sprite group ID) */ |
0 | 718 |
/* TODO: Only trains supported now. */ |
719 |
/* TODO: Multiple cargo support could be useful even for trains/cars - |
|
720 |
* cargo id 0xff is used for showing images in the build train list. */ |
|
721 |
||
722 |
static byte *last_engines; |
|
723 |
static int last_engines_count; |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
724 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
725 |
uint8 idcount; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
726 |
int wagover; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
727 |
uint8 cidcount; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
728 |
int c, i; |
0 | 729 |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
730 |
check_length(len, 7, "VehicleMapSpriteGroup"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
731 |
feature = buf[1]; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
732 |
idcount = buf[2] & 0x7F; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
733 |
wagover = buf[2] & 0x80; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
734 |
cidcount = buf[3 + idcount]; |
0 | 735 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
736 |
if (feature == 4) { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
737 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Stations unsupported, skipping."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
738 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
739 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
740 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
741 |
// FIXME: Tropicset contains things like: |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
742 |
// 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
|
743 |
// what should we exactly do with that? --pasky |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
744 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
745 |
if (!_spriteset_start || !_spritesset) { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
746 |
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
|
747 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
748 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
749 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
750 |
if (!wagover && last_engines_count != idcount) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
751 |
last_engines = realloc(last_engines, idcount); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
752 |
last_engines_count = idcount; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
753 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
754 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
755 |
for (i = 0; i < idcount; i++) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
756 |
uint8 engine = buf[3 + i] + _vehshifts[feature]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
757 |
byte *bp = &buf[4 + idcount]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
758 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
759 |
for (c = 0; c < cidcount; c++) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
760 |
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
|
761 |
uint16 groupid = grf_load_word(&bp); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
762 |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
763 |
if (groupid >= _spritesset_count) { |
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
764 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x, skipping.", groupid, _spritesset_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
765 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
766 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
767 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
768 |
if (ctype == 0xFF) |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
769 |
ctype = CID_PURCHASE; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
770 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
771 |
if (wagover) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
772 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
773 |
SetWagonOverrideSprites(engine, &_spritesset[groupid], last_engines, last_engines_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
774 |
} else { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
775 |
SetCustomEngineSprites(engine, ctype, &_spritesset[groupid]); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
776 |
last_engines[i] = engine; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
777 |
} |
0 | 778 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
779 |
} |
0 | 780 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
781 |
{ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
782 |
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
|
783 |
uint16 groupid = grf_load_word(&bp); |
0 | 784 |
|
785 |
for (i = 0; i < idcount; i++) { |
|
786 |
uint8 engine = buf[3 + i] + _vehshifts[feature]; |
|
787 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
788 |
// Don't tell me you don't love duplicated code! |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
789 |
if (groupid >= _spritesset_count) { |
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
790 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x, skipping.", groupid, _spritesset_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
791 |
return; |
0 | 792 |
} |
793 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
794 |
if (wagover) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
795 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
796 |
SetWagonOverrideSprites(engine, &_spritesset[groupid], last_engines, last_engines_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
797 |
} else { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
798 |
SetCustomEngineSprites(engine, CID_DEFAULT, &_spritesset[groupid]); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
799 |
last_engines[i] = engine; |
0 | 800 |
} |
801 |
} |
|
802 |
} |
|
803 |
} |
|
804 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
805 |
/* Action 0x04 */ |
0 | 806 |
static void VehicleNewName(byte *buf, int len) |
807 |
{ |
|
808 |
/* <04> <veh-type> <language-id> <num-veh> <offset> <data...> |
|
809 |
* |
|
810 |
* B veh-type see action 0 |
|
811 |
* B language-id language ID with bit 7 cleared (see below) |
|
812 |
* B num-veh number of vehicles which are getting a new name |
|
813 |
* B offset number of the first vehicle that gets a new name |
|
814 |
* S data new texts, each of them zero-terminated, after |
|
815 |
* which the next name begins. */ |
|
816 |
/* TODO: No support for changing non-vehicle text. Perhaps we shouldn't |
|
817 |
* implement it at all, but it could be useful for some "modpacks" |
|
818 |
* (completely new scenarios changing all graphics and logically also |
|
819 |
* factory names etc). We should then also support all languages (by |
|
820 |
* name), not only the original four ones. --pasky */ |
|
821 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
822 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
823 |
uint8 lang; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
824 |
uint8 id; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
825 |
uint8 endid; |
0 | 826 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
827 |
check_length(len, 6, "VehicleNewName"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
828 |
feature = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
829 |
lang = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
830 |
id = buf[4] + _vehshifts[feature]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
831 |
endid = id + buf[3]; |
0 | 832 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
833 |
if (lang & 0x80) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
834 |
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
|
835 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
836 |
} |
0 | 837 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
838 |
if (!(lang & 3)) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
839 |
/* XXX: If non-English name, silently skip it. */ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
840 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
841 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
842 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
843 |
buf += 5, len -= 5; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
844 |
for (; id < endid && len > 0; id++) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
845 |
int ofs = strlen(buf) + 1; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
846 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
847 |
if (ofs < 128) |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
848 |
SetCustomEngineName(id, buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
849 |
buf += ofs, len -= ofs; |
0 | 850 |
} |
851 |
} |
|
852 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
853 |
/* Action 0x05 */ |
0 | 854 |
static void GraphicsNew(byte *buf, int len) |
855 |
{ |
|
856 |
/* <05> <graphics-type> <num-sprites> <other data...> |
|
857 |
* |
|
858 |
* B graphics-type What set of graphics the sprites define. |
|
859 |
* B num-sprites How many sprites are in this set? |
|
860 |
* V other data Graphics type specific data. Currently unused. */ |
|
861 |
/* TODO */ |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
862 |
|
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
863 |
uint8 type; |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
864 |
uint8 num; |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
865 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
866 |
check_length(len, 2, "GraphicsNew"); |
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
867 |
type = buf[0]; |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
868 |
num = buf[1]; |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
869 |
|
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
870 |
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
|
871 |
type, num); |
0 | 872 |
} |
873 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
874 |
/* Action 0x06 */ |
0 | 875 |
static void CfgApply(byte *buf, int len) |
876 |
{ |
|
877 |
/* <06> <param-num> <param-size> <offset> ... <FF> |
|
878 |
* |
|
879 |
* B param-num Number of parameter to substitute (First = "zero") |
|
880 |
* Ignored if that parameter was not specified in newgrf.cfg |
|
881 |
* B param-size How many bytes to replace. If larger than 4, the |
|
882 |
* bytes of the following parameter are used. In that |
|
883 |
* case, nothing is applied unless *all* parameters |
|
884 |
* were specified. |
|
885 |
* B offset Offset into data from beginning of next sprite |
|
886 |
* to place where parameter is to be stored. */ |
|
887 |
/* TODO */ |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
888 |
grfmsg(GMS_NOTICE, "CfgApply: Ignoring (not implemented).\n"); |
0 | 889 |
} |
890 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
891 |
/* Action 0x07 */ |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
892 |
/* Action 0x09 */ |
0 | 893 |
static void SkipIf(byte *buf, int len) |
894 |
{ |
|
895 |
/* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites> |
|
896 |
* |
|
897 |
* B param-num |
|
898 |
* B param-size |
|
899 |
* B condition-type |
|
900 |
* V value |
|
901 |
* B num-sprites */ |
|
902 |
/* TODO: More params. More condition types. */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
903 |
uint8 param; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
904 |
uint8 paramsize; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
905 |
uint8 condtype; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
906 |
uint8 numsprites; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
907 |
int param_val = 0, cond_val = 0; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
908 |
bool result; |
0 | 909 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
910 |
check_length(len, 6, "SkipIf"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
911 |
param = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
912 |
paramsize = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
913 |
condtype = buf[3]; |
0 | 914 |
|
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
|
915 |
if (condtype < 2) { |
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
|
916 |
/* Always 1 for bit tests, the given value should |
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
|
917 |
* be ignored. */ |
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
|
918 |
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
|
919 |
} |
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
|
920 |
|
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
|
921 |
buf += 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
|
922 |
if (paramsize == 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
|
923 |
cond_val = grf_load_dword(&buf); |
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
|
924 |
else if (paramsize == 2) |
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
|
925 |
cond_val = grf_load_word(&buf); |
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
|
926 |
else if (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
|
927 |
cond_val = grf_load_byte(&buf); |
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
|
928 |
|
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
|
929 |
switch (param) { |
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
|
930 |
case 0x83: |
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
|
931 |
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
|
932 |
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
|
933 |
case 0x84: |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
934 |
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
|
935 |
break; |
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
|
936 |
case 0x85: |
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
|
937 |
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
|
938 |
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
|
939 |
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
|
940 |
case 0x86: |
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
|
941 |
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
|
942 |
break; |
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
|
943 |
case 0x88: { |
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
|
944 |
struct GRFFile *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
|
945 |
|
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
|
946 |
file = GetFileByGRFID(cond_val); |
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
|
947 |
param_val = (file != 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
|
948 |
} 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
|
949 |
default: |
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
|
950 |
if (param >= 0x80) { |
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
|
951 |
/* In-game variable. */ |
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
|
952 |
grfmsg(GMS_WARN, "Unsupported in-game variable %x. Ignoring test.", param); |
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
|
953 |
} 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
|
954 |
/* Parameter. */ |
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
|
955 |
param_val = _paramlist[param]; |
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
|
956 |
} |
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
|
957 |
return; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
958 |
} |
0 | 959 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
960 |
switch (condtype) { |
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
|
961 |
case 0: result = (param_val & (1 << cond_val)); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
962 |
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
|
963 |
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
|
964 |
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
|
965 |
/* 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
|
966 |
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
|
967 |
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
|
968 |
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
|
969 |
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
|
970 |
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
|
971 |
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
|
972 |
case 5: result = (param_val > cond_val); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
973 |
break; |
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
|
974 |
case 6: result = param_val; /* GRFID is 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
|
975 |
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
|
976 |
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
|
977 |
break; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
978 |
default: |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
979 |
grfmsg(GMS_WARN, "Unsupported test %d. Ignoring.", condtype); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
980 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
981 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
982 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
983 |
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
|
984 |
grfmsg(GMS_NOTICE, "Not skipping sprites, test was false."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
985 |
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
|
986 |
} |
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
|
987 |
|
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
|
988 |
numsprites = grf_load_byte(&buf); |
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
|
989 |
grfmsg(GMS_NOTICE, "Skipping %d sprites, test was true.", numsprites); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
990 |
_skip_sprites = numsprites; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
991 |
if (_skip_sprites == 0) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
992 |
/* Zero means there are no sprites to skip, so |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
993 |
* we use -1 to indicate that all further |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
994 |
* sprites should be skipped. */ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
995 |
_skip_sprites = -1; |
0 | 996 |
} |
997 |
} |
|
998 |
||
999 |
static void GRFInfo(byte *buf, int len) |
|
1000 |
{ |
|
1001 |
/* <08> <version> <grf-id> <name> <info> |
|
1002 |
* |
|
1003 |
* B version newgrf version, currently 06 |
|
1004 |
* 4*B grf-id globally unique ID of this .grf file |
|
1005 |
* S name name of this .grf set |
|
1006 |
* S info string describing the set, and e.g. author and copyright */ |
|
1007 |
/* TODO: Check version. (We should have own versioning done somehow.) */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1008 |
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
|
1009 |
uint32 grfid; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1010 |
char *name; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1011 |
char *info; |
0 | 1012 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1013 |
check_length(len, 9, "GRFInfo"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1014 |
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
|
1015 |
/* this is de facto big endian - grf_load_dword() unsuitable */ |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1016 |
grfid = buf[2] << 24 | buf[3] << 16 | buf[4] << 8 | buf[5]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1017 |
name = buf + 6; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1018 |
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
|
1019 |
|
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
|
1020 |
_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
|
1021 |
_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
|
1022 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1023 |
DEBUG(grf, 1) ("[%s] Loaded GRFv%d set %08lx - %s:\n%s\n", |
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
|
1024 |
_cur_grffile->filename, version, grfid, name, info); |
0 | 1025 |
} |
1026 |
||
1027 |
static void SpriteReplace(byte *buf, int len) |
|
1028 |
{ |
|
1029 |
/* <0A> <num-sets> <set1> [<set2> ...] |
|
1030 |
* <set>: <num-sprites> <first-sprite> |
|
1031 |
* |
|
1032 |
* B num-sets How many sets of sprites to replace. |
|
1033 |
* Each set: |
|
1034 |
* B num-sprites How many sprites are in this set |
|
1035 |
* 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
|
1036 |
uint8 num_sets; |
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
|
1037 |
int i; |
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
|
1038 |
|
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
|
1039 |
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
|
1040 |
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
|
1041 |
|
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
|
1042 |
if (num_sets > 16) { |
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
|
1043 |
grfmsg(GMS_ERROR, "SpriteReplace: Too many sets (%d), taking only the first 16!", num_sets); |
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
|
1044 |
} |
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
|
1045 |
|
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
|
1046 |
for (i = 0; i < 16; i++) { |
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
|
1047 |
if (i < num_sets) { |
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
|
1048 |
uint8 num_sprites = 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
|
1049 |
uint16 first_sprite = grf_load_word(&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
|
1050 |
|
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
|
1051 |
_replace_sprites_count[i] = num_sprites; |
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
|
1052 |
_replace_sprites_offset[i] = first_sprite; |
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
|
1053 |
grfmsg(GMS_NOTICE, "SpriteReplace: [Set %d] Changing %d sprites, beginning with %d", |
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
|
1054 |
i, num_sprites, first_sprite); |
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
|
1055 |
} else { |
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
|
1056 |
_replace_sprites_count[i] = 0; |
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
|
1057 |
_replace_sprites_offset[i] = 0; |
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
|
1058 |
} |
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
|
1059 |
} |
0 | 1060 |
} |
1061 |
||
1062 |
static void GRFError(byte *buf, int len) |
|
1063 |
{ |
|
1064 |
/* <0B> <severity> <language-id> <message-id> [<message...> 00] [<data...>] 00 [<parnum>] |
|
1065 |
* |
|
1066 |
* B severity 00: notice, contine loading grf file |
|
1067 |
* 01: warning, continue loading grf file |
|
1068 |
* 02: error, but continue loading grf file, and attempt |
|
1069 |
* loading grf again when loading or starting next game |
|
1070 |
* 03: error, abort loading and prevent loading again in |
|
1071 |
* the future (only when restarting the patch) |
|
1072 |
* B language-id see action 4, use 1F for built-in error messages |
|
1073 |
* B message-id message to show, see below |
|
1074 |
* S message for custom messages (message-id FF), text of the message |
|
1075 |
* not present for built-in messages. |
|
1076 |
* V data additional data for built-in (or custom) messages |
|
1077 |
* B parnum see action 6, only used with built-in message 03 */ |
|
1078 |
/* TODO: For now we just show the message, sometimes incomplete and never translated. */ |
|
1079 |
||
1080 |
static const char * const msgstr[4] = { |
|
1081 |
"Requires at least pseudo-TTDPatch version %s.", |
|
1082 |
"This file is for %s version of TTD.", |
|
1083 |
"Designed to be used with %s.", |
|
1084 |
"Invalid parameter %s.", |
|
1085 |
}; |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1086 |
uint8 severity; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1087 |
uint8 msgid; |
0 | 1088 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1089 |
check_length(len, 6, "GRFError"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1090 |
severity = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1091 |
msgid = buf[3]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1092 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1093 |
if (msgid == 0xFF) { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1094 |
grfmsg(severity, "%s", buf+4); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1095 |
} else { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1096 |
grfmsg(severity, msgstr[msgid], buf+4); |
0 | 1097 |
} |
1098 |
} |
|
1099 |
||
1100 |
static void GRFComment(byte *buf, int len) |
|
1101 |
{ |
|
1102 |
/* <0C> [<ignored...>] |
|
1103 |
* |
|
1104 |
* V ignored Anything following the 0C is ignored */ |
|
1105 |
} |
|
1106 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1107 |
/* Action 0x0D */ |
0 | 1108 |
static void ParamSet(byte *buf, int len) |
1109 |
{ |
|
1110 |
/* <0D> <target> <operation> <source1> <source2> [<data>] |
|
1111 |
* |
|
1112 |
* B target parameter number where result is stored |
|
1113 |
* B operation operation to perform, see below |
|
1114 |
* B source1 first source operand |
|
1115 |
* B source2 second source operand |
|
1116 |
* D data data to use in the calculation, not necessary |
|
1117 |
* if both source1 and source2 refer to actual parameters |
|
1118 |
* |
|
1119 |
* Operations |
|
1120 |
* 00 Set parameter equal to source1 |
|
1121 |
* 01 Addition, source1 + source2 |
|
1122 |
* 02 Subtraction, source1 - source2 |
|
1123 |
* 03 Unsigned multiplication, source1 * source2 (both unsigned) |
|
1124 |
* 04 Signed multiplication, source1 * source2 (both signed) |
|
1125 |
* 05 Unsigned bit shift, source1 by source2 (source2 taken to be a |
|
1126 |
* signed quantity; left shift if positive and right shift if |
|
1127 |
* negative, source1 is unsigned) |
|
1128 |
* 06 Signed bit shift, source1 by source2 |
|
1129 |
* (source2 like in 05, and source1 as well) |
|
1130 |
*/ |
|
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
|
1131 |
|
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
|
1132 |
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
|
1133 |
byte 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
|
1134 |
uint16 src1; |
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
|
1135 |
uint16 src2; |
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
|
1136 |
uint16 data = 0; |
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
|
1137 |
|
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
|
1138 |
check_length(len, 5, "ParamSet"); |
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
|
1139 |
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
|
1140 |
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
|
1141 |
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
|
1142 |
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
|
1143 |
|
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
|
1144 |
if (len >= 8) |
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
|
1145 |
data = grf_load_dword(&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
|
1146 |
|
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
|
1147 |
/* 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
|
1148 |
* 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
|
1149 |
* 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
|
1150 |
* - 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
|
1151 |
* - 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
|
1152 |
* 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
|
1153 |
if (oper & 0x80) { |
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
|
1154 |
if (_param_max < 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
|
1155 |
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
|
1156 |
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
|
1157 |
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
|
1158 |
} |
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
|
1159 |
|
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
|
1160 |
/* 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
|
1161 |
* 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
|
1162 |
* 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
|
1163 |
* 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
|
1164 |
* 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
|
1165 |
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
|
1166 |
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
|
1167 |
} 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
|
1168 |
src1 = _param_max >= src1 ? _paramlist[src1] : 0; |
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
|
1169 |
} |
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
|
1170 |
|
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
|
1171 |
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
|
1172 |
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
|
1173 |
} 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
|
1174 |
src2 = _param_max >= src2 ? _paramlist[src2] : 0; |
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
|
1175 |
} |
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
|
1176 |
|
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
|
1177 |
/* 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
|
1178 |
* 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
|
1179 |
* 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
|
1180 |
* 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
|
1181 |
* 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
|
1182 |
|
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
|
1183 |
/* TODO: The target operand can also refer to the special variables |
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
|
1184 |
* from action 7, but at the moment the only variable that is valid to |
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
|
1185 |
* write is 8E. */ |
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
|
1186 |
|
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
|
1187 |
if (_param_max < 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
|
1188 |
_param_max = 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
|
1189 |
|
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
|
1190 |
/* FIXME: No checking for overflows. */ |
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
|
1191 |
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
|
1192 |
case 0x00: |
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
|
1193 |
_paramlist[target] = src1; |
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
|
1194 |
break; |
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
|
1195 |
case 0x01: |
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
|
1196 |
_paramlist[target] = src1 + src2; |
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
|
1197 |
break; |
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
|
1198 |
case 0x02: |
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
|
1199 |
_paramlist[target] = src1 - src2; |
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
|
1200 |
break; |
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
|
1201 |
case 0x03: |
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
|
1202 |
_paramlist[target] = ((uint32) src1) * ((uint32) src2); |
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
|
1203 |
break; |
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
|
1204 |
case 0x04: |
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
|
1205 |
_paramlist[target] = ((int32) src1) * ((int32) src2); |
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
|
1206 |
break; |
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
|
1207 |
case 0x05: |
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
|
1208 |
if (src2 & 0x8000) /* src2 is "negative" */ |
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
|
1209 |
_paramlist[target] = src1 >> -((int16) src2); |
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
|
1210 |
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
|
1211 |
_paramlist[target] = src1 << src2; |
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
|
1212 |
break; |
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
|
1213 |
case 0x06: |
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
|
1214 |
if (src2 & 0x8000) /* src2 is "negative" */ |
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
|
1215 |
_paramlist[target] = ((int16) src1) >> -((int16) src2); |
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
|
1216 |
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
|
1217 |
_paramlist[target] = ((int16) src1) << src2; |
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
|
1218 |
break; |
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
|
1219 |
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
|
1220 |
grfmsg(GMS_ERROR, "ParamSet: Unknown operation %d, skipping.", 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
|
1221 |
} |
0 | 1222 |
} |
1223 |
||
1224 |
static void GRFInhibit(byte *buf, int len) |
|
1225 |
{ |
|
1226 |
/* <0E> <num> <grfids...> |
|
1227 |
* |
|
1228 |
* B num Number of GRFIDs that follow |
|
1229 |
* 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
|
1230 |
/* XXX: Should we handle forward deactivations? */ |
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
|
1231 |
|
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
|
1232 |
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
|
1233 |
int 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
|
1234 |
|
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
|
1235 |
check_length(len, 1, "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
|
1236 |
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
|
1237 |
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
|
1238 |
|
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
|
1239 |
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
|
1240 |
uint32 grfid = grf_load_dword(&buf); |
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
|
1241 |
struct GRFFile *file = GetFileByGRFID(grfid); |
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
|
1242 |
|
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
|
1243 |
/* 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
|
1244 |
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
|
1245 |
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
|
1246 |
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
|
1247 |
} |
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
|
1248 |
} |
0 | 1249 |
} |
1250 |
||
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
|
1251 |
|
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
|
1252 |
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
|
1253 |
{ |
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
|
1254 |
/* 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
|
1255 |
|
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
|
1256 |
_ttdpatch_flags[1] = (1 << 0x08) /* mammothtrains */ |
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
|
1257 |
| (1 << 0x0B) /* subsidiaries */ |
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
|
1258 |
| (1 << 0x14) /* bridgespeedlimits */ |
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
|
1259 |
| (1 << 0x16) /* eternalgame */ |
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
|
1260 |
| (1 << 0x17) /* newtrains */ |
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
|
1261 |
| (1 << 0x18) /* newrvs */ |
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
|
1262 |
| (1 << 0x19) /* newships */ |
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
|
1263 |
| (1 << 0x1A); /* newplanes */ |
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
|
1264 |
|
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
|
1265 |
_ttdpatch_flags[2] = (1 << 0x0D) /* signalsontrafficside */ |
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
|
1266 |
| (1 << 0x16) /* canals */ |
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
|
1267 |
| (1 << 0x17); /* newstartyear */ |
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
|
1268 |
} |
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
|
1269 |
|
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1270 |
void InitNewGRFFile(const char *filename, int sprite_offset) |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1271 |
{ |
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
|
1272 |
struct 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
|
1273 |
|
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
|
1274 |
newfile = malloc(sizeof(struct GRFFile)); |
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
|
1275 |
|
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
|
1276 |
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
|
1277 |
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
|
1278 |
|
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
|
1279 |
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
|
1280 |
newfile->grfid = 0; |
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
|
1281 |
newfile->flags = 0x0000; |
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
|
1282 |
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
|
1283 |
newfile->next = 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
|
1284 |
|
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
|
1285 |
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
|
1286 |
_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
|
1287 |
_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
|
1288 |
} 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
|
1289 |
_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
|
1290 |
_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
|
1291 |
} |
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
|
1292 |
} |
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
|
1293 |
|
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
|
1294 |
|
0 | 1295 |
/* Here we perform initial decoding of some special sprites (as are they |
1296 |
* 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
|
1297 |
* partial implementation yet). */ |
0 | 1298 |
/* XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by |
1299 |
* a crafted invalid GRF file. We should tell that to the user somehow, or |
|
1300 |
* better make this more robust in the future. */ |
|
1301 |
||
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1302 |
void DecodeSpecialSprite(const char *filename, int num, int spriteid, int stage) |
0 | 1303 |
{ |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1304 |
#define NUM_ACTIONS 0xF |
0 | 1305 |
static const SpecialSpriteHandler handlers[NUM_ACTIONS] = { |
1306 |
/* 0x0 */ VehicleChangeInfo, |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1307 |
/* 0x1 */ NewSpriteSet, |
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1308 |
/* 0x2 */ NewSpriteGroup, |
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1309 |
/* 0x3 */ NewVehicle_SpriteGroupMapping, |
0 | 1310 |
/* 0x4 */ VehicleNewName, |
1311 |
/* 0x5 */ GraphicsNew, |
|
1312 |
/* 0x6 */ CfgApply, |
|
1313 |
/* 0x7 */ SkipIf, |
|
1314 |
/* 0x8 */ GRFInfo, |
|
1315 |
/* 0x9 */ SkipIf, |
|
1316 |
/* 0xa */ SpriteReplace, |
|
1317 |
/* 0xb */ GRFError, |
|
1318 |
/* 0xc */ GRFComment, |
|
1319 |
/* 0xd */ ParamSet, |
|
1320 |
/* 0xe */ GRFInhibit, |
|
1321 |
}; |
|
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
|
1322 |
static int initialized; |
0 | 1323 |
byte action; |
1324 |
byte *buf = malloc(num); |
|
1325 |
int i; |
|
1326 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1327 |
if (buf == NULL) error("DecodeSpecialSprite: Could not allocate memory"); |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1328 |
|
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
|
1329 |
if (!initialized) { |
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
|
1330 |
InitializeGRFSpecial(); |
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
|
1331 |
initialized = 1; |
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
|
1332 |
} |
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
|
1333 |
|
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1334 |
_cur_stage = stage; |
0 | 1335 |
_cur_spriteid = spriteid; |
1336 |
||
1337 |
for (i = 0; i != num; i++) |
|
1338 |
buf[i] = FioReadByte(); |
|
1339 |
||
1340 |
action = buf[0]; |
|
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1341 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1342 |
/* XXX: Action 0x03 is temporarily processed together with actions 0x01 |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1343 |
* and 0x02 before it is fixed to be reentrant (probably storing the |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1344 |
* group information in {struct GRFFile}). --pasky */ |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1345 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1346 |
if (stage == 0) { |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1347 |
/* During initialization, actions 0, 3, 4, 5 and 7 are ignored. */ |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1348 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1349 |
if ((action == 0x00) /*|| (action == 0x03)*/ || (action == 0x04) |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1350 |
|| (action == 0x05) || (action == 0x07)) { |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1351 |
DEBUG (grf, 5) ("DecodeSpecialSprite: Action: %x, Stage 0, Skipped", action); |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1352 |
/* Do nothing. */ |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1353 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1354 |
} else if (action < NUM_ACTIONS) { |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1355 |
DEBUG (grf, 5) ("DecodeSpecialSprite: Action: %x, Stage 0", action); |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1356 |
handlers[action](buf, num); |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1357 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1358 |
} else { |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1359 |
grfmsg(GMS_WARN, "Unknown special sprite action %x, skipping.", action); |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1360 |
} |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1361 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1362 |
} else if (stage == 1) { |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1363 |
/* A .grf file is activated only if it was active when the game was |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1364 |
* started. If a game is loaded, only its active .grfs will be |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1365 |
* reactivated, unless "loadallgraphics on" is used. A .grf file is |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1366 |
* considered active if its action 8 has been processed, i.e. its |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1367 |
* action 8 hasn't been skipped using an action 7. |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1368 |
* |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1369 |
* During activation, only actions 0, 3, 4, 5, 7, 8, 9 and 0A are |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1370 |
* carried out. All others are ignored, because they only need to be |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1371 |
* processed once at initialization. */ |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1372 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1373 |
if ((_cur_grffile == NULL) || strcmp(_cur_grffile->filename, filename)) |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1374 |
_cur_grffile = GetFileByFilename(filename); |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1375 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1376 |
if (_cur_grffile == NULL) |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1377 |
error("File ``%s'' lost in cache.\n", filename); |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1378 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1379 |
if (!(_cur_grffile->flags & 0x0001)) { |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1380 |
DEBUG (grf, 5) ("DecodeSpecialSprite: Action: %x, Stage 1, Not activated", action); |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1381 |
/* Do nothing. */ |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1382 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1383 |
} else if ((action == 0x00) /*|| (action == 0x03)*/ || (action == 0x04) || (action == 0x05) |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1384 |
|| (action == 0x07) || (action == 0x08) || (action == 0x09) || (action == 0x0A)) { |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1385 |
DEBUG (grf, 5) ("DecodeSpecialSprite: Action: %x, Stage 1", action); |
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
|
1386 |
handlers[action](buf, num); |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1387 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1388 |
} else if (action < NUM_ACTIONS) { |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1389 |
DEBUG (grf, 5) ("DecodeSpecialSprite: Action: %x, Stage 1, Skipped", action); |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1390 |
/* Do nothing. */ |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1391 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1392 |
} else { |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1393 |
grfmsg(GMS_WARN, "Unknown special sprite action %x, skipping.", action); |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1394 |
} |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1395 |
|
0 | 1396 |
} else { |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1397 |
error("Invalid stage %d", stage); |
0 | 1398 |
} |
1399 |
||
1400 |
free(buf); |
|
1401 |
#undef NUM_ACTIONS |
|
1402 |
} |