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