author | darkvater |
Sun, 14 Nov 2004 14:53:15 +0000 | |
changeset 400 | d0608455bb77 |
parent 399 | ad3dcbfd2d48 |
child 401 | 37143866b5df |
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" |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
9 |
#include "station.h" |
0 | 10 |
|
11 |
/* TTDPatch extended GRF format codec |
|
12 |
* (c) Petr Baudis 2004 (GPL'd) |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
13 |
* 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
|
14 |
* |
0 | 15 |
* Contains portions of documentation by TTDPatch team. |
16 |
* Thanks especially to Josef Drexler for the documentation as well as a lot |
|
17 |
* of help at #tycoon. Also thanks to Michael Blunck for is GRF files which |
|
18 |
* served as subject to the initial testing of this codec. */ |
|
19 |
||
20 |
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
|
21 |
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
|
22 |
extern int _replace_sprites_offset[16]; |
0 | 23 |
|
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
|
24 |
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
|
25 |
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
|
26 |
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
|
27 |
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
|
28 |
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
|
29 |
struct GRFFile *next; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
30 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
31 |
/* A sprite group contains all sprites of a given vehicle (or multiple |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
32 |
* vehicles) when carrying given cargo. It consists of several sprite |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
33 |
* sets. Group ids are refered as "cargo id"s by TTDPatch |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
34 |
* documentation, contributing to the global confusion. |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
35 |
* |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
36 |
* A sprite set contains all sprites of a given vehicle carrying given |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
37 |
* cargo at a given *stage* - that is usually its load stage. Ie. you |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
38 |
* can have a spriteset for an empty wagon, wagon full of coal, |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
39 |
* half-filled wagon etc. Each spriteset contains eight sprites (one |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
40 |
* per direction) or four sprites if the vehicle is symmetric. */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
41 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
42 |
int spriteset_start; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
43 |
int spriteset_numsets; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
44 |
int spriteset_numents; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
45 |
int spriteset_feature; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
46 |
|
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
47 |
int spritegroups_count; |
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
48 |
struct SpriteGroup *spritegroups; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
49 |
|
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
50 |
struct StationSpec stations[256]; |
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
|
51 |
}; |
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
|
52 |
|
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
|
53 |
static struct GRFFile *_cur_grffile, *_first_grffile; |
0 | 54 |
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
|
55 |
static int _cur_stage; |
0 | 56 |
|
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
|
57 |
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
|
58 |
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
|
59 |
|
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
|
60 |
/* 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
|
61 |
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
|
62 |
|
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
63 |
|
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
64 |
enum grfspec_feature { |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
65 |
GSF_TRAIN, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
66 |
GSF_ROAD, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
67 |
GSF_SHIP, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
68 |
GSF_AIRCRAFT, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
69 |
GSF_STATION, |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
70 |
GSF_BRIDGE, |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
71 |
GSF_TOWNHOUSE, |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
72 |
}; |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
73 |
|
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
74 |
|
0 | 75 |
typedef void (*SpecialSpriteHandler)(byte *buf, int len); |
76 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
77 |
static const int _vehcounts[4] = { |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
78 |
/* GSF_TRAIN */ NUM_TRAIN_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
79 |
/* GSF_ROAD */ NUM_ROAD_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
80 |
/* GSF_SHIP */ NUM_SHIP_ENGINES, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
81 |
/* GSF_AIRCRAFT */ NUM_AIRCRAFT_ENGINES |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
82 |
}; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
83 |
|
0 | 84 |
static const int _vehshifts[4] = { |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
85 |
/* GSF_TRAIN */ 0, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
86 |
/* GSF_ROAD */ ROAD_ENGINES_INDEX, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
87 |
/* GSF_SHIP */ SHIP_ENGINES_INDEX, |
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
88 |
/* GSF_AIRCRAFT */ AIRCRAFT_ENGINES_INDEX, |
0 | 89 |
}; |
90 |
||
91 |
||
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
92 |
/* Debugging messages policy: |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
93 |
* |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
94 |
* These should be the severities used for direct DEBUG() calls |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
95 |
* (there is room for exceptions, but you have to have a good cause): |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
96 |
* |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
97 |
* 0..2 - dedicated to grfmsg() |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
98 |
* 3 |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
99 |
* 4 |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
100 |
* 5 |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
101 |
* 6 - action handler entry reporting - one per action |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
102 |
* 7 - basic action progress reporting - in loops, only single one allowed |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
103 |
* 8 - more detailed progress reporting - less important stuff, in deep loops etc |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
104 |
* 9 - extremely detailed progress reporting - detailed reports inside of deep loops and so |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
105 |
*/ |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
106 |
|
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
107 |
|
0 | 108 |
enum grfmsg_severity { |
109 |
GMS_NOTICE, |
|
110 |
GMS_WARN, |
|
111 |
GMS_ERROR, |
|
112 |
GMS_FATAL, |
|
113 |
}; |
|
114 |
||
115 |
static void CDECL grfmsg(enum grfmsg_severity severity, const char *str, ...) |
|
116 |
{ |
|
117 |
static const char * const severitystr[4] = { "Notice", "Warning", "Error", "Fatal" }; |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
118 |
int export_severity = 0; |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
51
diff
changeset
|
119 |
char buf[1024]; |
0 | 120 |
va_list va; |
121 |
||
122 |
va_start(va, str); |
|
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
51
diff
changeset
|
123 |
vsprintf(buf, str, va); |
0 | 124 |
va_end(va); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
125 |
|
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
126 |
export_severity = 2 - (severity == GMS_FATAL ? 2 : severity); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
127 |
DEBUG(grf, export_severity) ("[%s][%s] %s", _cur_grffile->filename, severitystr[severity], buf); |
0 | 128 |
} |
129 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
130 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
131 |
#define check_length(real, wanted, where) \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
132 |
do { \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
133 |
if (real < wanted) { \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
134 |
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
|
135 |
return; \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
136 |
} \ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
137 |
} while (0) |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
138 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
139 |
|
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
140 |
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
|
141 |
{ |
0 | 142 |
return *(*buf)++; |
143 |
} |
|
144 |
||
145 |
static uint16 grf_load_word(byte **buf) |
|
146 |
{ |
|
147 |
uint16 val; |
|
148 |
byte *p = *buf; |
|
149 |
val = p[0]; |
|
150 |
val |= p[1] << 8; |
|
151 |
*buf = p + 2; |
|
152 |
return val; |
|
153 |
} |
|
154 |
||
155 |
static uint16 grf_load_dword(byte **buf) |
|
156 |
{ |
|
157 |
uint32 val; |
|
158 |
byte *p = *buf; |
|
159 |
val = p[0]; |
|
160 |
val |= p[1] << 8; |
|
161 |
val |= p[2] << 16; |
|
162 |
val |= p[3] << 24; |
|
163 |
*buf = p + 4; |
|
164 |
return val; |
|
165 |
} |
|
166 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
167 |
|
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
|
168 |
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
|
169 |
{ |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
170 |
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
|
171 |
|
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
|
172 |
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
|
173 |
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
|
174 |
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
|
175 |
|
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
|
176 |
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
|
177 |
} |
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
|
178 |
|
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
179 |
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
|
180 |
{ |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
181 |
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
|
182 |
|
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
|
183 |
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
|
184 |
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
|
185 |
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
|
186 |
|
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
187 |
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
|
188 |
} |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
189 |
|
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
|
190 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
191 |
typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); |
0 | 192 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
193 |
#define FOR_EACH_ENGINE for (i = 0; i < numinfo; i++) |
0 | 194 |
|
195 |
static void dewagonize(int condition, int engine) |
|
196 |
{ |
|
197 |
EngineInfo *ei = &_engine_info[engine]; |
|
198 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
|
199 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
200 |
if (condition != 0) { |
0 | 201 |
ei->unk2 &= ~0x80; |
202 |
rvi->flags &= ~2; |
|
203 |
} else { |
|
204 |
ei->unk2 |= 0x80; |
|
205 |
rvi->flags |= 2; |
|
206 |
} |
|
207 |
} |
|
208 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
209 |
static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 210 |
{ |
211 |
EngineInfo *ei = &_engine_info[engine]; |
|
212 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
|
213 |
byte *buf = *bufp; |
|
214 |
int i; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
215 |
bool ret = false; |
0 | 216 |
|
217 |
switch (prop) { |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
218 |
case 0x05: { /* Track type */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
219 |
FOR_EACH_ENGINE { |
0 | 220 |
uint8 tracktype = grf_load_byte(&buf); |
221 |
||
222 |
ei[i].railtype_climates &= 0xf; |
|
223 |
ei[i].railtype_climates |= tracktype << 4; |
|
224 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
225 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
226 |
case 0x08: { /* AI passenger service */ |
0 | 227 |
/* TODO */ |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
228 |
FOR_EACH_ENGINE { |
0 | 229 |
grf_load_byte(&buf); |
230 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
231 |
ret = true; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
232 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
233 |
case 0x09: { /* Speed */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
234 |
FOR_EACH_ENGINE { |
0 | 235 |
uint16 speed = grf_load_word(&buf); |
236 |
||
237 |
rvi[i].max_speed = speed; |
|
238 |
dewagonize(speed, engine + i); |
|
239 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
240 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
241 |
case 0x0B: { /* Power */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
242 |
FOR_EACH_ENGINE { |
0 | 243 |
uint16 power = grf_load_word(&buf); |
244 |
||
245 |
rvi[i].power = power; |
|
246 |
dewagonize(power, engine + i); |
|
247 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
248 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
249 |
case 0x0D: { /* Running cost factor */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
250 |
FOR_EACH_ENGINE { |
0 | 251 |
uint8 runcostfact = grf_load_byte(&buf); |
252 |
||
253 |
rvi[i].running_cost_base = runcostfact; |
|
254 |
dewagonize(runcostfact, engine + i); |
|
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 0x0E: { /* Running cost base */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
258 |
FOR_EACH_ENGINE { |
0 | 259 |
uint32 base = grf_load_dword(&buf); |
260 |
||
261 |
switch (base) { |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
262 |
case 0x4C30: |
0 | 263 |
rvi[i].engclass = 0; |
264 |
break; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
265 |
case 0x4C36: |
0 | 266 |
rvi[i].engclass = 1; |
267 |
break; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
268 |
case 0x4C3C: |
0 | 269 |
rvi[i].engclass = 2; |
270 |
break; |
|
271 |
} |
|
272 |
dewagonize(base, engine + i); |
|
273 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
274 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
275 |
case 0x12: { /* Sprite ID */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
276 |
FOR_EACH_ENGINE { |
0 | 277 |
uint8 spriteid = grf_load_byte(&buf); |
278 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
279 |
if (spriteid == 0xFD && rvi[i].image_index != 0xFD) |
0 | 280 |
_engine_original_sprites[engine + i] = rvi[i].image_index; |
281 |
rvi[i].image_index = spriteid; |
|
282 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
283 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
284 |
case 0x13: { /* Dual-headed */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
285 |
FOR_EACH_ENGINE { |
0 | 286 |
uint8 dual = grf_load_byte(&buf); |
287 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
288 |
if (dual != 0) { |
0 | 289 |
rvi[i].flags |= 1; |
290 |
} else { |
|
291 |
rvi[i].flags &= ~1; |
|
292 |
} |
|
293 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
294 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
295 |
case 0x14: { /* Cargo capacity */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
296 |
FOR_EACH_ENGINE { |
0 | 297 |
uint8 capacity = grf_load_byte(&buf); |
298 |
||
299 |
rvi[i].capacity = capacity; |
|
300 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
301 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
302 |
case 0x15: { /* Cargo type */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
303 |
FOR_EACH_ENGINE { |
0 | 304 |
uint8 ctype = grf_load_byte(&buf); |
305 |
||
306 |
rvi[i].cargo_type = ctype; |
|
307 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
308 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
309 |
case 0x16: { /* Weight */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
310 |
FOR_EACH_ENGINE { |
0 | 311 |
uint8 weight = grf_load_byte(&buf); |
312 |
||
313 |
rvi[i].weight = weight; |
|
314 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
315 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
316 |
case 0x17: { /* Cost factor */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
317 |
FOR_EACH_ENGINE { |
0 | 318 |
uint8 cfactor = grf_load_byte(&buf); |
319 |
||
320 |
rvi[i].base_cost = cfactor; |
|
321 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
322 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
323 |
case 0x18: { /* AI rank */ |
0 | 324 |
/* 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
|
325 |
FOR_EACH_ENGINE { |
0 | 326 |
grf_load_byte(&buf); |
327 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
328 |
ret = true; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
329 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
330 |
case 0x19: { /* Engine traction type */ |
0 | 331 |
/* TODO: What do the individual numbers mean? |
332 |
* 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
|
333 |
FOR_EACH_ENGINE { |
0 | 334 |
uint8 traction = grf_load_byte(&buf); |
335 |
int engclass; |
|
336 |
||
337 |
if (traction <= 0x07) |
|
338 |
engclass = 0; |
|
339 |
else if (traction <= 0x27) |
|
340 |
engclass = 1; |
|
341 |
else if (traction <= 0x31) |
|
342 |
engclass = 2; |
|
343 |
else |
|
344 |
break; |
|
345 |
||
346 |
rvi[i].engclass = engclass; |
|
347 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
348 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
349 |
|
0 | 350 |
/* TODO */ |
351 |
/* 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
|
352 |
case 0x1D: /* Refit cargo */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
353 |
FOR_EACH_ENGINE { |
0 | 354 |
grf_load_word(&buf); |
355 |
} |
|
356 |
/* 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
|
357 |
case 0x1B: /* Powered wagons power bonus */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
358 |
FOR_EACH_ENGINE { |
0 | 359 |
grf_load_byte(&buf); |
360 |
} |
|
361 |
/* 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
|
362 |
case 0x1A: /* Sort order */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
363 |
case 0x1C: /* Refit cost */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
364 |
case 0x1E: /* Callback */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
365 |
case 0x1F: /* Tractive effort */ |
0 | 366 |
case 0x21: /* Shorter tenders */ |
367 |
case 0x22: /* Visual */ |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
368 |
case 0x23: {/* Powered wagons weight bonus */ |
0 | 369 |
/* TODO */ |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
370 |
FOR_EACH_ENGINE { |
0 | 371 |
grf_load_byte(&buf); |
372 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
373 |
ret = true; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
374 |
} break; |
0 | 375 |
default: |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
376 |
ret = true; |
0 | 377 |
} |
378 |
*bufp = buf; |
|
379 |
return ret; |
|
380 |
} |
|
381 |
||
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
382 |
static bool RoadVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
383 |
{ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
384 |
RoadVehicleInfo *rvi = &_road_vehicle_info[engine]; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
385 |
byte *buf = *bufp; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
386 |
int i; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
387 |
bool ret = false; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
388 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
389 |
switch (prop) { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
390 |
case 0x08: { /* Speed */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
391 |
FOR_EACH_ENGINE { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
392 |
uint8 speed = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
393 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
394 |
rvi[i].max_speed = speed; // ?? units |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
395 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
396 |
} break; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
397 |
case 0x09: { /* Running cost factor */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
398 |
FOR_EACH_ENGINE { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
399 |
uint8 runcost = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
400 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
401 |
rvi[i].running_cost = runcost; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
402 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
403 |
} break; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
404 |
case 0x0A: /* Running cost base */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
405 |
/* TODO: I have no idea. --pasky */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
406 |
FOR_EACH_ENGINE { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
407 |
grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
408 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
409 |
ret = true; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
410 |
break; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
411 |
case 0x0E: { /* Sprite ID */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
412 |
FOR_EACH_ENGINE { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
413 |
uint8 spriteid = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
414 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
415 |
if (spriteid == 0xFF) |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
416 |
spriteid = 0xFD; // cars have different custom id in the GRF file |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
417 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
418 |
// This is currently not used but there's no reason |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
419 |
// in not having it here for the future. |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
420 |
if (spriteid == 0xFD && rvi[i].image_index != 0xFD) |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
421 |
_engine_original_sprites[ROAD_ENGINES_INDEX + engine + i] = rvi[i].image_index; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
422 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
423 |
rvi[i].image_index = spriteid; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
424 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
425 |
} break; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
426 |
case 0x0F: { /* Cargo capacity */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
427 |
FOR_EACH_ENGINE { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
428 |
uint16 capacity = grf_load_word(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
429 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
430 |
rvi[i].capacity = capacity; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
431 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
432 |
} break; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
433 |
case 0x10: { /* Cargo type */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
434 |
FOR_EACH_ENGINE { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
435 |
uint8 cargo = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
436 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
437 |
rvi[i].cargo_type = cargo; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
438 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
439 |
} break; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
440 |
case 0x11: { /* Cost factor */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
441 |
FOR_EACH_ENGINE { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
442 |
uint8 cost_factor = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
443 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
444 |
rvi[i].base_cost = cost_factor; // ?? is it base_cost? |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
445 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
446 |
} break; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
447 |
case 0x12: { /* SFX */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
448 |
FOR_EACH_ENGINE { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
449 |
uint8 sfx = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
450 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
451 |
rvi[i].sfx = sfx; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
452 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
453 |
} break; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
454 |
case 0x13: /* Power in 10hp */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
455 |
case 0x14: /* Weight in 1/4 tons */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
456 |
case 0x15: /* Speed in mph*0.8 */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
457 |
/* TODO: Support for road vehicles realistic power |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
458 |
* computations (called rvpower in TTDPatch) is just |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
459 |
* missing in OTTD yet. --pasky */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
460 |
FOR_EACH_ENGINE { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
461 |
grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
462 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
463 |
ret = true; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
464 |
break; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
465 |
case 0x16: { /* Cargos available for refitting */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
466 |
FOR_EACH_ENGINE { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
467 |
uint32 refit_mask = grf_load_dword(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
468 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
469 |
_engine_refit_masks[ROAD_ENGINES_INDEX + engine + i] = refit_mask; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
470 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
471 |
} break; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
472 |
case 0x17: /* Callback */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
473 |
case 0x18: /* Tractive effort */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
474 |
/* TODO */ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
475 |
FOR_EACH_ENGINE { |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
476 |
grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
477 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
478 |
ret = true; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
479 |
break; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
480 |
default: |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
481 |
ret = true; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
482 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
483 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
484 |
*bufp = buf; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
485 |
return ret; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
486 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
487 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
488 |
static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 489 |
{ |
490 |
ShipVehicleInfo *svi = &_ship_vehicle_info[engine]; |
|
491 |
byte *buf = *bufp; |
|
492 |
int i; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
493 |
bool ret = false; |
0 | 494 |
|
495 |
//printf("e %x prop %x?\n", engine, prop); |
|
496 |
switch (prop) { |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
497 |
case 0x08: { /* Sprite ID */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
498 |
FOR_EACH_ENGINE { |
0 | 499 |
uint8 spriteid = grf_load_byte(&buf); |
500 |
||
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
501 |
if (spriteid == 0xFF) |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
502 |
spriteid = 0xFD; // ships have different custom id in the GRF file |
0 | 503 |
|
504 |
// This is currently not used but there's no reason |
|
505 |
// 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
|
506 |
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
|
507 |
_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
|
508 |
|
0 | 509 |
svi[i].image_index = spriteid; |
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 0x09: { /* Refittable */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
513 |
FOR_EACH_ENGINE { |
0 | 514 |
uint8 refittable = grf_load_byte(&buf); |
515 |
||
516 |
svi[i].refittable = refittable; |
|
517 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
518 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
519 |
case 0x0A: { /* Cost factor */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
520 |
FOR_EACH_ENGINE { |
0 | 521 |
uint8 cost_factor = grf_load_byte(&buf); |
522 |
||
523 |
svi[i].base_cost = cost_factor; // ?? is it base_cost? |
|
524 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
525 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
526 |
case 0x0B: { /* Speed */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
527 |
FOR_EACH_ENGINE { |
0 | 528 |
uint8 speed = grf_load_byte(&buf); |
529 |
||
530 |
svi[i].max_speed = speed; // ?? units |
|
531 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
532 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
533 |
case 0x0C: { /* Cargo type */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
534 |
FOR_EACH_ENGINE { |
0 | 535 |
uint8 cargo = grf_load_byte(&buf); |
536 |
||
537 |
// XXX: Need to consult this with patchman yet. |
|
538 |
#if 0 |
|
539 |
// Documentation claims this is already the |
|
540 |
// per-landscape cargo type id, but newships.grf |
|
541 |
// assume otherwise. |
|
542 |
cargo = local_cargo_id_ctype[cargo]; |
|
543 |
#endif |
|
544 |
svi[i].cargo_type = cargo; |
|
545 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
546 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
547 |
case 0x0D: { /* Cargo capacity */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
548 |
FOR_EACH_ENGINE { |
0 | 549 |
uint16 capacity = grf_load_word(&buf); |
550 |
||
551 |
svi[i].capacity = capacity; |
|
552 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
553 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
554 |
case 0x0F: { /* Running cost factor */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
555 |
FOR_EACH_ENGINE { |
0 | 556 |
uint8 runcost = grf_load_byte(&buf); |
557 |
||
558 |
svi[i].running_cost = runcost; |
|
559 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
560 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
561 |
case 0x10: { /* SFX */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
562 |
FOR_EACH_ENGINE { |
0 | 563 |
uint8 sfx = grf_load_byte(&buf); |
564 |
||
565 |
svi[i].sfx = sfx; |
|
566 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
567 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
568 |
case 0x11: { /* Cargos available for refitting */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
569 |
FOR_EACH_ENGINE { |
0 | 570 |
uint32 refit_mask = grf_load_dword(&buf); |
571 |
||
572 |
_engine_refit_masks[SHIP_ENGINES_INDEX + engine + i] = refit_mask; |
|
573 |
} |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
574 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
575 |
case 0x12: { /* Callback TODO */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
576 |
ret = true; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
577 |
} break; |
0 | 578 |
default: |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
579 |
ret = true; |
0 | 580 |
} |
581 |
||
582 |
*bufp = buf; |
|
583 |
return ret; |
|
584 |
} |
|
585 |
||
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
586 |
static bool AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
587 |
{ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
588 |
AircraftVehicleInfo *avi = &_aircraft_vehicle_info[engine]; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
589 |
byte *buf = *bufp; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
590 |
int i; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
591 |
bool ret = false; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
592 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
593 |
//printf("e %x prop %x?\n", engine, prop); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
594 |
switch (prop) { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
595 |
case 0x08: { /* Sprite ID */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
596 |
FOR_EACH_ENGINE { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
597 |
uint8 spriteid = grf_load_byte(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
598 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
599 |
if (spriteid == 0xFF) |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
600 |
spriteid = 0xFD; // ships have different custom id in the GRF file |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
601 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
602 |
// This is currently not used but there's no reason |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
603 |
// in not having it here for the future. |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
604 |
if (spriteid == 0xFD && avi[i].image_index != 0xFD) |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
605 |
_engine_original_sprites[AIRCRAFT_ENGINES_INDEX + engine + i] = avi[i].image_index; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
606 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
607 |
avi[i].image_index = spriteid; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
608 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
609 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
610 |
case 0x09: { /* Helicopter */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
611 |
FOR_EACH_ENGINE { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
612 |
uint8 heli = grf_load_byte(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
613 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
614 |
avi[i].subtype = (heli == 0) ? 0 : 1; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
615 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
616 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
617 |
case 0x0A: { /* Large */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
618 |
FOR_EACH_ENGINE { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
619 |
uint8 large = grf_load_byte(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
620 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
621 |
avi[i].subtype = (large == 1) ? 3 : 1; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
622 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
623 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
624 |
case 0x0B: { /* Cost factor */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
625 |
FOR_EACH_ENGINE { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
626 |
uint8 cost_factor = grf_load_byte(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
627 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
628 |
avi[i].base_cost = cost_factor; // ?? is it base_cost? |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
629 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
630 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
631 |
case 0x0C: { /* Speed */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
632 |
FOR_EACH_ENGINE { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
633 |
uint8 speed = grf_load_byte(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
634 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
635 |
avi[i].max_speed = speed; // ?? units |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
636 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
637 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
638 |
case 0x0D: { /* Acceleration */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
639 |
FOR_EACH_ENGINE { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
640 |
uint8 accel = grf_load_byte(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
641 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
642 |
avi[i].acceleration = accel; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
643 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
644 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
645 |
case 0x0E: { /* Running cost factor */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
646 |
FOR_EACH_ENGINE { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
647 |
uint8 runcost = grf_load_byte(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
648 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
649 |
avi[i].running_cost = runcost; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
650 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
651 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
652 |
case 0x0F: { /* Passenger capacity */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
653 |
FOR_EACH_ENGINE { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
654 |
uint16 capacity = grf_load_word(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
655 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
656 |
avi[i].passanger_capacity = capacity; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
657 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
658 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
659 |
case 0x11: { /* Mail capacity */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
660 |
FOR_EACH_ENGINE { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
661 |
uint8 capacity = grf_load_byte(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
662 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
663 |
avi[i].mail_capacity = capacity; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
664 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
665 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
666 |
case 0x12: { /* SFX */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
667 |
FOR_EACH_ENGINE { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
668 |
uint8 sfx = grf_load_byte(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
669 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
670 |
avi[i].sfx = sfx; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
671 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
672 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
673 |
case 0x13: { /* Cargos available for refitting */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
674 |
FOR_EACH_ENGINE { |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
675 |
uint32 refit_mask = grf_load_dword(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
676 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
677 |
_engine_refit_masks[AIRCRAFT_ENGINES_INDEX + engine + i] = refit_mask; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
678 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
679 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
680 |
case 0x14: { /* Callback TODO */ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
681 |
ret = true; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
682 |
} break; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
683 |
default: |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
684 |
ret = true; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
685 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
686 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
687 |
*bufp = buf; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
688 |
return ret; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
689 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
690 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
691 |
static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int len) |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
692 |
{ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
693 |
byte *buf = *bufp; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
694 |
int i; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
695 |
int ret = 0; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
696 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
697 |
/* This is one single huge TODO. It doesn't handle anything more than |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
698 |
* just waypoints for now. */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
699 |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
700 |
/* TODO: Differentiate between railtypes. This is missing in the new |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
701 |
* GRF file specification yet, though, so I need to agree on this with |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
702 |
* patchman yet. We just assume all the station stuff is for railtype 0 |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
703 |
* (railroad) for now. --pasky */ |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
704 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
705 |
//printf("sci %d %d [0x%02x]\n", stid, numinfo, prop); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
706 |
switch (prop) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
707 |
case 0x08: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
708 |
{ /* Class ID */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
709 |
FOR_EACH_ENGINE { |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
710 |
struct StationSpec *stat = &_cur_grffile->stations[stid + i]; |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
711 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
712 |
/* classid, for a change, is always little-endian */ |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
713 |
stat->classid = *(buf++) << 24; |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
714 |
stat->classid |= *(buf++) << 16; |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
715 |
stat->classid |= *(buf++) << 8; |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
716 |
stat->classid |= *(buf++); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
717 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
718 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
719 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
720 |
case 0x09: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
721 |
{ /* Define sprite layout */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
722 |
FOR_EACH_ENGINE { |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
723 |
struct StationSpec *stat = &_cur_grffile->stations[stid + i]; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
724 |
int t; |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
725 |
|
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
726 |
stat->tiles = grf_load_byte(&buf); |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
727 |
for (t = 0; t < stat->tiles; t++) { |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
728 |
DrawTileSprites *dts = &stat->renderdata[t]; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
729 |
int seq_count = 0; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
730 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
731 |
if (t >= 8) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
732 |
grfmsg(GMS_WARN, "StationChangeInfo: Sprite %d>=8, skipping.", t); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
733 |
grf_load_dword(&buf); // at least something |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
734 |
continue; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
735 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
736 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
737 |
dts->ground_sprite = grf_load_dword(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
738 |
if (!dts->ground_sprite) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
739 |
static const DrawTileSeqStruct empty = {0x80}; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
740 |
dts->seq = ∅ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
741 |
continue; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
742 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
743 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
744 |
dts->seq = NULL; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
745 |
while (buf < *bufp + len) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
746 |
DrawTileSeqStruct *dtss; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
747 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
748 |
// no relative bounding box support |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
749 |
dts->seq = realloc((void*)dts->seq, ++seq_count * sizeof(DrawTileSeqStruct)); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
750 |
dtss = (DrawTileSeqStruct*) &dts->seq[seq_count - 1]; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
751 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
752 |
dtss->delta_x = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
753 |
if ((byte) dtss->delta_x == 0x80) break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
754 |
dtss->delta_y = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
755 |
dtss->delta_z = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
756 |
dtss->width = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
757 |
dtss->height = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
758 |
dtss->unk = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
759 |
dtss->image = grf_load_dword(&buf) - 0x42d; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
760 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
761 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
762 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
763 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
764 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
765 |
case 0x0a: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
766 |
{ /* Copy sprite layout */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
767 |
FOR_EACH_ENGINE { |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
768 |
struct StationSpec *stat = &_cur_grffile->stations[stid + i]; |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
769 |
byte srcid = grf_load_byte(&buf); |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
770 |
struct StationSpec *srcstat = &_cur_grffile->stations[srcid]; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
771 |
int t; |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
772 |
|
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
773 |
stat->tiles = srcstat->tiles; |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
774 |
for (t = 0; t < stat->tiles; t++) { |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
775 |
DrawTileSprites *dts = &stat->renderdata[t]; |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
776 |
DrawTileSprites *sdts = &srcstat->renderdata[t]; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
777 |
DrawTileSeqStruct const *sdtss = sdts->seq; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
778 |
int seq_count = 0; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
779 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
780 |
dts->ground_sprite = sdts->ground_sprite; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
781 |
if (!dts->ground_sprite) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
782 |
static const DrawTileSeqStruct empty = {0x80}; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
783 |
dts->seq = ∅ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
784 |
continue; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
785 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
786 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
787 |
dts->seq = NULL; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
788 |
while (1) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
789 |
DrawTileSeqStruct *dtss; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
790 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
791 |
// no relative bounding box support |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
792 |
dts->seq = realloc((void*)dts->seq, ++seq_count * sizeof(DrawTileSeqStruct)); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
793 |
dtss = (DrawTileSeqStruct*) &dts->seq[seq_count - 1]; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
794 |
*dtss = *sdtss; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
795 |
if ((byte) dtss->delta_x == 0x80) break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
796 |
sdtss++; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
797 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
798 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
799 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
800 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
801 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
802 |
case 0x0b: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
803 |
{ /* Callback */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
804 |
/* TODO */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
805 |
FOR_EACH_ENGINE { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
806 |
grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
807 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
808 |
ret = 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
809 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
810 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
811 |
case 0x0c: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
812 |
{ /* Platforms number */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
813 |
/* TODO */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
814 |
FOR_EACH_ENGINE { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
815 |
grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
816 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
817 |
ret = 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
818 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
819 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
820 |
case 0x0d: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
821 |
{ /* Platforms length */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
822 |
/* TODO */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
823 |
FOR_EACH_ENGINE { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
824 |
grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
825 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
826 |
ret = 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
827 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
828 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
829 |
case 0x0e: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
830 |
{ /* Define custom layout */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
831 |
/* TODO */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
832 |
FOR_EACH_ENGINE { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
833 |
while (buf < *bufp + len) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
834 |
byte length = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
835 |
byte number = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
836 |
int k = length * number; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
837 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
838 |
if (!length && !number) break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
839 |
while (k--) grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
840 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
841 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
842 |
ret = 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
843 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
844 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
845 |
case 0x0f: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
846 |
{ /* Copy custom layout */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
847 |
/* TODO */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
848 |
FOR_EACH_ENGINE { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
849 |
grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
850 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
851 |
ret = 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
852 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
853 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
854 |
case 0x10: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
855 |
{ /* Little/lots cargo threshold */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
856 |
/* TODO */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
857 |
FOR_EACH_ENGINE { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
858 |
grf_load_word(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
859 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
860 |
ret = 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
861 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
862 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
863 |
default: |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
864 |
ret = 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
865 |
break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
866 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
867 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
868 |
*bufp = buf; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
869 |
return ret; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
870 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
871 |
|
0 | 872 |
#undef shift_buf |
873 |
||
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
874 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
875 |
/* Action 0x00 */ |
0 | 876 |
static void VehicleChangeInfo(byte *buf, int len) |
877 |
{ |
|
878 |
byte *bufend = buf + len; |
|
879 |
int i; |
|
880 |
||
881 |
/* <00> <feature> <num-props> <num-info> <id> (<property <new-info>)... |
|
882 |
* |
|
883 |
* B feature 0, 1, 2 or 3 for trains, road vehicles, ships or planes |
|
884 |
* 4 for defining new train station sets |
|
885 |
* B num-props how many properties to change per vehicle/station |
|
886 |
* B num-info how many vehicles/stations to change |
|
887 |
* B id ID of first vehicle/station to change, if num-info is |
|
888 |
* greater than one, this one and the following |
|
889 |
* vehicles/stations will be changed |
|
890 |
* B property what property to change, depends on the feature |
|
891 |
* V new-info new bytes of info (variable size; depends on properties) */ |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
892 |
/* TODO: Bridges, town houses. */ |
0 | 893 |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
894 |
static const VCI_Handler handler[7] = { |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
895 |
/* GSF_TRAIN */ RailVehicleChangeInfo, |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
896 |
/* GSF_ROAD */ RoadVehicleChangeInfo, |
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
897 |
/* GSF_SHIP */ ShipVehicleChangeInfo, |
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
898 |
/* GSF_AIRCRAFT */ AircraftVehicleChangeInfo, |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
899 |
/* GSF_STATION */ StationChangeInfo, |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
900 |
/* GSF_BRIDGE */ NULL, |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
901 |
/* GSF_TOWNHOUSE */NULL, |
0 | 902 |
}; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
903 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
904 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
905 |
uint8 numprops; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
906 |
uint8 numinfo; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
907 |
byte engine; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
908 |
EngineInfo *ei; |
0 | 909 |
|
396
f7dc2d2144b6
(svn r588) -newgrf: Silent ignore those stupid one-byte zero special sprites (dbsetw.grf is crawling with them) (pasky).
darkvater
parents:
391
diff
changeset
|
910 |
if (len == 1) { |
f7dc2d2144b6
(svn r588) -newgrf: Silent ignore those stupid one-byte zero special sprites (dbsetw.grf is crawling with them) (pasky).
darkvater
parents:
391
diff
changeset
|
911 |
DEBUG(grf, 8) ("Silently ignoring one-byte special sprite 0x00."); |
f7dc2d2144b6
(svn r588) -newgrf: Silent ignore those stupid one-byte zero special sprites (dbsetw.grf is crawling with them) (pasky).
darkvater
parents:
391
diff
changeset
|
912 |
return; |
f7dc2d2144b6
(svn r588) -newgrf: Silent ignore those stupid one-byte zero special sprites (dbsetw.grf is crawling with them) (pasky).
darkvater
parents:
391
diff
changeset
|
913 |
} |
f7dc2d2144b6
(svn r588) -newgrf: Silent ignore those stupid one-byte zero special sprites (dbsetw.grf is crawling with them) (pasky).
darkvater
parents:
391
diff
changeset
|
914 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
915 |
check_length(len, 6, "VehicleChangeInfo"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
916 |
feature = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
917 |
numprops = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
918 |
numinfo = buf[3]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
919 |
engine = buf[4]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
920 |
|
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
921 |
DEBUG(grf, 6) ("VehicleChangeInfo: Feature %d, %d properties, to apply to %d+%d", |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
922 |
feature, numprops, engine, numinfo); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
923 |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
924 |
if (feature > GSF_STATION) { |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
925 |
grfmsg(GMS_WARN, "VehicleChangeInfo: Unsupported feature %d, skipping.", feature); |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
926 |
return; |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
927 |
} |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
928 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
929 |
if (feature != GSF_STATION) |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
930 |
ei = &_engine_info[engine + _vehshifts[feature]]; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
931 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
932 |
buf += 5; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
933 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
934 |
while (numprops-- && buf < bufend) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
935 |
uint8 prop = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
936 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
937 |
if (feature == 4) |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
938 |
// stations don't share those common properties |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
939 |
goto run_handler; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
940 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
941 |
switch (prop) { |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
942 |
case 0x00: { /* Introduction date */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
943 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
944 |
uint16 date = grf_load_word(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
945 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
946 |
ei[i].base_intro = date; |
0 | 947 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
948 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
949 |
case 0x02: { /* Decay speed */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
950 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
951 |
uint8 decay = grf_load_byte(&buf); |
0 | 952 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
953 |
ei[i].unk2 &= 0x80; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
954 |
ei[i].unk2 |= decay & 0x7f; |
0 | 955 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
956 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
957 |
case 0x03: { /* Vehicle life */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
958 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
959 |
uint8 life = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
960 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
961 |
ei[i].lifelength = life; |
0 | 962 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
963 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
964 |
case 0x04: { /* Model life */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
965 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
966 |
uint8 life = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
967 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
968 |
ei[i].base_life = life; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
969 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
970 |
} break; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
971 |
case 0x06: { /* Climates available */ |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
972 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
973 |
uint8 climates = grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
974 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
975 |
ei[i].railtype_climates &= 0xf0; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
976 |
ei[i].railtype_climates |= climates; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
977 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
978 |
} break; |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
979 |
case 0x07: { /* Loading speed */ |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
980 |
/* TODO */ |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
981 |
/* Hyronymus explained me what does |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
982 |
* this mean and insists on having a |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
983 |
* credit ;-). --pasky */ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
984 |
/* TODO: This needs to be supported by |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
985 |
* LoadUnloadVehicle() first. */ |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
986 |
FOR_EACH_ENGINE { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
987 |
grf_load_byte(&buf); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
988 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
989 |
goto ignoring; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
990 |
} |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
991 |
default: { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
992 |
run_handler: |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
993 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) { |
0 | 994 |
ignoring: |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
995 |
grfmsg(GMS_NOTICE, "VehicleChangeInfo: Ignoring property %x (not implemented).", prop); |
0 | 996 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
997 |
break; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
998 |
} |
0 | 999 |
} |
1000 |
} |
|
1001 |
#undef shift_buf |
|
1002 |
} |
|
1003 |
||
1004 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1005 |
/* 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
|
1006 |
static void NewSpriteSet(byte *buf, int len) |
0 | 1007 |
{ |
1008 |
/* <01> <feature> <num-sets> <num-ent> |
|
1009 |
* |
|
1010 |
* B feature feature to define sprites for |
|
1011 |
* 0, 1, 2, 3: veh-type, 4: train stations |
|
1012 |
* B num-sets number of sprite sets |
|
1013 |
* B num-ent how many entries per sprite set |
|
1014 |
* For vehicles, this is the number of different |
|
1015 |
* vehicle directions in each sprite set |
|
1016 |
* Set num-dirs=8, unless your sprites are symmetric. |
|
1017 |
* In that case, use num-dirs=4. |
|
1018 |
* For stations, must be 12 (hex) for the eighteen |
|
1019 |
* different sprites that make up a station */ |
|
1020 |
/* TODO: No stations support. */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1021 |
uint8 feature; |
0 | 1022 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1023 |
check_length(len, 4, "NewSpriteSet"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1024 |
feature = buf[1]; |
0 | 1025 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1026 |
_cur_grffile->spriteset_start = _cur_spriteid + 1; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1027 |
_cur_grffile->spriteset_feature = feature; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1028 |
_cur_grffile->spriteset_numsets = buf[2]; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1029 |
_cur_grffile->spriteset_numents = buf[3]; |
0 | 1030 |
} |
1031 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1032 |
/* 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
|
1033 |
static void NewSpriteGroup(byte *buf, int len) |
0 | 1034 |
{ |
1035 |
byte *bufend = buf + len; |
|
1036 |
||
1037 |
/* <02> <feature> <set-id> <type/num-entries> <feature-specific-data...> |
|
1038 |
* |
|
1039 |
* B feature see action 1 |
|
1040 |
* B set-id ID of this particular definition |
|
1041 |
* B type/num-entries |
|
1042 |
* if 80 or greater, this is a randomized or variational |
|
1043 |
* list definition, see below |
|
1044 |
* otherwise it specifies a number of entries, the exact |
|
1045 |
* meaning depends on the feature |
|
1046 |
* V feature-specific-data (huge mess, don't even look it up --pasky) */ |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1047 |
/* TODO: No 0x80-types (ugh). */ |
0 | 1048 |
/* TODO: Also, empty sprites aren't handled for now. Need to investigate |
1049 |
* the "opacity" rules for these, that is which sprite to fall back to |
|
1050 |
* when. --pasky */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1051 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1052 |
uint8 setid; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1053 |
/* XXX: For stations, these two are "little cargo" and "lotsa cargo" sets. */ |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1054 |
uint8 numloaded; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1055 |
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
|
1056 |
struct SpriteGroup *group; |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1057 |
byte *loaded_ptr; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1058 |
byte *loading_ptr; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1059 |
int i; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
1060 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1061 |
check_length(len, 5, "NewSpriteGroup"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1062 |
feature = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1063 |
setid = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1064 |
numloaded = buf[3]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1065 |
numloading = buf[4]; |
0 | 1066 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1067 |
if (numloaded == 0x81) { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1068 |
/* XXX: This just goes for the default superset for now, |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1069 |
* straight and safe. --pasky */ |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1070 |
uint8 var = buf[4]; |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1071 |
//uint8 shiftnum = buf[5]; |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1072 |
//uint8 andmask = buf[6]; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1073 |
uint8 nvar = buf[7]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1074 |
//uint32 val; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1075 |
uint16 def; |
0 | 1076 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1077 |
grfmsg(GMS_WARN, "NewSpriteGroup(0x81): Unsupported variable %x. Using default cid.", var); |
0 | 1078 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1079 |
//val = (0xff << shiftnum) & andmask; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1080 |
|
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1081 |
if (setid >= _cur_grffile->spritegroups_count) { |
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1082 |
_cur_grffile->spritegroups_count = setid + 1; |
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1083 |
_cur_grffile->spritegroups = realloc(_cur_grffile->spritegroups, _cur_grffile->spritegroups_count * sizeof(struct SpriteGroup)); |
0 | 1084 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1085 |
buf += 8 + nvar * 4; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1086 |
def = grf_load_word(&buf); |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1087 |
_cur_grffile->spritegroups[setid] = _cur_grffile->spritegroups[def]; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1088 |
return; |
0 | 1089 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1090 |
} else if (numloaded & 0x80) { |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1091 |
grfmsg(GMS_WARN, "NewSpriteGroup(0x%x): Unsupported special group.", numloaded); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1092 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1093 |
} |
0 | 1094 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1095 |
if (!_cur_grffile->spriteset_start) { |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1096 |
grfmsg(GMS_ERROR, "NewSpriteGroup: No sprite set to work on! Skipping."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1097 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1098 |
} |
0 | 1099 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1100 |
if (_cur_grffile->spriteset_feature != feature) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1101 |
grfmsg(GMS_ERROR, "NewSpriteGroup: Group feature %x doesn't match set feature %x! Playing it risky and trying to use it anyway.", feature, _cur_grffile->spriteset_feature); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1102 |
// return; // XXX: we can't because of MB's newstats.grf --pasky |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1103 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1104 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1105 |
check_length(bufend - buf, 5, "NewSpriteGroup"); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1106 |
buf += 5; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1107 |
check_length(bufend - buf, 2 * numloaded, "NewSpriteGroup"); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1108 |
loaded_ptr = buf; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1109 |
loading_ptr = buf + 2 * numloaded; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1110 |
|
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1111 |
if (numloaded > 16) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1112 |
grfmsg(GMS_WARN, "NewSpriteGroup: More than 16 sprites in group %x, skipping the rest.", setid); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1113 |
numloaded = 16; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1114 |
} |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1115 |
if (numloading > 16) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1116 |
grfmsg(GMS_WARN, "NewSpriteGroup: More than 16 sprites in group %x, skipping the rest.", setid); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1117 |
numloading = 16; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1118 |
} |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1119 |
|
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1120 |
if (setid >= _cur_grffile->spritegroups_count) { |
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1121 |
_cur_grffile->spritegroups_count = setid + 1; |
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1122 |
_cur_grffile->spritegroups = realloc(_cur_grffile->spritegroups, _cur_grffile->spritegroups_count * sizeof(struct SpriteGroup)); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1123 |
} |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1124 |
group = &_cur_grffile->spritegroups[setid]; |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1125 |
memset(group, 0, sizeof(struct SpriteGroup)); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1126 |
group->sprites_per_set = _cur_grffile->spriteset_numents; |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1127 |
group->loaded_count = numloaded; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1128 |
group->loading_count = numloading; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1129 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1130 |
DEBUG(grf, 6) ("NewSpriteGroup: New SpriteGroup 0x%02hhx, %u views, %u loaded, %u loading, sprites %u - %u", |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1131 |
setid, group->sprites_per_set, group->loaded_count, group->loading_count, |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1132 |
_cur_grffile->spriteset_start - _cur_grffile->sprite_offset, |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1133 |
_cur_grffile->spriteset_start + (_cur_grffile->spriteset_numents * (numloaded + numloading)) - _cur_grffile->sprite_offset); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1134 |
|
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1135 |
for (i = 0; i < numloaded; i++) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1136 |
uint16 spriteset_id = grf_load_word(&loaded_ptr); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1137 |
group->loaded[i] = _cur_grffile->spriteset_start + spriteset_id * _cur_grffile->spriteset_numents; |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1138 |
DEBUG(grf, 8) ("NewSpriteGroup: + group->loaded[%i] = %u (subset %u)", i, group->loaded[i], spriteset_id); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1139 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1140 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1141 |
for (i = 0; i < numloading; i++) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1142 |
uint16 spriteset_id = grf_load_word(&loading_ptr); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1143 |
group->loading[i] = _cur_grffile->spriteset_start + spriteset_id * _cur_grffile->spriteset_numents; |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1144 |
DEBUG(grf, 8) ("NewSpriteGroup: + group->loading[%i] = %u (subset %u)", i, group->loading[i], spriteset_id); |
0 | 1145 |
} |
1146 |
} |
|
1147 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1148 |
/* 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
|
1149 |
static void NewVehicle_SpriteGroupMapping(byte *buf, int len) |
0 | 1150 |
{ |
1151 |
/* <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
|
1152 |
* id-list := [<id>] [id-list] |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1153 |
* cargo-list := <cargo-type> <cid> [cargo-list] |
0 | 1154 |
* |
1155 |
* B feature see action 0 |
|
1156 |
* B n-id bits 0-6: how many IDs this definition applies to |
|
1157 |
* bit 7: if set, this is a wagon override definition (see below) |
|
1158 |
* 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
|
1159 |
* B num-cid number of cargo IDs (sprite group IDs) in this definition |
0 | 1160 |
* can be zero, in that case the def-cid is used always |
1161 |
* 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
|
1162 |
* 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
|
1163 |
* W def-cid default cargo ID (sprite group ID) */ |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1164 |
/* TODO: Bridges, town houses. */ |
0 | 1165 |
/* TODO: Multiple cargo support could be useful even for trains/cars - |
1166 |
* cargo id 0xff is used for showing images in the build train list. */ |
|
1167 |
||
1168 |
static byte *last_engines; |
|
1169 |
static int last_engines_count; |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1170 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1171 |
uint8 idcount; |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1172 |
bool wagover; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1173 |
uint8 cidcount; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1174 |
int c, i; |
0 | 1175 |
|
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1176 |
check_length(len, 7, "VehicleMapSpriteGroup"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1177 |
feature = buf[1]; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1178 |
idcount = buf[2] & 0x7F; |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1179 |
wagover = (buf[2] & 0x80) == 0x80; |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1180 |
check_length(len, 3 + idcount, "VehicleMapSpriteGroup"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1181 |
cidcount = buf[3 + idcount]; |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1182 |
check_length(len, 4 + idcount + cidcount * 3, "VehicleMapSpriteGroup"); |
0 | 1183 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1184 |
DEBUG(grf, 6) ("VehicleMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d.", |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1185 |
feature, idcount, cidcount, wagover); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1186 |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1187 |
if (feature > GSF_STATION) { |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1188 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Unsupported feature %d, skipping.", feature); |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1189 |
return; |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1190 |
} |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
1191 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1192 |
|
373
218e83c92cb8
(svn r561) -newgrf: killed some of the magic numbers in the code (pasky)
celestar
parents:
372
diff
changeset
|
1193 |
if (feature == GSF_STATION) { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1194 |
// We do things differently for stations. |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1195 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1196 |
/* XXX: Currently we don't support cargo-specific images, so |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1197 |
* we go straight to the defaults. */ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1198 |
byte *bp = buf + 4 + idcount + cidcount * 3; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1199 |
uint16 groupid = grf_load_word(&bp); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1200 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1201 |
for (i = 0; i < idcount; i++) { |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1202 |
struct StationSpec *stat; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1203 |
uint8 stid = buf[3 + i]; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1204 |
int j; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1205 |
|
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1206 |
if (groupid >= _cur_grffile->spritegroups_count) { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1207 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x, skipping.", |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1208 |
groupid, _cur_grffile->spritegroups_count); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1209 |
return; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1210 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1211 |
|
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1212 |
stat = &_cur_grffile->stations[stid]; |
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1213 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1214 |
// relocate sprite indexes based on spriteset locations |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1215 |
for (j = 0; j < stat->tiles; j++) { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1216 |
DrawTileSeqStruct *seq; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1217 |
|
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1218 |
foreach_draw_tile_seq(seq, (DrawTileSeqStruct*) stat->renderdata[j].seq) { |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1219 |
seq->image += _cur_grffile->spritegroups[groupid].loading[0]; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1220 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1221 |
} |
400
d0608455bb77
(svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents:
399
diff
changeset
|
1222 |
stat->grfid = _cur_grffile->grfid; |
399
ad3dcbfd2d48
(svn r591) -newgrf: Store whole struct StationSpec in SetCustomStation(), not just the rendering data. This will be needed for variational stationspecs (pasky).
darkvater
parents:
398
diff
changeset
|
1223 |
SetCustomStation(stid, stat); |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1224 |
stat->classid = 0; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1225 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1226 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1227 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1228 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1229 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1230 |
/* If ``n-id'' (or ``idcount'') is zero, this is a ``feature |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1231 |
* callback''. I have no idea how this works, so we will ignore it for |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1232 |
* now. --octo */ |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1233 |
if (idcount == 0) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1234 |
grfmsg(GMS_NOTICE, "NewMapping: Feature callbacks not implemented yet."); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1235 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1236 |
} |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1237 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1238 |
// FIXME: Tropicset contains things like: |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1239 |
// 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
|
1240 |
// what should we exactly do with that? --pasky |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1241 |
|
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1242 |
if (!_cur_grffile->spriteset_start || !_cur_grffile->spritegroups) { |
369
ab2266938fa8
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
368
diff
changeset
|
1243 |
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
|
1244 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1245 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1246 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1247 |
if (!wagover && last_engines_count != idcount) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1248 |
last_engines = realloc(last_engines, idcount); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1249 |
last_engines_count = idcount; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1250 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1251 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1252 |
if (wagover) { |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1253 |
if (last_engines_count == 0) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1254 |
grfmsg(GMS_ERROR, "VehicleMapSpriteGroup: WagonOverride: No engine to do override with."); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1255 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1256 |
} |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1257 |
DEBUG(grf, 6) ("VehicleMapSpriteGroup: WagonOverride: %u engines, %u wagons.", |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1258 |
last_engines_count, idcount); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1259 |
} |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1260 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1261 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1262 |
for (i = 0; i < idcount; i++) { |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1263 |
uint8 engine_id = buf[3 + i]; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1264 |
uint8 engine = engine_id + _vehshifts[feature]; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1265 |
byte *bp = &buf[4 + idcount]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1266 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1267 |
if (engine_id > _vehcounts[feature]) { |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1268 |
grfmsg(GMS_ERROR, "Id %u for feature %x is out of bounds.", |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1269 |
engine_id, feature); |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1270 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1271 |
} |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1272 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1273 |
DEBUG(grf, 7) ("VehicleMapSpriteGroup: [%d] Engine %d...", i, engine); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1274 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1275 |
for (c = 0; c < cidcount; c++) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1276 |
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
|
1277 |
uint16 groupid = grf_load_word(&bp); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1278 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1279 |
DEBUG(grf, 8) ("VehicleMapSpriteGroup: * [%d] Cargo type %x, group id %x", c, ctype, groupid); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1280 |
|
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1281 |
if (groupid >= _cur_grffile->spritegroups_count) { |
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1282 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x, skipping.", groupid, _cur_grffile->spritegroups_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1283 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1284 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1285 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1286 |
if (ctype == 0xFF) |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1287 |
ctype = CID_PURCHASE; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1288 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1289 |
if (wagover) { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1290 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1291 |
SetWagonOverrideSprites(engine, &_cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1292 |
} else { |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1293 |
SetCustomEngineSprites(engine, ctype, &_cur_grffile->spritegroups[groupid]); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1294 |
last_engines[i] = engine; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1295 |
} |
0 | 1296 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1297 |
} |
0 | 1298 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1299 |
{ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1300 |
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
|
1301 |
uint16 groupid = grf_load_word(&bp); |
0 | 1302 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1303 |
DEBUG(grf, 8) ("-- Default group id %x", groupid); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1304 |
|
0 | 1305 |
for (i = 0; i < idcount; i++) { |
1306 |
uint8 engine = buf[3 + i] + _vehshifts[feature]; |
|
1307 |
||
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1308 |
// Don't tell me you don't love duplicated code! |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1309 |
if (groupid >= _cur_grffile->spritegroups_count) { |
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1310 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x, skipping.", groupid, _cur_grffile->spritegroups_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1311 |
return; |
0 | 1312 |
} |
1313 |
||
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1314 |
if (wagover) { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1315 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1316 |
SetWagonOverrideSprites(engine, &_cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1317 |
} else { |
397
fc532e982139
(svn r589) -newgrf: Rename spritesset to spritegroups (pasky).
darkvater
parents:
396
diff
changeset
|
1318 |
SetCustomEngineSprites(engine, CID_DEFAULT, &_cur_grffile->spritegroups[groupid]); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1319 |
last_engines[i] = engine; |
0 | 1320 |
} |
1321 |
} |
|
1322 |
} |
|
1323 |
} |
|
1324 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1325 |
/* Action 0x04 */ |
0 | 1326 |
static void VehicleNewName(byte *buf, int len) |
1327 |
{ |
|
1328 |
/* <04> <veh-type> <language-id> <num-veh> <offset> <data...> |
|
1329 |
* |
|
1330 |
* B veh-type see action 0 |
|
1331 |
* B language-id language ID with bit 7 cleared (see below) |
|
1332 |
* B num-veh number of vehicles which are getting a new name |
|
1333 |
* B offset number of the first vehicle that gets a new name |
|
1334 |
* S data new texts, each of them zero-terminated, after |
|
1335 |
* which the next name begins. */ |
|
1336 |
/* TODO: No support for changing non-vehicle text. Perhaps we shouldn't |
|
1337 |
* implement it at all, but it could be useful for some "modpacks" |
|
1338 |
* (completely new scenarios changing all graphics and logically also |
|
1339 |
* factory names etc). We should then also support all languages (by |
|
1340 |
* name), not only the original four ones. --pasky */ |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1341 |
/* TODO: Support for custom station class/type names. */ |
0 | 1342 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1343 |
uint8 feature; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1344 |
uint8 lang; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1345 |
uint8 id; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1346 |
uint8 endid; |
0 | 1347 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1348 |
check_length(len, 6, "VehicleNewName"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1349 |
feature = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1350 |
lang = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1351 |
id = buf[4] + _vehshifts[feature]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1352 |
endid = id + buf[3]; |
0 | 1353 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1354 |
DEBUG(grf, 6) ("VehicleNewName: About to rename engines %d..%d (feature %d) in language 0x%x.", |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1355 |
id, endid, feature, lang); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1356 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1357 |
if (lang & 0x80) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1358 |
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
|
1359 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1360 |
} |
0 | 1361 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1362 |
if (!(lang & 3)) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1363 |
/* XXX: If non-English name, silently skip it. */ |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1364 |
DEBUG(grf, 7) ("VehicleNewName: Skipping non-English name."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1365 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1366 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1367 |
|
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1368 |
buf += 5, len -= 5; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1369 |
for (; id < endid && len > 0; id++) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1370 |
int ofs = strlen(buf) + 1; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1371 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1372 |
if (ofs < 128) { |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1373 |
DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, buf); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1374 |
SetCustomEngineName(id, buf); |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1375 |
} else { |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1376 |
DEBUG(grf, 7) ("VehicleNewName: Too long a name (%d)", ofs); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1377 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1378 |
buf += ofs, len -= ofs; |
0 | 1379 |
} |
1380 |
} |
|
1381 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1382 |
/* Action 0x05 */ |
0 | 1383 |
static void GraphicsNew(byte *buf, int len) |
1384 |
{ |
|
1385 |
/* <05> <graphics-type> <num-sprites> <other data...> |
|
1386 |
* |
|
1387 |
* B graphics-type What set of graphics the sprites define. |
|
1388 |
* B num-sprites How many sprites are in this set? |
|
1389 |
* V other data Graphics type specific data. Currently unused. */ |
|
1390 |
/* TODO */ |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1391 |
|
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1392 |
uint8 type; |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1393 |
uint8 num; |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1394 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1395 |
check_length(len, 2, "GraphicsNew"); |
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1396 |
type = buf[0]; |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1397 |
num = buf[1]; |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1398 |
|
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1399 |
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
|
1400 |
type, num); |
0 | 1401 |
} |
1402 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1403 |
/* Action 0x06 */ |
0 | 1404 |
static void CfgApply(byte *buf, int len) |
1405 |
{ |
|
1406 |
/* <06> <param-num> <param-size> <offset> ... <FF> |
|
1407 |
* |
|
1408 |
* B param-num Number of parameter to substitute (First = "zero") |
|
1409 |
* Ignored if that parameter was not specified in newgrf.cfg |
|
1410 |
* B param-size How many bytes to replace. If larger than 4, the |
|
1411 |
* bytes of the following parameter are used. In that |
|
1412 |
* case, nothing is applied unless *all* parameters |
|
1413 |
* were specified. |
|
1414 |
* B offset Offset into data from beginning of next sprite |
|
1415 |
* to place where parameter is to be stored. */ |
|
1416 |
/* TODO */ |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1417 |
grfmsg(GMS_NOTICE, "CfgApply: Ignoring (not implemented).\n"); |
0 | 1418 |
} |
1419 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1420 |
/* Action 0x07 */ |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1421 |
/* Action 0x09 */ |
0 | 1422 |
static void SkipIf(byte *buf, int len) |
1423 |
{ |
|
1424 |
/* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites> |
|
1425 |
* |
|
1426 |
* B param-num |
|
1427 |
* B param-size |
|
1428 |
* B condition-type |
|
1429 |
* V value |
|
1430 |
* B num-sprites */ |
|
1431 |
/* TODO: More params. More condition types. */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1432 |
uint8 param; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1433 |
uint8 paramsize; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1434 |
uint8 condtype; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1435 |
uint8 numsprites; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1436 |
int param_val = 0, cond_val = 0; |
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1437 |
bool result; |
0 | 1438 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1439 |
check_length(len, 6, "SkipIf"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1440 |
param = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1441 |
paramsize = buf[2]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1442 |
condtype = buf[3]; |
0 | 1443 |
|
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
|
1444 |
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
|
1445 |
/* 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
|
1446 |
* 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
|
1447 |
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
|
1448 |
} |
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
|
1449 |
|
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
|
1450 |
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
|
1451 |
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
|
1452 |
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
|
1453 |
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
|
1454 |
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
|
1455 |
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
|
1456 |
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
|
1457 |
|
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
|
1458 |
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
|
1459 |
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
|
1460 |
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
|
1461 |
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
|
1462 |
case 0x84: |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1463 |
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
|
1464 |
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
|
1465 |
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
|
1466 |
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
|
1467 |
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
|
1468 |
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
|
1469 |
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
|
1470 |
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
|
1471 |
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
|
1472 |
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
|
1473 |
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
|
1474 |
|
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
|
1475 |
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
|
1476 |
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
|
1477 |
} 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
|
1478 |
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
|
1479 |
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
|
1480 |
/* 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
|
1481 |
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
|
1482 |
} 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
|
1483 |
/* 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
|
1484 |
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
|
1485 |
} |
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
|
1486 |
return; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1487 |
} |
0 | 1488 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1489 |
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
|
1490 |
case 0: result = (param_val & (1 << cond_val)); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1491 |
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
|
1492 |
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
|
1493 |
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
|
1494 |
/* 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
|
1495 |
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
|
1496 |
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
|
1497 |
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
|
1498 |
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
|
1499 |
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
|
1500 |
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
|
1501 |
case 5: result = (param_val > cond_val); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1502 |
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
|
1503 |
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
|
1504 |
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
|
1505 |
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
|
1506 |
break; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1507 |
default: |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1508 |
grfmsg(GMS_WARN, "Unsupported test %d. Ignoring.", condtype); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1509 |
return; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1510 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1511 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1512 |
if (result == 0) { |
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
|
1513 |
grfmsg(GMS_NOTICE, "Not skipping sprites, test was false."); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1514 |
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
|
1515 |
} |
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
|
1516 |
|
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
|
1517 |
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
|
1518 |
grfmsg(GMS_NOTICE, "Skipping %d sprites, test was true.", numsprites); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1519 |
_skip_sprites = numsprites; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1520 |
if (_skip_sprites == 0) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1521 |
/* Zero means there are no sprites to skip, so |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1522 |
* we use -1 to indicate that all further |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1523 |
* sprites should be skipped. */ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1524 |
_skip_sprites = -1; |
0 | 1525 |
} |
1526 |
} |
|
1527 |
||
1528 |
static void GRFInfo(byte *buf, int len) |
|
1529 |
{ |
|
1530 |
/* <08> <version> <grf-id> <name> <info> |
|
1531 |
* |
|
1532 |
* B version newgrf version, currently 06 |
|
1533 |
* 4*B grf-id globally unique ID of this .grf file |
|
1534 |
* S name name of this .grf set |
|
1535 |
* S info string describing the set, and e.g. author and copyright */ |
|
1536 |
/* TODO: Check version. (We should have own versioning done somehow.) */ |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1537 |
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
|
1538 |
uint32 grfid; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1539 |
char *name; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1540 |
char *info; |
0 | 1541 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1542 |
check_length(len, 9, "GRFInfo"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1543 |
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
|
1544 |
/* this is de facto big endian - grf_load_dword() unsuitable */ |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1545 |
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
|
1546 |
name = buf + 6; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1547 |
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
|
1548 |
|
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
|
1549 |
_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
|
1550 |
_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
|
1551 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1552 |
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
|
1553 |
_cur_grffile->filename, version, grfid, name, info); |
0 | 1554 |
} |
1555 |
||
1556 |
static void SpriteReplace(byte *buf, int len) |
|
1557 |
{ |
|
1558 |
/* <0A> <num-sets> <set1> [<set2> ...] |
|
1559 |
* <set>: <num-sprites> <first-sprite> |
|
1560 |
* |
|
1561 |
* B num-sets How many sets of sprites to replace. |
|
1562 |
* Each set: |
|
1563 |
* B num-sprites How many sprites are in this set |
|
1564 |
* 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
|
1565 |
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
|
1566 |
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
|
1567 |
|
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
|
1568 |
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
|
1569 |
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
|
1570 |
|
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
|
1571 |
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
|
1572 |
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
|
1573 |
} |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1574 |
|
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
|
1575 |
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
|
1576 |
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
|
1577 |
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
|
1578 |
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
|
1579 |
|
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
|
1580 |
_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
|
1581 |
_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
|
1582 |
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
|
1583 |
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
|
1584 |
} 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
|
1585 |
_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
|
1586 |
_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
|
1587 |
} |
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
|
1588 |
} |
0 | 1589 |
} |
1590 |
||
1591 |
static void GRFError(byte *buf, int len) |
|
1592 |
{ |
|
1593 |
/* <0B> <severity> <language-id> <message-id> [<message...> 00] [<data...>] 00 [<parnum>] |
|
1594 |
* |
|
1595 |
* B severity 00: notice, contine loading grf file |
|
1596 |
* 01: warning, continue loading grf file |
|
1597 |
* 02: error, but continue loading grf file, and attempt |
|
1598 |
* loading grf again when loading or starting next game |
|
1599 |
* 03: error, abort loading and prevent loading again in |
|
1600 |
* the future (only when restarting the patch) |
|
1601 |
* B language-id see action 4, use 1F for built-in error messages |
|
1602 |
* B message-id message to show, see below |
|
1603 |
* S message for custom messages (message-id FF), text of the message |
|
1604 |
* not present for built-in messages. |
|
1605 |
* V data additional data for built-in (or custom) messages |
|
1606 |
* B parnum see action 6, only used with built-in message 03 */ |
|
1607 |
/* TODO: For now we just show the message, sometimes incomplete and never translated. */ |
|
1608 |
||
1609 |
static const char * const msgstr[4] = { |
|
1610 |
"Requires at least pseudo-TTDPatch version %s.", |
|
1611 |
"This file is for %s version of TTD.", |
|
1612 |
"Designed to be used with %s.", |
|
1613 |
"Invalid parameter %s.", |
|
1614 |
}; |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1615 |
uint8 severity; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1616 |
uint8 msgid; |
0 | 1617 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1618 |
check_length(len, 6, "GRFError"); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1619 |
severity = buf[1]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1620 |
msgid = buf[3]; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1621 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1622 |
if (msgid == 0xFF) { |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1623 |
grfmsg(severity, "%s", buf+4); |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1624 |
} else { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
1625 |
grfmsg(severity, msgstr[msgid], buf+4); |
0 | 1626 |
} |
1627 |
} |
|
1628 |
||
1629 |
static void GRFComment(byte *buf, int len) |
|
1630 |
{ |
|
1631 |
/* <0C> [<ignored...>] |
|
1632 |
* |
|
1633 |
* V ignored Anything following the 0C is ignored */ |
|
1634 |
} |
|
1635 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1636 |
/* Action 0x0D */ |
0 | 1637 |
static void ParamSet(byte *buf, int len) |
1638 |
{ |
|
1639 |
/* <0D> <target> <operation> <source1> <source2> [<data>] |
|
1640 |
* |
|
1641 |
* B target parameter number where result is stored |
|
1642 |
* B operation operation to perform, see below |
|
1643 |
* B source1 first source operand |
|
1644 |
* B source2 second source operand |
|
1645 |
* D data data to use in the calculation, not necessary |
|
1646 |
* if both source1 and source2 refer to actual parameters |
|
1647 |
* |
|
1648 |
* Operations |
|
1649 |
* 00 Set parameter equal to source1 |
|
1650 |
* 01 Addition, source1 + source2 |
|
1651 |
* 02 Subtraction, source1 - source2 |
|
1652 |
* 03 Unsigned multiplication, source1 * source2 (both unsigned) |
|
1653 |
* 04 Signed multiplication, source1 * source2 (both signed) |
|
1654 |
* 05 Unsigned bit shift, source1 by source2 (source2 taken to be a |
|
1655 |
* signed quantity; left shift if positive and right shift if |
|
1656 |
* negative, source1 is unsigned) |
|
1657 |
* 06 Signed bit shift, source1 by source2 |
|
1658 |
* (source2 like in 05, and source1 as well) |
|
1659 |
*/ |
|
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
|
1660 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1661 |
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
|
1662 |
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
|
1663 |
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
|
1664 |
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
|
1665 |
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
|
1666 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1667 |
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
|
1668 |
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
|
1669 |
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
|
1670 |
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
|
1671 |
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
|
1672 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1673 |
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
|
1674 |
data = grf_load_dword(&buf); |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1675 |
|
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
|
1676 |
/* 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
|
1677 |
* 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
|
1678 |
* 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
|
1679 |
* - 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
|
1680 |
* - 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
|
1681 |
* 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
|
1682 |
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
|
1683 |
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
|
1684 |
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
|
1685 |
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
|
1686 |
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
|
1687 |
} |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1688 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1689 |
/* 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
|
1690 |
* 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
|
1691 |
* 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
|
1692 |
* 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
|
1693 |
* 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
|
1694 |
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
|
1695 |
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
|
1696 |
} 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
|
1697 |
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
|
1698 |
} |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1699 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1700 |
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
|
1701 |
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
|
1702 |
} 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
|
1703 |
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
|
1704 |
} |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1705 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1706 |
/* 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
|
1707 |
* 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
|
1708 |
* 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
|
1709 |
* 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
|
1710 |
* 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
|
1711 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1712 |
/* 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
|
1713 |
* 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
|
1714 |
* 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
|
1715 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1716 |
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
|
1717 |
_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
|
1718 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
1719 |
/* 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
|
1720 |
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
|
1721 |
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
|
1722 |
_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
|
1723 |
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
|
1724 |
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
|
1725 |
_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
|
1726 |
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
|
1727 |
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
|
1728 |
_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
|
1729 |
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
|
1730 |
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
|
1731 |
_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
|
1732 |
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
|
1733 |
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
|
1734 |
_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
|
1735 |
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
|
1736 |
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
|
1737 |
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
|
1738 |
_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
|
1739 |
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
|
1740 |
_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
|
1741 |
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
|
1742 |
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
|
1743 |
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
|
1744 |
_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
|
1745 |
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
|
1746 |
_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
|
1747 |
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
|
1748 |
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
|
1749 |
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
|
1750 |
} |
0 | 1751 |
} |
1752 |
||
1753 |
static void GRFInhibit(byte *buf, int len) |
|
1754 |
{ |
|
1755 |
/* <0E> <num> <grfids...> |
|
1756 |
* |
|
1757 |
* B num Number of GRFIDs that follow |
|
1758 |
* 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
|
1759 |
|
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
|
1760 |
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
|
1761 |
int i; |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1762 |
|
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
|
1763 |
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
|
1764 |
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
|
1765 |
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
|
1766 |
|
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
|
1767 |
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
|
1768 |
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
|
1769 |
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
|
1770 |
|
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
|
1771 |
/* 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
|
1772 |
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
|
1773 |
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
|
1774 |
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
|
1775 |
} |
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
|
1776 |
} |
0 | 1777 |
} |
1778 |
||
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
|
1779 |
|
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
|
1780 |
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
|
1781 |
{ |
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
|
1782 |
/* 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
|
1783 |
|
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
|
1784 |
_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
|
1785 |
| (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
|
1786 |
| (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
|
1787 |
| (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
|
1788 |
| (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
|
1789 |
| (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
|
1790 |
| (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
|
1791 |
| (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
|
1792 |
|
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
|
1793 |
_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
|
1794 |
| (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
|
1795 |
| (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
|
1796 |
} |
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
|
1797 |
|
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1798 |
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
|
1799 |
{ |
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
|
1800 |
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
|
1801 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1802 |
newfile = calloc(1, sizeof(struct GRFFile)); |
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
|
1803 |
|
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
|
1804 |
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
|
1805 |
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
|
1806 |
|
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
|
1807 |
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
|
1808 |
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
|
1809 |
|
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
|
1810 |
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
|
1811 |
_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
|
1812 |
_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
|
1813 |
} 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
|
1814 |
_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
|
1815 |
_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
|
1816 |
} |
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
|
1817 |
} |
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
|
1818 |
|
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
|
1819 |
|
0 | 1820 |
/* Here we perform initial decoding of some special sprites (as are they |
1821 |
* 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
|
1822 |
* partial implementation yet). */ |
0 | 1823 |
/* XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by |
1824 |
* a crafted invalid GRF file. We should tell that to the user somehow, or |
|
1825 |
* better make this more robust in the future. */ |
|
1826 |
||
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1827 |
void DecodeSpecialSprite(const char *filename, int num, int spriteid, int stage) |
0 | 1828 |
{ |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
1829 |
#define NUM_ACTIONS 0xF |
0 | 1830 |
static const SpecialSpriteHandler handlers[NUM_ACTIONS] = { |
1831 |
/* 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
|
1832 |
/* 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
|
1833 |
/* 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
|
1834 |
/* 0x3 */ NewVehicle_SpriteGroupMapping, |
0 | 1835 |
/* 0x4 */ VehicleNewName, |
1836 |
/* 0x5 */ GraphicsNew, |
|
1837 |
/* 0x6 */ CfgApply, |
|
1838 |
/* 0x7 */ SkipIf, |
|
1839 |
/* 0x8 */ GRFInfo, |
|
1840 |
/* 0x9 */ SkipIf, |
|
1841 |
/* 0xa */ SpriteReplace, |
|
1842 |
/* 0xb */ GRFError, |
|
1843 |
/* 0xc */ GRFComment, |
|
1844 |
/* 0xd */ ParamSet, |
|
1845 |
/* 0xe */ GRFInhibit, |
|
1846 |
}; |
|
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
|
1847 |
static int initialized; |
0 | 1848 |
byte action; |
1849 |
byte *buf = malloc(num); |
|
1850 |
int i; |
|
1851 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
1852 |
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
|
1853 |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
1854 |
if (initialized == 0) { |
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
|
1855 |
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
|
1856 |
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
|
1857 |
} |
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
|
1858 |
|
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1859 |
_cur_stage = stage; |
0 | 1860 |
_cur_spriteid = spriteid; |
1861 |
||
1862 |
for (i = 0; i != num; i++) |
|
1863 |
buf[i] = FioReadByte(); |
|
1864 |
||
1865 |
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
|
1866 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1867 |
/* XXX: There is a difference between staged loading in TTDPatch and |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1868 |
* here. In TTDPatch, for some reason actions 1 and 2 are carried out |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1869 |
* during stage 0, whilst action 3 is carried out during stage 1 (to |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1870 |
* "resolve" cargo IDs... wtf). This is a little problem, because cargo |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1871 |
* IDs are valid only within a given set (action 1) block, and may be |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1872 |
* overwritten after action 3 associates them. But overwriting happens |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1873 |
* in an earlier stage than associating, so... We just process actions |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1874 |
* 1 and 2 in stage 1 now, let's hope that won't get us into problems. |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1875 |
* --pasky */ |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1876 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1877 |
if (stage == 0) { |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1878 |
/* During initialization, actions 0, 1, 2, 3, 4, 5 and 7 are ignored. */ |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1879 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1880 |
if ((action == 0x00) || (action == 0x01) || (action == 0x02) || (action == 0x03) |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1881 |
|| (action == 0x04) || (action == 0x05) || (action == 0x07)) { |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1882 |
DEBUG (grf, 7) ("DecodeSpecialSprite: Action: %x, Stage 0, Skipped", action); |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1883 |
/* Do nothing. */ |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1884 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1885 |
} else if (action < NUM_ACTIONS) { |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1886 |
DEBUG (grf, 7) ("DecodeSpecialSprite: Action: %x, Stage 0", action); |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1887 |
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
|
1888 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1889 |
} else { |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1890 |
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
|
1891 |
} |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1892 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1893 |
} 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
|
1894 |
/* 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
|
1895 |
* 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
|
1896 |
* 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
|
1897 |
* 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
|
1898 |
* 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
|
1899 |
* |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1900 |
* During activation, only actions 0, 1, 2, 3, 4, 5, 7, 8, 9 and 0A are |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1901 |
* 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
|
1902 |
* 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
|
1903 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1904 |
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
|
1905 |
_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
|
1906 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1907 |
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
|
1908 |
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
|
1909 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1910 |
if (!(_cur_grffile->flags & 0x0001)) { |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1911 |
DEBUG (grf, 7) ("DecodeSpecialSprite: Action: %x, Stage 1, Not activated", action); |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1912 |
/* Do nothing. */ |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1913 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1914 |
} else if ((action == 0x00) || (action == 0x01) || (action == 0x02) || (action == 0x03) |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1915 |
|| (action == 0x04) || (action == 0x05) || (action == 0x07) || (action == 0x08) |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1916 |
|| (action == 0x09) || (action == 0x0A)) { |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1917 |
DEBUG (grf, 7) ("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
|
1918 |
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
|
1919 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1920 |
} else if (action < NUM_ACTIONS) { |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
1921 |
DEBUG (grf, 7) ("DecodeSpecialSprite: Action: %x, Stage 1, Skipped", action); |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1922 |
/* Do nothing. */ |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1923 |
|
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1924 |
} else { |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1925 |
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
|
1926 |
} |
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1927 |
|
0 | 1928 |
} else { |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
1929 |
error("Invalid stage %d", stage); |
0 | 1930 |
} |
1931 |
||
1932 |
free(buf); |
|
1933 |
#undef NUM_ACTIONS |
|
1934 |
} |