author | peter1138 |
Sun, 07 May 2006 11:41:44 +0000 | |
changeset 3777 | 455c0c7b657e |
parent 3775 | 0fb5118536c3 |
child 3783 | 0199c4b70cc2 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3 |
#include "stdafx.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 <stdarg.h> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
6 |
|
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1883
diff
changeset
|
7 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1183
diff
changeset
|
8 |
#include "debug.h" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
9 |
#include "gfx.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
10 |
#include "fileio.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
11 |
#include "functions.h" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
12 |
#include "engine.h" |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
13 |
#include "spritecache.h" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
14 |
#include "station.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
15 |
#include "sprite.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
16 |
#include "newgrf.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2013
diff
changeset
|
17 |
#include "variables.h" |
3566
21db83574baf
(svn r4447) - NewGRF: It seems I committed printing action NOP Action 0x0C which is mainly used for comments. So leave it in, but fix the created warning. Use proper action name for check_length() in Action 0x10
Darkvater
parents:
3561
diff
changeset
|
18 |
#include "string.h" |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
19 |
#include "bridge.h" |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
20 |
#include "economy.h" |
2962
f0a49b646c48
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2958
diff
changeset
|
21 |
#include "newgrf_engine.h" |
3577
c6532e0bee4c
(svn r4463) -Codechange. Include vehicle.h directly instead of implicitly via station.h in a number of source files
celestar
parents:
3571
diff
changeset
|
22 |
#include "vehicle.h" |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
23 |
#include "newgrf_text.h" |
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
24 |
#include "table/sprites.h" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
25 |
|
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
26 |
#include "newgrf_spritegroup.h" |
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
27 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
28 |
/* TTDPatch extended GRF format codec |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
29 |
* (c) Petr Baudis 2004 (GPL'd) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
30 |
* 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
|
31 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
32 |
* Contains portions of documentation by TTDPatch team. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
33 |
* 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
|
34 |
* 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
|
35 |
* 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
|
36 |
|
455 | 37 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
38 |
uint16 _custom_sprites_base; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
39 |
static int _skip_sprites; // XXX |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
40 |
static uint _file_index; // XXX |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
41 |
extern int _traininfo_vehicle_pitch; |
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
42 |
SpriteID _signal_base = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
43 |
|
2340
e18ef06bc59a
(svn r2866) Move all functions and tables which aren't directly involved in managing the sprite heap to a new file gfxinit.c.
tron
parents:
2336
diff
changeset
|
44 |
static GRFFile *_cur_grffile; |
1477 | 45 |
GRFFile *_first_grffile; |
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
46 |
GRFConfig *_first_grfconfig; |
3707
7dc7e4d2487e
(svn r4650) - NewGRF: use the correct type for _cur_spriteid
peter1138
parents:
3704
diff
changeset
|
47 |
static SpriteID _cur_spriteid; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
48 |
static int _cur_stage; |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
49 |
static uint32 _nfo_line; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
50 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
51 |
/* 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
|
52 |
static uint32 _ttdpatch_flags[8]; |
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 |
|
1477 | 55 |
typedef enum grfspec_feature { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
56 |
GSF_TRAIN, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
57 |
GSF_ROAD, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
58 |
GSF_SHIP, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
59 |
GSF_AIRCRAFT, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
60 |
GSF_STATION, |
2438
f0bf4adbd620
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
61 |
GSF_CANAL, |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
62 |
GSF_BRIDGE, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
63 |
GSF_TOWNHOUSE, |
3620
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
64 |
GSF_GLOBALVAR, |
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
65 |
GSF_INDUSTRYTILES, |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
66 |
GSF_INDUSTRIES, |
3620
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
67 |
GSF_CARGOS, |
a8f09c120f03
(svn r4517) - NewGRF: fix and complete the feature list
peter1138
parents:
3614
diff
changeset
|
68 |
GSF_SOUNDFX, |
1477 | 69 |
} grfspec_feature; |
452
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 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
72 |
typedef void (*SpecialSpriteHandler)(byte *buf, int len); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
73 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
74 |
static const int _vehcounts[4] = { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
75 |
/* GSF_TRAIN */ NUM_TRAIN_ENGINES, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
76 |
/* GSF_ROAD */ NUM_ROAD_ENGINES, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
77 |
/* GSF_SHIP */ NUM_SHIP_ENGINES, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
78 |
/* GSF_AIRCRAFT */ NUM_AIRCRAFT_ENGINES |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
79 |
}; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
80 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
81 |
static const int _vehshifts[4] = { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
82 |
/* GSF_TRAIN */ 0, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
83 |
/* GSF_ROAD */ ROAD_ENGINES_INDEX, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
84 |
/* GSF_SHIP */ SHIP_ENGINES_INDEX, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
85 |
/* GSF_AIRCRAFT */ AIRCRAFT_ENGINES_INDEX, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
86 |
}; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
87 |
|
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
88 |
enum { |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
89 |
MAX_STATIONS = 256, |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
90 |
}; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
91 |
|
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
92 |
static uint16 cargo_allowed[TOTAL_NUM_ENGINES]; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
93 |
static uint16 cargo_disallowed[TOTAL_NUM_ENGINES]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
94 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
95 |
/* Debugging messages policy: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
96 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
97 |
* 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
|
98 |
* (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
|
99 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
100 |
* 0..2 - dedicated to grfmsg() |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
101 |
* 3 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
102 |
* 4 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
103 |
* 5 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
104 |
* 6 - action handler entry reporting - one per action |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
105 |
* 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
|
106 |
* 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
|
107 |
* 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
|
108 |
*/ |
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 |
|
1477 | 111 |
typedef enum grfmsg_severity { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
112 |
GMS_NOTICE, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
113 |
GMS_WARN, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
114 |
GMS_ERROR, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
115 |
GMS_FATAL, |
1477 | 116 |
} grfmsg_severity; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
117 |
|
1477 | 118 |
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
|
119 |
{ |
1477 | 120 |
static const char* const severitystr[] = { |
121 |
"Notice", |
|
122 |
"Warning", |
|
123 |
"Error", |
|
124 |
"Fatal" |
|
125 |
}; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
126 |
int export_severity = 0; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
127 |
char buf[1024]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
128 |
va_list va; |
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 |
va_start(va, str); |
1477 | 131 |
vsnprintf(buf, sizeof(buf), str, va); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
132 |
va_end(va); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
133 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
134 |
export_severity = 2 - (severity == GMS_FATAL ? 2 : severity); |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
135 |
DEBUG(grf, export_severity) ("[%s:%d][%s] %s", _cur_grffile->filename, _nfo_line, severitystr[severity], buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
136 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
137 |
|
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 |
#define check_length(real, wanted, where) \ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
140 |
do { \ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
141 |
if (real < wanted) { \ |
2849
a8adbd09c6df
(svn r3397) - NewGRF fix: Show nfo sprite number instead of current sprite id for warning messages -- this makes this output more useful...
peter1138
parents:
2846
diff
changeset
|
142 |
grfmsg(GMS_ERROR, "%s: Invalid special sprite length %d (expected %d)!", \ |
a8adbd09c6df
(svn r3397) - NewGRF fix: Show nfo sprite number instead of current sprite id for warning messages -- this makes this output more useful...
peter1138
parents:
2846
diff
changeset
|
143 |
where, real, wanted); \ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
144 |
return; \ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
145 |
} \ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
146 |
} while (0) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
147 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
148 |
|
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
490
diff
changeset
|
149 |
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
|
150 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
151 |
return *(*buf)++; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
152 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
153 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
154 |
static uint16 grf_load_word(byte **buf) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
155 |
{ |
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
156 |
uint16 val = grf_load_byte(buf); |
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
157 |
return val | (grf_load_byte(buf) << 8); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
158 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
159 |
|
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
160 |
static uint16 grf_load_extended(byte** buf) |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
161 |
{ |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
162 |
uint16 val; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
163 |
val = grf_load_byte(buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
164 |
if (val == 0xFF) val = grf_load_word(buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
165 |
return val; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
166 |
} |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
167 |
|
2324 | 168 |
static uint32 grf_load_dword(byte **buf) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
169 |
{ |
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
170 |
uint32 val = grf_load_word(buf); |
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
171 |
return val | (grf_load_word(buf) << 16); |
452
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 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
174 |
static uint32 grf_load_var(byte size, byte **buf) |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
175 |
{ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
176 |
switch (size) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
177 |
case 1: return grf_load_byte(buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
178 |
case 2: return grf_load_word(buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
179 |
case 4: return grf_load_dword(buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
180 |
default: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
181 |
NOT_REACHED(); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
182 |
return 0; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
183 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
184 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
185 |
|
1477 | 186 |
static GRFFile *GetFileByGRFID(uint32 grfid) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
187 |
{ |
1477 | 188 |
GRFFile *file; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
189 |
|
1477 | 190 |
for (file = _first_grffile; file != NULL; file = file->next) { |
191 |
if (file->grfid == grfid) break; |
|
192 |
} |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
193 |
return file; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
194 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
195 |
|
1477 | 196 |
static GRFFile *GetFileByFilename(const char *filename) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
197 |
{ |
1477 | 198 |
GRFFile *file; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
199 |
|
1477 | 200 |
for (file = _first_grffile; file != NULL; file = file->next) { |
201 |
if (strcmp(file->filename, filename) == 0) break; |
|
202 |
} |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
203 |
return file; |
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 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
206 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
207 |
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
|
208 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
209 |
#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
|
210 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
211 |
static void dewagonize(int condition, int engine) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
212 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
213 |
EngineInfo *ei = &_engine_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
214 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
215 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
216 |
if (condition != 0) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
217 |
ei->unk2 &= ~0x80; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
218 |
rvi->flags &= ~2; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
219 |
} else { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
220 |
ei->unk2 |= 0x80; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
221 |
rvi->flags |= 2; |
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 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
224 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
225 |
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
|
226 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
227 |
EngineInfo *ei = &_engine_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
228 |
RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
229 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
230 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
231 |
bool ret = false; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
232 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
233 |
switch (prop) { |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
234 |
case 0x05: /* Track type */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
235 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
236 |
uint8 tracktype = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
237 |
|
3026
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
238 |
switch (tracktype) { |
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
239 |
case 0: ei[i].railtype = RAILTYPE_RAIL; break; |
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
240 |
case 1: ei[i].railtype = RAILTYPE_MONO; break; |
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
241 |
case 2: ei[i].railtype = RAILTYPE_MAGLEV; break; |
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
242 |
default: |
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
243 |
grfmsg(GMS_WARN, "RailVehicleChangeInfo: Invalid track type %d specified, ignoring.", tracktype); |
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
244 |
break; |
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
245 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
246 |
} |
3026
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
247 |
break; |
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
248 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
249 |
case 0x08: /* AI passenger service */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
250 |
/* TODO */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
251 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
252 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
253 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
254 |
|
3488
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
255 |
case 0x09: /* Speed (1 unit is 1 kmh) */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
256 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
257 |
uint16 speed = grf_load_word(&buf); |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
258 |
if (speed == 0xFFFF) speed = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
259 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
260 |
rvi[i].max_speed = speed; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
261 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
262 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
263 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
264 |
case 0x0B: /* Power */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
265 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
266 |
uint16 power = grf_load_word(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
267 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
268 |
if (rvi[i].flags & RVI_MULTIHEAD) power /= 2; |
1894
c76c6bc57121
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
269 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
270 |
rvi[i].power = power; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
271 |
dewagonize(power, engine + i); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
272 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
273 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
274 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
275 |
case 0x0D: /* Running cost factor */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
276 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
277 |
uint8 runcostfact = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
278 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
279 |
if (rvi[i].flags & RVI_MULTIHEAD) runcostfact /= 2; |
2836
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
280 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
281 |
rvi[i].running_cost_base = runcostfact; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
282 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
283 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
284 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
285 |
case 0x0E: /* Running cost base */ |
452
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 |
uint32 base = grf_load_dword(&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 |
switch (base) { |
2840
9038b4ab8c9a
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2838
diff
changeset
|
290 |
case 0x4C30: rvi[i].running_cost_class = 0; break; |
9038b4ab8c9a
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2838
diff
changeset
|
291 |
case 0x4C36: rvi[i].running_cost_class = 1; break; |
9038b4ab8c9a
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2838
diff
changeset
|
292 |
case 0x4C3C: rvi[i].running_cost_class = 2; break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
293 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
294 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
295 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
296 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
297 |
case 0x12: /* Sprite ID */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
298 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
299 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
300 |
|
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
301 |
/* TTD sprite IDs point to a location in a 16bit array, but we use it |
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
302 |
* as an array index, so we need it to be half the original value. */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
303 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
304 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
305 |
rvi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
306 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
307 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
308 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
309 |
case 0x13: /* Dual-headed */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
310 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
311 |
uint8 dual = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
312 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
313 |
if (dual != 0) { |
2836
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
314 |
if (!(rvi[i].flags & RVI_MULTIHEAD)) { |
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
315 |
// adjust power and running cost if needed |
1894
c76c6bc57121
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
316 |
rvi[i].power /= 2; |
2836
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
317 |
rvi[i].running_cost_base /= 2; |
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
318 |
} |
1894
c76c6bc57121
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
319 |
rvi[i].flags |= RVI_MULTIHEAD; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
320 |
} else { |
2836
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
321 |
if (rvi[i].flags & RVI_MULTIHEAD) { |
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
322 |
// adjust power and running cost if needed |
1894
c76c6bc57121
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
323 |
rvi[i].power *= 2; |
2840
9038b4ab8c9a
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2838
diff
changeset
|
324 |
rvi[i].running_cost_base *= 2; |
2836
9c023d993651
(svn r3384) - NewGRF fix: running cost should be halved for dual head vehicles.
peter1138
parents:
2812
diff
changeset
|
325 |
} |
1894
c76c6bc57121
(svn r2400) - Fix: [newgrf] Load power for dual-headed engines correctly
hackykid
parents:
1891
diff
changeset
|
326 |
rvi[i].flags &= ~RVI_MULTIHEAD; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
327 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
328 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
329 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
330 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
331 |
case 0x14: /* Cargo capacity */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
332 |
FOR_EACH_OBJECT rvi[i].capacity = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
333 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
334 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
335 |
case 0x15: /* Cargo type */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
336 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
337 |
uint8 ctype = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
338 |
|
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
339 |
if (ctype < NUM_CARGO) { |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
340 |
rvi[i].cargo_type = ctype; |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
341 |
} else { |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
342 |
grfmsg(GMS_NOTICE, "RailVehicleChangeInfo: Invalid cargo type %d, ignoring.", ctype); |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
343 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
344 |
} |
3023
d651099f7b18
(svn r3603) - NewGRF: Support loading of AI rank data
peter1138
parents:
3006
diff
changeset
|
345 |
break; |
d651099f7b18
(svn r3603) - NewGRF: Support loading of AI rank data
peter1138
parents:
3006
diff
changeset
|
346 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
347 |
case 0x16: /* Weight */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
348 |
FOR_EACH_OBJECT SB(rvi[i].weight, 0, 8, grf_load_byte(&buf)); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
349 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
350 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
351 |
case 0x17: /* Cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
352 |
FOR_EACH_OBJECT rvi[i].base_cost = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
353 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
354 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
355 |
case 0x18: /* AI rank */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
356 |
FOR_EACH_OBJECT rvi[i].ai_rank = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
357 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
358 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
359 |
case 0x19: /* Engine traction type */ |
2838
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
360 |
/* What do the individual numbers mean? |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
361 |
* 0x00 .. 0x07: Steam |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
362 |
* 0x08 .. 0x27: Diesel |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
363 |
* 0x28 .. 0x31: Electric |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
364 |
* 0x32 .. 0x37: Monorail |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
365 |
* 0x38 .. 0x41: Maglev |
abfaee414ae7
(svn r3386) - NewGRF: Small comment update, and fix for possible issue with engine class not getting set.
peter1138
parents:
2836
diff
changeset
|
366 |
*/ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
367 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
368 |
uint8 traction = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
369 |
int engclass; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
370 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
371 |
if (traction <= 0x07) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
372 |
engclass = 0; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
373 |
} else if (traction <= 0x27) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
374 |
engclass = 1; |
3355
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3095
diff
changeset
|
375 |
} else if (traction <= 0x31) { |
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3095
diff
changeset
|
376 |
engclass = 2; |
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3095
diff
changeset
|
377 |
ei[i].railtype = RAILTYPE_ELECTRIC; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
378 |
} else if (traction <= 0x41) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
379 |
engclass = 2; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
380 |
} else { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
381 |
break; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
382 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
383 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
384 |
rvi[i].engclass = engclass; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
385 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
386 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
387 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
388 |
case 0x1A: /* Alter purchase list sort order */ |
2971
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
389 |
FOR_EACH_OBJECT { |
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
390 |
EngineID pos = grf_load_byte(&buf); |
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
391 |
|
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
392 |
if (pos < NUM_TRAIN_ENGINES) { |
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
393 |
AlterRailVehListOrder(engine + i, pos); |
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
394 |
} else { |
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
395 |
grfmsg(GMS_NOTICE, "RailVehicleChangeInfo: Invalid train engine ID %d, ignoring.", pos); |
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
396 |
} |
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
397 |
} |
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
398 |
break; |
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
399 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
400 |
case 0x1B: /* Powered wagons power bonus */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
401 |
FOR_EACH_OBJECT rvi[i].pow_wag_power = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
402 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
403 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
404 |
case 0x1D: /* Refit cargo */ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
405 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
406 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
407 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
408 |
case 0x1E: /* Callback */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
409 |
FOR_EACH_OBJECT rvi[i].callbackmask = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
410 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
411 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
412 |
case 0x21: /* Shorter vehicle */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
413 |
FOR_EACH_OBJECT rvi[i].shorten_factor = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
414 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
415 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
416 |
case 0x22: /* Visual effect */ |
1908
2fa391fed79a
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1895
diff
changeset
|
417 |
// see note in engine.h about rvi->visual_effect |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
418 |
FOR_EACH_OBJECT rvi[i].visual_effect = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
419 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
420 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
421 |
case 0x23: /* Powered wagons weight bonus */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
422 |
FOR_EACH_OBJECT rvi[i].pow_wag_weight = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
423 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
424 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
425 |
case 0x24: /* High byte of vehicle weight */ |
2542
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
426 |
FOR_EACH_OBJECT { |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
427 |
byte weight = grf_load_byte(&buf); |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
428 |
|
2545
aa71b3d576ce
(svn r3074) -NewGrf: Fix stupid typo in weight setting.
peter1138
parents:
2542
diff
changeset
|
429 |
if (weight > 4) { |
2542
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
430 |
grfmsg(GMS_NOTICE, "RailVehicleChangeInfo: Nonsensical weight of %d tons, ignoring.", weight << 8); |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
431 |
} else { |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
432 |
SB(rvi[i].weight, 8, 8, weight); |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
433 |
} |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
434 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
435 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
436 |
|
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
437 |
case 0x27: /* Miscellaneous flags */ |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
438 |
FOR_EACH_OBJECT ei[i].misc_flags = grf_load_byte(&buf); |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
439 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
440 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
441 |
case 0x28: /* Cargo classes allowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
442 |
FOR_EACH_OBJECT cargo_allowed[engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
443 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
444 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
445 |
case 0x29: /* Cargo classes disallowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
446 |
FOR_EACH_OBJECT cargo_disallowed[engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
447 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
448 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
449 |
/* TODO */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
450 |
/* Fall-through for unimplemented one byte long properties. */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
451 |
case 0x1C: /* Refit cost */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
452 |
case 0x1F: /* Tractive effort */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
453 |
case 0x20: /* Air drag */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
454 |
case 0x25: /* User-defined bit mask to set when checking veh. var. 42 */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
455 |
case 0x26: /* Retire vehicle early */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
456 |
/* TODO */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
457 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
458 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
459 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
460 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
461 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
462 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
463 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
464 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
465 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
466 |
return ret; |
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 |
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
|
470 |
{ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
471 |
EngineInfo *ei = &_engine_info[ROAD_ENGINES_INDEX + engine]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
472 |
RoadVehicleInfo *rvi = &_road_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
473 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
474 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
475 |
bool ret = false; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
476 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
477 |
switch (prop) { |
3488
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
478 |
case 0x08: /* Speed (1 unit is 0.5 kmh) */ |
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
479 |
FOR_EACH_OBJECT rvi[i].max_speed = grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
480 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
481 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
482 |
case 0x09: /* Running cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
483 |
FOR_EACH_OBJECT rvi[i].running_cost = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
484 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
485 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
486 |
case 0x0A: /* Running cost base */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
487 |
/* TODO: I have no idea. --pasky */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
488 |
FOR_EACH_OBJECT grf_load_dword(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
489 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
490 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
491 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
492 |
case 0x0E: /* Sprite ID */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
493 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
494 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
495 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
496 |
// cars have different custom id in the GRF file |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
497 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
498 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
499 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
500 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
501 |
rvi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
502 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
503 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
504 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
505 |
case 0x0F: /* Cargo capacity */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
506 |
FOR_EACH_OBJECT rvi[i].capacity = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
507 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
508 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
509 |
case 0x10: /* Cargo type */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
510 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
511 |
uint8 cargo = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
512 |
|
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
513 |
if (cargo < NUM_CARGO) { |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
514 |
rvi[i].cargo_type = cargo; |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
515 |
} else { |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
516 |
grfmsg(GMS_NOTICE, "RoadVehicleChangeInfo: Invalid cargo type %d, ignoring.", cargo); |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
517 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
518 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
519 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
520 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
521 |
case 0x11: /* Cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
522 |
FOR_EACH_OBJECT rvi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
523 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
524 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
525 |
case 0x12: /* SFX */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
526 |
FOR_EACH_OBJECT rvi[i].sfx = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
527 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
528 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
529 |
case 0x13: /* Power in 10hp */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
530 |
case 0x14: /* Weight in 1/4 tons */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
531 |
case 0x15: /* Speed in mph*0.8 */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
532 |
/* TODO: Support for road vehicles realistic power |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
533 |
* computations (called rvpower in TTDPatch) is just |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
534 |
* missing in OTTD yet. --pasky */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
535 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
536 |
ret = true; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
537 |
break; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
538 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
539 |
case 0x16: /* Cargos available for refitting */ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
540 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3006
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
541 |
break; |
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
542 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
543 |
case 0x17: /* Callback mask */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
544 |
FOR_EACH_OBJECT rvi[i].callbackmask = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
545 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
546 |
|
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
547 |
case 0x1C: /* Miscellaneous flags */ |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
548 |
FOR_EACH_OBJECT ei[i].misc_flags = grf_load_byte(&buf); |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
549 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
550 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
551 |
case 0x1D: /* Cargo classes allowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
552 |
FOR_EACH_OBJECT cargo_allowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
553 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
554 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
555 |
case 0x1E: /* Cargo classes disallowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
556 |
FOR_EACH_OBJECT cargo_disallowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
557 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
558 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
559 |
case 0x18: /* Tractive effort */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
560 |
case 0x19: /* Air drag */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
561 |
case 0x1A: /* Refit cost */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
562 |
case 0x1B: /* Retire vehicle early */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
563 |
/* TODO */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
564 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
565 |
ret = true; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
566 |
break; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
567 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
568 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
569 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
570 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
571 |
} |
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 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
574 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
575 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
576 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
577 |
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
|
578 |
{ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
579 |
EngineInfo *ei = &_engine_info[SHIP_ENGINES_INDEX + engine]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
580 |
ShipVehicleInfo *svi = &_ship_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
581 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
582 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
583 |
bool ret = false; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
584 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
585 |
//printf("e %x prop %x?\n", engine, prop); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
586 |
switch (prop) { |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
587 |
case 0x08: /* Sprite ID */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
588 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
589 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
590 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
591 |
// ships have different custom id in the GRF file |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
592 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
593 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
594 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
595 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
596 |
svi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
597 |
} |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
598 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
599 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
600 |
case 0x09: /* Refittable */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
601 |
FOR_EACH_OBJECT svi[i].refittable = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
602 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
603 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
604 |
case 0x0A: /* Cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
605 |
FOR_EACH_OBJECT svi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
606 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
607 |
|
3488
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
608 |
case 0x0B: /* Speed (1 unit is 0.5 kmh) */ |
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
609 |
FOR_EACH_OBJECT svi[i].max_speed = grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
610 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
611 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
612 |
case 0x0C: /* Cargo type */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
613 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
614 |
uint8 cargo = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
615 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
616 |
// XXX: Need to consult this with patchman yet. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
617 |
#if 0 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
618 |
// Documentation claims this is already the |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
619 |
// per-landscape cargo type id, but newships.grf |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
620 |
// assume otherwise. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
621 |
cargo = local_cargo_id_ctype[cargo]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
622 |
#endif |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
623 |
if (cargo < NUM_CARGO) { |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
624 |
svi[i].cargo_type = cargo; |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
625 |
} else { |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
626 |
grfmsg(GMS_NOTICE, "ShipVehicleChangeInfo: Invalid cargo type %d, ignoring.", cargo); |
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
627 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
628 |
} |
3006
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
629 |
break; |
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
630 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
631 |
case 0x0D: /* Cargo capacity */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
632 |
FOR_EACH_OBJECT svi[i].capacity = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
633 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
634 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
635 |
case 0x0F: /* Running cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
636 |
FOR_EACH_OBJECT svi[i].running_cost = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
637 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
638 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
639 |
case 0x10: /* SFX */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
640 |
FOR_EACH_OBJECT svi[i].sfx = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
641 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
642 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
643 |
case 0x11: /* Cargos available for refitting */ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
644 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
645 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
646 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
647 |
case 0x12: /* Callback mask */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
648 |
FOR_EACH_OBJECT svi[i].callbackmask = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
649 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
650 |
|
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
651 |
case 0x17: /* Miscellaneous flags */ |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
652 |
FOR_EACH_OBJECT ei[i].misc_flags = grf_load_byte(&buf); |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
653 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
654 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
655 |
case 0x18: /* Cargo classes allowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
656 |
FOR_EACH_OBJECT cargo_allowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
657 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
658 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
659 |
case 0x19: /* Cargo classes disallowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
660 |
FOR_EACH_OBJECT cargo_disallowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
661 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
662 |
|
1872
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
663 |
case 0x13: /* Refit cost */ |
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
664 |
case 0x14: /* Ocean speed fraction */ |
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
665 |
case 0x15: /* Canal speed fraction */ |
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
666 |
case 0x16: /* Retire vehicle early */ |
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
667 |
/* TODO */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
668 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
669 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
670 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
671 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
672 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
673 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
674 |
break; |
452
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 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
677 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
678 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
679 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
680 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
681 |
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
|
682 |
{ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
683 |
EngineInfo *ei = &_engine_info[AIRCRAFT_ENGINES_INDEX + engine]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
684 |
AircraftVehicleInfo *avi = &_aircraft_vehicle_info[engine]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
685 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
686 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
687 |
bool ret = false; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
688 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
689 |
//printf("e %x prop %x?\n", engine, prop); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
690 |
switch (prop) { |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
691 |
case 0x08: /* Sprite ID */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
692 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
693 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
694 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
695 |
// aircraft have different custom id in the GRF file |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
696 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
697 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
698 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
699 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
700 |
avi[i].image_index = spriteid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
701 |
} |
3006
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
702 |
break; |
6da38dbee2a7
(svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents:
2971
diff
changeset
|
703 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
704 |
case 0x09: /* Helicopter */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
705 |
FOR_EACH_OBJECT SB(avi[i].subtype, 0, 1, (grf_load_byte(&buf) != 0 ? 1 : 0)); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
706 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
707 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
708 |
case 0x0A: /* Large */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
709 |
FOR_EACH_OBJECT SB(avi[i].subtype, 1, 1, (grf_load_byte(&buf) != 0 ? 1 : 0)); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
710 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
711 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
712 |
case 0x0B: /* Cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
713 |
FOR_EACH_OBJECT avi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
714 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
715 |
|
3488
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
716 |
case 0x0C: /* Speed (1 unit is 8 mph) */ |
7bf7e30fb865
(svn r4339) - Comment Change: NewGRF, update comments for units of speed
peter1138
parents:
3355
diff
changeset
|
717 |
FOR_EACH_OBJECT avi[i].max_speed = grf_load_byte(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
718 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
719 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
720 |
case 0x0D: /* Acceleration */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
721 |
FOR_EACH_OBJECT avi[i].acceleration = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
722 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
723 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
724 |
case 0x0E: /* Running cost factor */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
725 |
FOR_EACH_OBJECT avi[i].running_cost = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
726 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
727 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
728 |
case 0x0F: /* Passenger capacity */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
729 |
FOR_EACH_OBJECT avi[i].passenger_capacity = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
730 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
731 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
732 |
case 0x11: /* Mail capacity */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
733 |
FOR_EACH_OBJECT avi[i].mail_capacity = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
734 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
735 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
736 |
case 0x12: /* SFX */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
737 |
FOR_EACH_OBJECT avi[i].sfx = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
738 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
739 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
740 |
case 0x13: /* Cargos available for refitting */ |
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
741 |
FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
742 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
743 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
744 |
case 0x14: /* Callback mask */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
745 |
FOR_EACH_OBJECT avi[i].callbackmask = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
746 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
747 |
|
3095
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
748 |
case 0x17: /* Miscellaneous flags */ |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
749 |
FOR_EACH_OBJECT ei[i].misc_flags = grf_load_byte(&buf); |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
750 |
break; |
19084629d27a
(svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents:
3089
diff
changeset
|
751 |
|
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
752 |
case 0x18: /* Cargo classes allowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
753 |
FOR_EACH_OBJECT cargo_allowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
754 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
755 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
756 |
case 0x19: /* Cargo classes disallowed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
757 |
FOR_EACH_OBJECT cargo_disallowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
758 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
759 |
|
1872
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
760 |
case 0x15: /* Refit cost */ |
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
761 |
case 0x16: /* Retire vehicle early */ |
4041ff29ee8e
(svn r2378) - Fix: [newgrf] Further property stubs, help prevents subsequent incorrect reading of newgrf data
orudge
parents:
1871
diff
changeset
|
762 |
/* TODO */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
763 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
764 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
765 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
766 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
767 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
768 |
ret = true; |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
769 |
break; |
452
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 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
772 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
773 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
774 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
775 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
776 |
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
|
777 |
{ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
778 |
StationSpec **statspec; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
779 |
byte *buf = *bufp; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
780 |
int i; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
781 |
bool ret = false; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
782 |
|
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
783 |
if (stid + numinfo > MAX_STATIONS) { |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
784 |
grfmsg(GMS_WARN, "StationChangeInfo: Station %u is invalid, max %u, ignoring.", stid + numinfo, MAX_STATIONS); |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
785 |
return false; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
786 |
} |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
787 |
|
3501
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
788 |
/* Allocate station specs if necessary */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
789 |
if (_cur_grffile->stations == NULL) _cur_grffile->stations = calloc(MAX_STATIONS, sizeof(*_cur_grffile->stations)); |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
790 |
|
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
791 |
statspec = &_cur_grffile->stations[stid]; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
792 |
|
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
793 |
if (prop != 0x08) { |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
794 |
/* Check that all stations we are modifying are defined. */ |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
795 |
FOR_EACH_OBJECT { |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
796 |
if (statspec[i] == NULL) { |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
797 |
grfmsg(GMS_NOTICE, "StationChangeInfo: Attempt to modify undefined station %u, ignoring.", stid + i); |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
798 |
return false; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
799 |
} |
3501
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
800 |
} |
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
801 |
} |
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
802 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
803 |
switch (prop) { |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
804 |
case 0x08: /* Class ID */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
805 |
FOR_EACH_OBJECT { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
806 |
uint32 classid; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
807 |
|
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
808 |
/* Property 0x08 is special; it is where the station is allocated */ |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
809 |
if (statspec[i] == NULL) statspec[i] = calloc(1, sizeof(*statspec[i])); |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
810 |
|
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
811 |
/* Swap classid because we read it in BE meaning WAYP or DFLT */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
812 |
classid = grf_load_dword(&buf); |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
813 |
statspec[i]->sclass = AllocateStationClass(BSWAP32(classid)); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
814 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
815 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
816 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
817 |
case 0x09: /* Define sprite layout */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
818 |
FOR_EACH_OBJECT { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
819 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
3570
707f93772b0a
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
820 |
uint t; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
821 |
|
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
822 |
statspec->tiles = grf_load_extended(&buf); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
823 |
statspec->renderdata = calloc(statspec->tiles, sizeof(*statspec->renderdata)); |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
824 |
statspec->copied_renderdata = false; |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
825 |
|
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
826 |
for (t = 0; t < statspec->tiles; t++) { |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
827 |
DrawTileSprites *dts = &statspec->renderdata[t]; |
3570
707f93772b0a
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
828 |
uint seq_count = 0; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
829 |
|
3737
1e4df4eb9298
(svn r4719) - Newstations: instead of drawing nothing, fall back to the default sprite layout if a station layout specifies so.
peter1138
parents:
3736
diff
changeset
|
830 |
dts->seq = NULL; |
3775
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
831 |
dts->ground_sprite = grf_load_dword(&buf); |
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
832 |
if (dts->ground_sprite == 0) continue; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
833 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
834 |
while (buf < *bufp + len) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
835 |
DrawTileSeqStruct *dtss; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
836 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
837 |
// no relative bounding box support |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
838 |
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
|
839 |
dtss = (DrawTileSeqStruct*) &dts->seq[seq_count - 1]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
840 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
841 |
dtss->delta_x = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
842 |
if ((byte) dtss->delta_x == 0x80) break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
843 |
dtss->delta_y = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
844 |
dtss->delta_z = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
845 |
dtss->width = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
846 |
dtss->height = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
847 |
dtss->unk = grf_load_byte(&buf); |
3771
9bce8ac706b2
(svn r4763) - Newstations: revert r4762, instead map bit the palette modifier from bit 14 to bit 31 on GRF load.
peter1138
parents:
3768
diff
changeset
|
848 |
dtss->image = grf_load_dword(&buf); |
9bce8ac706b2
(svn r4763) - Newstations: revert r4762, instead map bit the palette modifier from bit 14 to bit 31 on GRF load.
peter1138
parents:
3768
diff
changeset
|
849 |
|
3775
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
850 |
/* Remap flags as ours collide */ |
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
851 |
if (HASBIT(dtss->image, 31)) { |
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
852 |
CLRBIT(dtss->image, 31); |
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
853 |
SETBIT(dtss->image, 30); |
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
854 |
} |
3771
9bce8ac706b2
(svn r4763) - Newstations: revert r4762, instead map bit the palette modifier from bit 14 to bit 31 on GRF load.
peter1138
parents:
3768
diff
changeset
|
855 |
if (HASBIT(dtss->image, 14)) { |
9bce8ac706b2
(svn r4763) - Newstations: revert r4762, instead map bit the palette modifier from bit 14 to bit 31 on GRF load.
peter1138
parents:
3768
diff
changeset
|
856 |
CLRBIT(dtss->image, 14); |
9bce8ac706b2
(svn r4763) - Newstations: revert r4762, instead map bit the palette modifier from bit 14 to bit 31 on GRF load.
peter1138
parents:
3768
diff
changeset
|
857 |
SETBIT(dtss->image, 31); |
9bce8ac706b2
(svn r4763) - Newstations: revert r4762, instead map bit the palette modifier from bit 14 to bit 31 on GRF load.
peter1138
parents:
3768
diff
changeset
|
858 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
859 |
} |
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 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
862 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
863 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
864 |
case 0x0A: /* Copy sprite layout */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
865 |
FOR_EACH_OBJECT { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
866 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
867 |
byte srcid = grf_load_byte(&buf); |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
868 |
const StationSpec *srcstatspec = _cur_grffile->stations[srcid]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
869 |
|
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
870 |
statspec->tiles = srcstatspec->tiles; |
3738
4694e7a0e2e4
(svn r4720) - Newstations: instead of literally copying sprite layout data, just copy the pointer to the existing data.
peter1138
parents:
3737
diff
changeset
|
871 |
statspec->renderdata = srcstatspec->renderdata; |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
872 |
statspec->copied_renderdata = true; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
873 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
874 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
875 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
876 |
case 0x0B: /* Callback mask */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
877 |
FOR_EACH_OBJECT statspec[i]->callbackmask = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
878 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
879 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
880 |
case 0x0C: /* Disallowed number of platforms */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
881 |
FOR_EACH_OBJECT statspec[i]->disallowed_platforms = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
882 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
883 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
884 |
case 0x0D: /* Disallowed platform lengths */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
885 |
FOR_EACH_OBJECT statspec[i]->disallowed_lengths = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
886 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
887 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
888 |
case 0x0E: /* Define custom layout */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
889 |
FOR_EACH_OBJECT { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
890 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
891 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
892 |
while (buf < *bufp + len) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
893 |
byte length = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
894 |
byte number = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
895 |
StationLayout layout; |
3570
707f93772b0a
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
896 |
uint l, p; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
897 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
898 |
if (length == 0 || number == 0) break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
899 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
900 |
//debug("l %d > %d ?", length, stat->lengths); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
901 |
if (length > statspec->lengths) { |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
902 |
statspec->platforms = realloc(statspec->platforms, length); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
903 |
memset(statspec->platforms + statspec->lengths, 0, length - statspec->lengths); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
904 |
|
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
905 |
statspec->layouts = realloc(statspec->layouts, length * sizeof(*statspec->layouts)); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
906 |
memset(statspec->layouts + statspec->lengths, 0, |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
907 |
(length - statspec->lengths) * sizeof(*statspec->layouts)); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
908 |
|
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
909 |
statspec->lengths = length; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
910 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
911 |
l = length - 1; // index is zero-based |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
912 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
913 |
//debug("p %d > %d ?", number, stat->platforms[l]); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
914 |
if (number > statspec->platforms[l]) { |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
915 |
statspec->layouts[l] = realloc(statspec->layouts[l], |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
916 |
number * sizeof(**statspec->layouts)); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
917 |
// We expect NULL being 0 here, but C99 guarantees that. |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
918 |
memset(statspec->layouts[l] + statspec->platforms[l], 0, |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
919 |
(number - statspec->platforms[l]) * sizeof(**statspec->layouts)); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
920 |
|
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
921 |
statspec->platforms[l] = number; |
452
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 |
|
542 | 924 |
p = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
925 |
layout = malloc(length * number); |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
926 |
for (l = 0; l < length; l++) { |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
927 |
for (p = 0; p < number; p++) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
928 |
layout[l * number + p] = grf_load_byte(&buf); |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
929 |
} |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
930 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
931 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
932 |
l--; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
933 |
p--; |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
934 |
free(statspec->layouts[l][p]); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
935 |
statspec->layouts[l][p] = layout; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
936 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
937 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
938 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
939 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
940 |
case 0x0F: /* Copy custom layout */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
941 |
/* TODO */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
942 |
FOR_EACH_OBJECT { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
943 |
grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
944 |
} |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
945 |
ret = true; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
946 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
947 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
948 |
case 0x10: /* Little/lots cargo threshold */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
949 |
FOR_EACH_OBJECT statspec[i]->cargo_threshold = grf_load_word(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
950 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
951 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
952 |
case 0x11: /* Pylon placement */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
953 |
FOR_EACH_OBJECT statspec[i]->pylons = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
954 |
break; |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
955 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
956 |
case 0x12: /* Cargo types for random triggers */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
957 |
FOR_EACH_OBJECT statspec[i]->cargo_triggers = grf_load_dword(&buf); |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
958 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
959 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
960 |
case 0x13: /* General flags */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
961 |
FOR_EACH_OBJECT statspec[i]->flags = grf_load_byte(&buf); |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
962 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
963 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
964 |
case 0x14: /* Overhead wire placement */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
965 |
FOR_EACH_OBJECT statspec[i]->wires = grf_load_byte(&buf); |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
966 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
967 |
|
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
968 |
case 0x15: /* Blocked tiles */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
969 |
FOR_EACH_OBJECT statspec[i]->blocked = grf_load_byte(&buf); |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
970 |
break; |
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
971 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
972 |
default: |
3505
091f0285df7d
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
973 |
ret = true; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
974 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
975 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
976 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
977 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
978 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
979 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
980 |
|
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
981 |
static bool BridgeChangeInfo(uint brid, int numinfo, int prop, byte **bufp, int len) |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
982 |
{ |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
983 |
byte *buf = *bufp; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
984 |
int i; |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
985 |
bool ret = false; |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
986 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
987 |
switch (prop) { |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
988 |
case 0x08: /* Year of availability */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
989 |
FOR_EACH_OBJECT _bridge[brid + i].avail_year = grf_load_byte(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
990 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
991 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
992 |
case 0x09: /* Minimum length */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
993 |
FOR_EACH_OBJECT _bridge[brid + i].min_length = grf_load_byte(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
994 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
995 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
996 |
case 0x0A: /* Maximum length */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
997 |
FOR_EACH_OBJECT _bridge[brid + i].max_length = grf_load_byte(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
998 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
999 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1000 |
case 0x0B: /* Cost factor */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1001 |
FOR_EACH_OBJECT _bridge[brid + i].price = grf_load_byte(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1002 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1003 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1004 |
case 0x0C: /* Maximum speed */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1005 |
FOR_EACH_OBJECT _bridge[brid + i].speed = grf_load_word(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1006 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1007 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1008 |
case 0x0D: /* Bridge sprite tables */ |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1009 |
FOR_EACH_OBJECT { |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1010 |
Bridge *bridge = &_bridge[brid + i]; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1011 |
byte tableid = grf_load_byte(&buf); |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1012 |
byte numtables = grf_load_byte(&buf); |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1013 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1014 |
if (bridge->sprite_table == NULL) { |
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1015 |
/* Allocate memory for sprite table pointers and zero out */ |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1016 |
bridge->sprite_table = calloc(7, sizeof(*bridge->sprite_table)); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1017 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1018 |
|
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1019 |
for (; numtables-- != 0; tableid++) { |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1020 |
byte sprite; |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1021 |
|
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1022 |
if (tableid >= 7) { // skip invalid data |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1023 |
grfmsg(GMS_WARN, "BridgeChangeInfo: Table %d >= 7, skipping.", tableid); |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1024 |
for (sprite = 0; sprite < 32; sprite++) grf_load_dword(&buf); |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1025 |
continue; |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1026 |
} |
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1027 |
|
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1028 |
if (bridge->sprite_table[tableid] == NULL) { |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1029 |
bridge->sprite_table[tableid] = malloc(32 * sizeof(**bridge->sprite_table)); |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1030 |
} |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1031 |
|
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1032 |
for (sprite = 0; sprite < 32; sprite++) |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1033 |
bridge->sprite_table[tableid][sprite] = grf_load_dword(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1034 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1035 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1036 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1037 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1038 |
case 0x0E: /* Flags; bit 0 - disable far pillars */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1039 |
FOR_EACH_OBJECT _bridge[brid + i].flags = grf_load_byte(&buf); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1040 |
break; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1041 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1042 |
default: |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1043 |
ret = true; |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1044 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1045 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1046 |
*bufp = buf; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1047 |
return ret; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1048 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1049 |
|
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1050 |
static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, int len) |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1051 |
{ |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1052 |
byte *buf = *bufp; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1053 |
int i; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1054 |
bool ret = false; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1055 |
|
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1056 |
switch (prop) { |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1057 |
case 0x08: /* Cost base factor */ |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1058 |
FOR_EACH_OBJECT { |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1059 |
byte factor = grf_load_byte(&buf); |
2508
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1060 |
uint price = gvid + i; |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1061 |
|
2508
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1062 |
if (price < NUM_PRICES) { |
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1063 |
SetPriceBaseMultiplier(price, factor); |
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1064 |
} else { |
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1065 |
grfmsg(GMS_WARN, "GlobalVarChangeInfo: Price %d out of range, ignoring.", price); |
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1066 |
} |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1067 |
} |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1068 |
break; |
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1069 |
|
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1070 |
default: |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1071 |
ret = true; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1072 |
} |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1073 |
|
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1074 |
*bufp = buf; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1075 |
return ret; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1076 |
} |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1077 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1078 |
/* Action 0x00 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1079 |
static void VehicleChangeInfo(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1080 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1081 |
byte *bufend = buf + len; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1082 |
int i; |
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 |
/* <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
|
1085 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1086 |
* 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
|
1087 |
* 4 for defining new train station sets |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1088 |
* 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
|
1089 |
* 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
|
1090 |
* 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
|
1091 |
* greater than one, this one and the following |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1092 |
* vehicles/stations will be changed |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1093 |
* 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
|
1094 |
* 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
|
1095 |
/* TODO: Bridges, town houses. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1096 |
|
2438
f0bf4adbd620
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
1097 |
static const VCI_Handler handler[] = { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1098 |
/* GSF_TRAIN */ RailVehicleChangeInfo, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1099 |
/* GSF_ROAD */ RoadVehicleChangeInfo, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1100 |
/* GSF_SHIP */ ShipVehicleChangeInfo, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1101 |
/* GSF_AIRCRAFT */ AircraftVehicleChangeInfo, |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1102 |
/* GSF_STATION */ StationChangeInfo, |
2438
f0bf4adbd620
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
1103 |
/* GSF_CANAL */ NULL, |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1104 |
/* GSF_BRIDGE */ BridgeChangeInfo, |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1105 |
/* GSF_TOWNHOUSE */NULL, |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1106 |
/* GSF_GLOBALVAR */GlobalVarChangeInfo, |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1107 |
}; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1108 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1109 |
uint8 feature; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1110 |
uint8 numprops; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1111 |
uint8 numinfo; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1112 |
byte engine; |
542 | 1113 |
EngineInfo *ei = NULL; |
452
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 |
if (len == 1) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1116 |
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
|
1117 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1118 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1119 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1120 |
check_length(len, 6, "VehicleChangeInfo"); |
3714
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1121 |
buf++; |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1122 |
feature = grf_load_byte(&buf); |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1123 |
numprops = grf_load_byte(&buf); |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1124 |
numinfo = grf_load_byte(&buf); |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1125 |
engine = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1126 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1127 |
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
|
1128 |
feature, numprops, engine, numinfo); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1129 |
|
2440
d0c69700c72e
(svn r2966) Fix: newgrf: Replace special case with a check for the existence of a handler in VehicleChangeInfo.
peter1138
parents:
2439
diff
changeset
|
1130 |
if (feature >= lengthof(handler) || handler[feature] == NULL) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1131 |
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
|
1132 |
return; |
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 |
|
2439
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1135 |
if (feature <= GSF_AIRCRAFT) { |
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1136 |
if (engine + numinfo > _vehcounts[feature]) { |
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1137 |
grfmsg(GMS_ERROR, "VehicleChangeInfo: Last engine ID %d out of bounds (max %d), skipping.", engine + numinfo, _vehcounts[feature]); |
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1138 |
return; |
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1139 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1140 |
ei = &_engine_info[engine + _vehshifts[feature]]; |
2439
b4962381b5b5
(svn r2965) Fix: newgrf: Add bounds checking to VehicleChangeInfo for vehicles and change
peter1138
parents:
2438
diff
changeset
|
1141 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1142 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1143 |
while (numprops-- && buf < bufend) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1144 |
uint8 prop = grf_load_byte(&buf); |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1145 |
bool ignoring = false; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1146 |
|
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1147 |
switch (feature) { |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1148 |
case GSF_TRAIN: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1149 |
case GSF_ROAD: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1150 |
case GSF_SHIP: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1151 |
case GSF_AIRCRAFT: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1152 |
/* Common properties for vehicles */ |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1153 |
switch (prop) { |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1154 |
case 0x00: /* Introduction date */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1155 |
FOR_EACH_OBJECT ei[i].base_intro = grf_load_word(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1156 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1157 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1158 |
case 0x02: /* Decay speed */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1159 |
FOR_EACH_OBJECT SB(ei[i].unk2, 0, 7, grf_load_byte(&buf) & 0x7F); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1160 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1161 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1162 |
case 0x03: /* Vehicle life */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1163 |
FOR_EACH_OBJECT ei[i].lifelength = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1164 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1165 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1166 |
case 0x04: /* Model life */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1167 |
FOR_EACH_OBJECT ei[i].base_life = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1168 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1169 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1170 |
case 0x06: /* Climates available */ |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1171 |
FOR_EACH_OBJECT ei[i].climates = grf_load_byte(&buf); |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1172 |
break; |
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1173 |
|
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1174 |
case 0x07: /* Loading speed */ |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1175 |
/* TODO */ |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1176 |
/* Hyronymus explained me what does |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1177 |
* this mean and insists on having a |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1178 |
* credit ;-). --pasky */ |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1179 |
/* TODO: This needs to be supported by |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1180 |
* LoadUnloadVehicle() first. */ |
3089
b073c15f794c
(svn r3678) - NewGRF Codechange: remove redundant braces and temporary variables.
peter1138
parents:
3033
diff
changeset
|
1181 |
FOR_EACH_OBJECT grf_load_byte(&buf); |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1182 |
ignoring = true; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1183 |
break; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1184 |
|
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1185 |
default: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1186 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1187 |
ignoring = true; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1188 |
break; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1189 |
} |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1190 |
break; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1191 |
|
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1192 |
default: |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1193 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1194 |
ignoring = true; |
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1195 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1196 |
} |
2421
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1197 |
|
8bc8ff3a5eb5
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
1198 |
if (ignoring) |
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1199 |
grfmsg(GMS_NOTICE, "VehicleChangeInfo: Ignoring property 0x%02X (not implemented).", prop); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1200 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1201 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1202 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1203 |
#undef FOR_EACH_OBJECT |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1204 |
|
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1205 |
/** |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1206 |
* Creates a spritegroup representing a callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1207 |
* @param value The value that was used to represent this callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1208 |
* @return A spritegroup representing that callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1209 |
*/ |
2752 | 1210 |
static SpriteGroup* NewCallBackResultSpriteGroup(uint16 value) |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1211 |
{ |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
1212 |
SpriteGroup *group = AllocateSpriteGroup(); |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1213 |
|
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1214 |
group->type = SGT_CALLBACK; |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1215 |
|
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1216 |
// Old style callback results have the highest byte 0xFF so signify it is a callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1217 |
// New style ones only have the highest bit set (allows 15-bit results, instead of just 8) |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1218 |
if ((value >> 8) == 0xFF) { |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1219 |
value &= ~0xFF00; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1220 |
} else { |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1221 |
value &= ~0x8000; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1222 |
} |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1223 |
|
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1224 |
group->g.callback.result = value; |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1225 |
|
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1226 |
return group; |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
1227 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1228 |
|
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1229 |
/** |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1230 |
* Creates a spritegroup representing a sprite number result. |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1231 |
* @param value The sprite number. |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1232 |
* @param sprites The number of sprites per set. |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1233 |
* @return A spritegroup representing the sprite number result. |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1234 |
*/ |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1235 |
static SpriteGroup* NewResultSpriteGroup(SpriteID sprite, byte num_sprites) |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1236 |
{ |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
1237 |
SpriteGroup *group = AllocateSpriteGroup(); |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1238 |
group->type = SGT_RESULT; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1239 |
group->g.result.sprite = sprite; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1240 |
group->g.result.num_sprites = num_sprites; |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1241 |
return group; |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1242 |
} |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1243 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1244 |
/* Action 0x01 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1245 |
static void NewSpriteSet(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1246 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1247 |
/* <01> <feature> <num-sets> <num-ent> |
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 |
* B feature feature to define sprites for |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1250 |
* 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
|
1251 |
* B num-sets number of sprite sets |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1252 |
* E num-ent how many entries per sprite set |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1253 |
* For vehicles, this is the number of different |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1254 |
* vehicle directions in each sprite set |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1255 |
* 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
|
1256 |
* In that case, use num-dirs=4. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1257 |
* 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
|
1258 |
* different sprites that make up a station */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1259 |
/* TODO: No stations support. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1260 |
uint8 feature; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1261 |
uint num_sets; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1262 |
uint num_ents; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1263 |
uint i; |
452
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 |
check_length(len, 4, "NewSpriteSet"); |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1266 |
buf++; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1267 |
feature = grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1268 |
num_sets = grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1269 |
num_ents = grf_load_extended(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1270 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1271 |
_cur_grffile->spriteset_start = _cur_spriteid; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1272 |
_cur_grffile->spriteset_feature = feature; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1273 |
_cur_grffile->spriteset_numsets = num_sets; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1274 |
_cur_grffile->spriteset_numents = num_ents; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1275 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1276 |
DEBUG(grf, 7) ( |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1277 |
"New sprite set at %d of type %d, " |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1278 |
"consisting of %d sets with %d views each (total %d)", |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1279 |
_cur_spriteid, feature, num_sets, num_ents, num_sets * num_ents |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1280 |
); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1281 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1282 |
for (i = 0; i < num_sets * num_ents; i++) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1283 |
LoadNextSprite(_cur_spriteid++, _file_index); |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
1284 |
_nfo_line++; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
1285 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1286 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1287 |
|
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1288 |
/* Helper function to either create a callback or link to a previously |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1289 |
* defined spritegroup. */ |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1290 |
static SpriteGroup* GetGroupFromGroupID(byte setid, byte type, uint16 groupid) |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1291 |
{ |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1292 |
if (HASBIT(groupid, 15)) return NewCallBackResultSpriteGroup(groupid); |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1293 |
|
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1294 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1295 |
grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty.", setid, type, groupid); |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1296 |
return NULL; |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1297 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1298 |
|
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1299 |
return _cur_grffile->spritegroups[groupid]; |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1300 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1301 |
|
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1302 |
/* Helper function to either create a callback or a result sprite group. */ |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1303 |
static SpriteGroup* CreateGroupFromGroupID(byte setid, byte type, uint16 spriteid, uint16 num_sprites) |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1304 |
{ |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1305 |
if (HASBIT(spriteid, 15)) return NewCallBackResultSpriteGroup(spriteid); |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1306 |
|
3667
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1307 |
if (spriteid >= _cur_grffile->spriteset_numsets) { |
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1308 |
grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Sprite set %u invalid, max %u", setid, type, spriteid, _cur_grffile->spriteset_numsets); |
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1309 |
return NULL; |
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1310 |
} |
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
1311 |
|
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1312 |
/* Check if the sprite is within range. This can fail if the Action 0x01 |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1313 |
* is skipped, as TTDPatch mandates that Action 0x02s must be processed. |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1314 |
* We don't have that rule, but must live by the Patch... */ |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1315 |
if (_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites > _cur_spriteid) { |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1316 |
grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Real Sprite IDs 0x%04X - 0x%04X do not (all) exist (max 0x%04X), leaving empty.", |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1317 |
setid, type, |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1318 |
_cur_grffile->spriteset_start + spriteid * num_sprites, |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1319 |
_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites - 1, _cur_spriteid - 1); |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1320 |
return NULL; |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1321 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1322 |
|
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1323 |
return NewResultSpriteGroup(_cur_grffile->spriteset_start + spriteid * num_sprites, num_sprites); |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1324 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
1325 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1326 |
/* Action 0x02 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1327 |
static void NewSpriteGroup(byte *buf, int len) |
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 |
/* <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
|
1330 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1331 |
* B feature see action 1 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1332 |
* B set-id ID of this particular definition |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1333 |
* B type/num-entries |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1334 |
* 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
|
1335 |
* list definition, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1336 |
* 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
|
1337 |
* meaning depends on the feature |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1338 |
* 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
|
1339 |
uint8 feature; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1340 |
uint8 setid; |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1341 |
uint8 type; |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1342 |
SpriteGroup *group = NULL; |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1343 |
byte *bufend = buf + len; |
452
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 |
check_length(len, 5, "NewSpriteGroup"); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1346 |
buf++; |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1347 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1348 |
feature = grf_load_byte(&buf); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1349 |
setid = grf_load_byte(&buf); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1350 |
type = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1351 |
|
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
1352 |
if (setid >= _cur_grffile->spritegroups_count) { |
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1353 |
// Allocate memory for new sprite group references. |
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1354 |
_cur_grffile->spritegroups = realloc(_cur_grffile->spritegroups, (setid + 1) * sizeof(*_cur_grffile->spritegroups)); |
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1355 |
// Initialise new space to NULL |
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1356 |
for (; _cur_grffile->spritegroups_count < (setid + 1); _cur_grffile->spritegroups_count++) |
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
1357 |
_cur_grffile->spritegroups[_cur_grffile->spritegroups_count] = NULL; |
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
1358 |
} |
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
1359 |
|
3634
6123c07f1bc1
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1360 |
if (feature != _cur_grffile->spriteset_feature) { |
6123c07f1bc1
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1361 |
grfmsg(GMS_WARN, "NewSpriteGroup: sprite set feature 0x%02X does not match action feature 0x%02X, skipping.", |
6123c07f1bc1
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1362 |
_cur_grffile->spriteset_feature, feature); |
6123c07f1bc1
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1363 |
/* Clear this group's reference */ |
6123c07f1bc1
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1364 |
_cur_grffile->spritegroups[setid] = NULL; |
6123c07f1bc1
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1365 |
return; |
6123c07f1bc1
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1366 |
} |
6123c07f1bc1
(svn r4539) - NewGRF: always check that the action 0x2 feature matches the action 0x1, not just on 'normal' sprite groups.
peter1138
parents:
3633
diff
changeset
|
1367 |
|
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1368 |
switch (type) { |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1369 |
/* Deterministic Sprite Group */ |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1370 |
case 0x81: // Self scope, byte |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1371 |
case 0x82: // Parent scope, byte |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1372 |
case 0x85: // Self scope, word |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1373 |
case 0x86: // Parent scope, word |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1374 |
case 0x89: // Self scope, dword |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1375 |
case 0x8A: // Parent scope, dword |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1376 |
{ |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1377 |
byte varadjust; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1378 |
byte varsize; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1379 |
uint i; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1380 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1381 |
/* Check we can load the var size parameter */ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1382 |
check_length(bufend - buf, 1, "NewSpriteGroup (Deterministic) (1)"); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1383 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1384 |
group = AllocateSpriteGroup(); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1385 |
group->type = SGT_DETERMINISTIC; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1386 |
group->g.determ.var_scope = HASBIT(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1387 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1388 |
switch (GB(type, 2, 2)) { |
3672
f626ea3c9994
(svn r4588) - NewGRF: silence a false compiler warning
peter1138
parents:
3668
diff
changeset
|
1389 |
default: NOT_REACHED(); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1390 |
case 0: group->g.determ.size = DSG_SIZE_BYTE; varsize = 1; break; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1391 |
case 1: group->g.determ.size = DSG_SIZE_WORD; varsize = 2; break; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1392 |
case 2: group->g.determ.size = DSG_SIZE_DWORD; varsize = 4; break; |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1393 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1394 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1395 |
check_length(bufend - buf, 2 + (varsize * 3) + 2, "NewSpriteGroup (Deterministic) (2)"); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1396 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1397 |
/* Loop through the var adjusts. Unfortunately we don't know how many we have |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1398 |
* from the outset, so we shall have to keep reallocing. */ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1399 |
do { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1400 |
DeterministicSpriteGroupAdjust *adjust; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1401 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1402 |
if (group->g.determ.num_adjusts > 0) { |
3694
c53e605f23ce
(svn r4631) - NewGRF: fix incorrect length check
peter1138
parents:
3676
diff
changeset
|
1403 |
check_length(bufend - buf, 2 + varsize + 3, "NewSpriteGroup (Deterministic) (3)"); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1404 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1405 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1406 |
group->g.determ.num_adjusts++; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1407 |
group->g.determ.adjusts = realloc(group->g.determ.adjusts, group->g.determ.num_adjusts * sizeof(*group->g.determ.adjusts)); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1408 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1409 |
adjust = &group->g.determ.adjusts[group->g.determ.num_adjusts - 1]; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1410 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1411 |
/* The first var adjust doesn't have an operation specified, so we set it to add. */ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1412 |
adjust->operation = group->g.determ.num_adjusts == 1 ? DSGA_OP_ADD : grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1413 |
adjust->variable = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1414 |
adjust->parameter = IS_BYTE_INSIDE(adjust->variable, 0x60, 0x80) ? grf_load_byte(&buf) : 0; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1415 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1416 |
varadjust = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1417 |
adjust->shift_num = GB(varadjust, 0, 5); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1418 |
adjust->type = GB(varadjust, 6, 2); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1419 |
adjust->and_mask = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1420 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1421 |
if (adjust->type != DSGA_TYPE_NONE) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1422 |
adjust->add_val = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1423 |
adjust->divmod_val = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1424 |
} else { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1425 |
adjust->add_val = 0; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1426 |
adjust->divmod_val = 0; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1427 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1428 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1429 |
/* Continue reading var adjusts while bit 5 is set. */ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1430 |
} while (HASBIT(varadjust, 5)); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1431 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1432 |
group->g.determ.num_ranges = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1433 |
group->g.determ.ranges = calloc(group->g.determ.num_ranges, sizeof(*group->g.determ.ranges)); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1434 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1435 |
check_length(bufend - buf, 2 + (2 + 2 * varsize) * group->g.determ.num_ranges, "NewSpriteGroup (Deterministic)"); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1436 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1437 |
for (i = 0; i < group->g.determ.num_ranges; i++) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1438 |
group->g.determ.ranges[i].group = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1439 |
group->g.determ.ranges[i].low = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1440 |
group->g.determ.ranges[i].high = grf_load_var(varsize, &buf); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1441 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1442 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1443 |
group->g.determ.default_group = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1444 |
break; |
452
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 |
|
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1447 |
/* Randomized Sprite Group */ |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1448 |
case 0x80: // Self scope |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1449 |
case 0x83: // Parent scope |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1450 |
{ |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1451 |
byte triggers; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1452 |
uint i; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1453 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1454 |
check_length(bufend - buf, 7, "NewSpriteGroup (Randomized) (1)"); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1455 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1456 |
group = AllocateSpriteGroup(); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1457 |
group->type = SGT_RANDOMIZED; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1458 |
group->g.random.var_scope = HASBIT(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1459 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1460 |
triggers = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1461 |
group->g.random.triggers = GB(triggers, 0, 7); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1462 |
group->g.random.cmp_mode = HASBIT(triggers, 7) ? RSG_CMP_ALL : RSG_CMP_ANY; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1463 |
group->g.random.lowest_randbit = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1464 |
group->g.random.num_groups = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1465 |
group->g.random.groups = calloc(group->g.random.num_groups, sizeof(*group->g.random.groups)); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1466 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1467 |
check_length(bufend - buf, 2 * group->g.random.num_groups, "NewSpriteGroup (Randomized) (2)"); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1468 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1469 |
for (i = 0; i < group->g.random.num_groups; i++) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1470 |
group->g.random.groups[i] = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1471 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1472 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1473 |
break; |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1474 |
} |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1475 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1476 |
/* Neither a variable or randomized sprite group... must be a real group */ |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1477 |
default: |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1478 |
{ |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1479 |
switch (feature) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1480 |
case GSF_TRAIN: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1481 |
case GSF_ROAD: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1482 |
case GSF_SHIP: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1483 |
case GSF_AIRCRAFT: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1484 |
case GSF_STATION: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1485 |
{ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1486 |
byte sprites = _cur_grffile->spriteset_numents; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1487 |
byte num_loaded = type; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1488 |
byte num_loading = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1489 |
uint i; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1490 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1491 |
if (_cur_grffile->spriteset_start == 0) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1492 |
grfmsg(GMS_ERROR, "NewSpriteGroup: No sprite set to work on! Skipping."); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1493 |
return; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1494 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1495 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1496 |
check_length(bufend - buf, 2 * num_loaded + 2 * num_loading, "NewSpriteGroup (Real) (1)"); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1497 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1498 |
group = AllocateSpriteGroup(); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1499 |
group->type = SGT_REAL; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1500 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1501 |
group->g.real.num_loaded = num_loaded; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1502 |
group->g.real.num_loading = num_loading; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1503 |
if (num_loaded > 0) group->g.real.loaded = calloc(num_loaded, sizeof(*group->g.real.loaded)); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1504 |
if (num_loading > 0) group->g.real.loading = calloc(num_loading, sizeof(*group->g.real.loading)); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1505 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1506 |
DEBUG(grf, 6) ("NewSpriteGroup: New SpriteGroup 0x%02X, %u views, %u loaded, %u loading", |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1507 |
setid, sprites, num_loaded, num_loading); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1508 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1509 |
for (i = 0; i < num_loaded; i++) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1510 |
uint16 spriteid = grf_load_word(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1511 |
group->g.real.loaded[i] = CreateGroupFromGroupID(setid, type, spriteid, sprites); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1512 |
DEBUG(grf, 8) ("NewSpriteGroup: + rg->loaded[%i] = subset %u", i, spriteid); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1513 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1514 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1515 |
for (i = 0; i < num_loading; i++) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1516 |
uint16 spriteid = grf_load_word(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1517 |
group->g.real.loading[i] = CreateGroupFromGroupID(setid, type, spriteid, sprites); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1518 |
DEBUG(grf, 8) ("NewSpriteGroup: + rg->loading[%i] = subset %u", i, spriteid); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1519 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1520 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1521 |
break; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1522 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1523 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1524 |
/* Loading of Tile Layout and Production Callback groups would happen here */ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1525 |
default: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
1526 |
grfmsg(GMS_WARN, "NewSpriteGroup: Unsupported feature %d, skipping.", feature); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
1527 |
} |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
1528 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1529 |
} |
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
1530 |
|
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
1531 |
_cur_grffile->spritegroups[setid] = group; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1532 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1533 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1534 |
/* Action 0x03 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1535 |
static void NewVehicle_SpriteGroupMapping(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1536 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1537 |
/* <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
|
1538 |
* id-list := [<id>] [id-list] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1539 |
* cargo-list := <cargo-type> <cid> [cargo-list] |
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 |
* B feature see action 0 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1542 |
* 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
|
1543 |
* 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
|
1544 |
* 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
|
1545 |
* 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
|
1546 |
* 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
|
1547 |
* 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
|
1548 |
* 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
|
1549 |
* 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
|
1550 |
/* TODO: Bridges, town houses. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1551 |
/* 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
|
1552 |
* 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
|
1553 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1554 |
static byte *last_engines; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1555 |
static int last_engines_count; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1556 |
uint8 feature; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1557 |
uint8 idcount; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1558 |
bool wagover; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1559 |
uint8 cidcount; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1560 |
int c, i; |
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 |
check_length(len, 7, "VehicleMapSpriteGroup"); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1563 |
feature = buf[1]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1564 |
idcount = buf[2] & 0x7F; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1565 |
wagover = (buf[2] & 0x80) == 0x80; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1566 |
check_length(len, 3 + idcount, "VehicleMapSpriteGroup"); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1567 |
cidcount = buf[3 + idcount]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1568 |
check_length(len, 4 + idcount + cidcount * 3, "VehicleMapSpriteGroup"); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1569 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1570 |
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
|
1571 |
feature, idcount, cidcount, wagover); |
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 |
if (feature > GSF_STATION) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1574 |
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
|
1575 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1576 |
} |
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 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1579 |
if (feature == GSF_STATION) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1580 |
// We do things differently for stations. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1581 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1582 |
for (i = 0; i < idcount; i++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1583 |
uint8 stid = buf[3 + i]; |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1584 |
StationSpec *statspec = _cur_grffile->stations[stid]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1585 |
byte *bp = &buf[4 + idcount]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1586 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1587 |
for (c = 0; c < cidcount; c++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1588 |
uint8 ctype = grf_load_byte(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1589 |
uint16 groupid = grf_load_word(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1590 |
|
2516
4659ceee4dcb
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1591 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1592 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1593 |
groupid, _cur_grffile->spritegroups_count); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1594 |
return; |
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 |
|
3750
ffe5ba5de494
(svn r4738) - Newstations: attach all sprite group cargo types, not just the default and purchase pseudo types, to a station spec.
peter1138
parents:
3740
diff
changeset
|
1597 |
if (ctype == 0xFE) ctype = GC_DEFAULT_NA; |
ffe5ba5de494
(svn r4738) - Newstations: attach all sprite group cargo types, not just the default and purchase pseudo types, to a station spec.
peter1138
parents:
3740
diff
changeset
|
1598 |
if (ctype == 0xFF) ctype = GC_PURCHASE; |
ffe5ba5de494
(svn r4738) - Newstations: attach all sprite group cargo types, not just the default and purchase pseudo types, to a station spec.
peter1138
parents:
3740
diff
changeset
|
1599 |
|
ffe5ba5de494
(svn r4738) - Newstations: attach all sprite group cargo types, not just the default and purchase pseudo types, to a station spec.
peter1138
parents:
3740
diff
changeset
|
1600 |
statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1601 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1602 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1603 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1604 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1605 |
byte *bp = buf + 4 + idcount + cidcount * 3; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1606 |
uint16 groupid = grf_load_word(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1607 |
|
2516
4659ceee4dcb
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1608 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1609 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1610 |
groupid, _cur_grffile->spritegroups_count); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1611 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1612 |
} |
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 |
for (i = 0; i < idcount; i++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1615 |
uint8 stid = buf[3 + i]; |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1616 |
StationSpec *statspec = _cur_grffile->stations[stid]; |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1617 |
|
3750
ffe5ba5de494
(svn r4738) - Newstations: attach all sprite group cargo types, not just the default and purchase pseudo types, to a station spec.
peter1138
parents:
3740
diff
changeset
|
1618 |
statspec->spritegroup[GC_DEFAULT] = _cur_grffile->spritegroups[groupid]; |
3775
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
1619 |
statspec->groundgroup = _cur_grffile->spritegroups[0]; |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1620 |
statspec->grfid = _cur_grffile->grfid; |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1621 |
statspec->localidx = stid; |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1622 |
SetCustomStationSpec(statspec); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1623 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1624 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1625 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1626 |
} |
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 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1629 |
/* 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
|
1630 |
* 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
|
1631 |
* now. --octo */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1632 |
if (idcount == 0) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1633 |
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
|
1634 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1635 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1636 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1637 |
// FIXME: Tropicset contains things like: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1638 |
// 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
|
1639 |
// what should we exactly do with that? --pasky |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1640 |
|
3635
26da0c860a64
(svn r4540) - NewGRF: don't treat integer values as boolean.
peter1138
parents:
3634
diff
changeset
|
1641 |
if (_cur_grffile->spriteset_start == 0 || _cur_grffile->spritegroups == 0) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1642 |
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
|
1643 |
return; |
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 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1646 |
if (!wagover && last_engines_count != idcount) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1647 |
last_engines = realloc(last_engines, idcount); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1648 |
last_engines_count = idcount; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1649 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1650 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1651 |
if (wagover) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1652 |
if (last_engines_count == 0) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1653 |
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
|
1654 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1655 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1656 |
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
|
1657 |
last_engines_count, idcount); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1658 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1659 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1660 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1661 |
for (i = 0; i < idcount; i++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1662 |
uint8 engine_id = buf[3 + i]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1663 |
uint8 engine = engine_id + _vehshifts[feature]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1664 |
byte *bp = &buf[4 + idcount]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1665 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1666 |
if (engine_id > _vehcounts[feature]) { |
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1667 |
grfmsg(GMS_ERROR, "Id %u for feature 0x%02X is out of bounds.", engine_id, feature); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1668 |
return; |
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 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1671 |
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
|
1672 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1673 |
for (c = 0; c < cidcount; c++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1674 |
uint8 ctype = grf_load_byte(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1675 |
uint16 groupid = grf_load_word(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1676 |
|
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1677 |
DEBUG(grf, 8) ("VehicleMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1678 |
|
2516
4659ceee4dcb
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1679 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1680 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", groupid, _cur_grffile->spritegroups_count); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1681 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1682 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1683 |
|
1802
da61740cc1e7
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1611
diff
changeset
|
1684 |
if (ctype == GC_INVALID) ctype = GC_PURCHASE; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1685 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1686 |
if (wagover) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1687 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
1688 |
SetWagonOverrideSprites(engine, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1689 |
} else { |
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
1690 |
SetCustomEngineSprites(engine, ctype, _cur_grffile->spritegroups[groupid]); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1691 |
last_engines[i] = engine; |
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 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1694 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1695 |
|
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 |
byte *bp = buf + 4 + idcount + cidcount * 3; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1698 |
uint16 groupid = grf_load_word(&bp); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1699 |
|
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1700 |
DEBUG(grf, 8) ("-- Default group id 0x%04X", groupid); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1701 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1702 |
for (i = 0; i < idcount; i++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1703 |
uint8 engine = buf[3 + i] + _vehshifts[feature]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1704 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1705 |
// Don't tell me you don't love duplicated code! |
2516
4659ceee4dcb
(svn r3045) -NewGRF, Codechange: Don't attempt to map and empty sprite group to a vehicle.
peter1138
parents:
2515
diff
changeset
|
1706 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1707 |
grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", groupid, _cur_grffile->spritegroups_count); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1708 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1709 |
} |
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 |
if (wagover) { |
3695
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1712 |
/* If the ID for this action 3 is the same as the vehicle ID, |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1713 |
* this indicates we have a helicopter rotor override. */ |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1714 |
if (feature == GSF_AIRCRAFT && engine == last_engines[i]) { |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1715 |
SetRotorOverrideSprites(engine, _cur_grffile->spritegroups[groupid]); |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1716 |
} else { |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1717 |
// TODO: No multiple cargo types per vehicle yet. --pasky |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1718 |
SetWagonOverrideSprites(engine, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
1719 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1720 |
} else { |
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
1721 |
SetCustomEngineSprites(engine, GC_DEFAULT, _cur_grffile->spritegroups[groupid]); |
3728
1e17fb743b49
(svn r4704) - NewGRF: in Action 0x03, set the engine type's GRF ID on the 'default' cargo type, not for each specific cargo. Fixes '(undefined string)' issues, as some engines weren't set properly.
peter1138
parents:
3715
diff
changeset
|
1722 |
SetEngineGRF(engine, _cur_grffile->grfid); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1723 |
last_engines[i] = engine; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1724 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1725 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1726 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1727 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1728 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1729 |
/* Action 0x04 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1730 |
static void VehicleNewName(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1731 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1732 |
/* <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
|
1733 |
* |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1734 |
* B veh-type see action 0 (as 00..07, + 0A |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1735 |
* But IF veh-type = 48, then generic text |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1736 |
* B language-id If bit 6 is set, This is the extended language scheme, |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1737 |
with up to 64 language. |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1738 |
Otherwise, it is a mapping where set bits have meaning |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1739 |
0 = american, 1 = english, 2 = german, 3 = french, 4 = spanish |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1740 |
Bit 7 set means this is a generic text, not a vehicle one (or else) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1741 |
* B num-veh number of vehicles which are getting a new name |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1742 |
* B/W offset number of the first vehicle that gets a new name |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1743 |
* Byte : ID of vehicle to change |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1744 |
* Word : ID of string to change/add |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1745 |
* 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
|
1746 |
* which the next name begins. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1747 |
/* 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
|
1748 |
* 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
|
1749 |
* (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
|
1750 |
* factory names etc). We should then also support all languages (by |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1751 |
* name), not only the original four ones. --pasky |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1752 |
* All of the above are coming. In Time. Some sooner than others :)*/ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1753 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1754 |
uint8 feature; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1755 |
uint8 lang; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1756 |
uint8 num; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1757 |
uint16 id; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1758 |
uint16 endid; |
1329 | 1759 |
const char* name; |
3643
c04228043cb0
(svn r4552) - NewGRF: fix braino... in r4550, new_scheme should true when the version is 7 or higher, not less than 7...
peter1138
parents:
3642
diff
changeset
|
1760 |
bool new_scheme = _cur_grffile->grf_version >= 7; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1761 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1762 |
check_length(len, 6, "VehicleNewName"); |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1763 |
buf++; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1764 |
feature = grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1765 |
lang = grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1766 |
num = grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1767 |
id = (lang & 0x80) ? grf_load_word(&buf) : grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1768 |
|
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
1769 |
if (feature <= GSF_AIRCRAFT && id < _vehcounts[feature]) { |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1770 |
id += _vehshifts[feature]; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1771 |
} |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1772 |
endid = id + num; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1773 |
|
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1774 |
DEBUG(grf, 6) ("VehicleNewName: About to rename engines %d..%d (feature %d) in language 0x%02X.", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1775 |
id, endid, feature, lang); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1776 |
|
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1777 |
name = (const char*)buf; /*transfer read value*/ |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1778 |
len -= (lang & 0x80) ? 6 : 5; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1779 |
for (; id < endid && len > 0; id++) { |
2458
dbaf5dffbb28
(svn r2984) Use adequate types, this should aid portability a bit
tron
parents:
2456
diff
changeset
|
1780 |
size_t ofs = strlen(name) + 1; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1781 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1782 |
if (ofs < 128) { |
1329 | 1783 |
DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, name); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1784 |
|
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1785 |
switch (feature) { |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1786 |
case GSF_TRAIN: |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1787 |
case GSF_ROAD: |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1788 |
case GSF_SHIP: |
3614 | 1789 |
case GSF_AIRCRAFT: { |
3641
88699e48a03e
(svn r4550) - NewGRF: update string system to new rules: a grf version of less than 6 uses the old scheme, of 7 or more uses the new scheme. (Moving targets, yay...)
peter1138
parents:
3640
diff
changeset
|
1790 |
StringID string = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name); |
3614 | 1791 |
if (id < TOTAL_NUM_ENGINES) SetCustomEngineName(id, string); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1792 |
break; |
3614 | 1793 |
} |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1794 |
|
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
1795 |
default: |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1796 |
switch (GB(id, 8, 8)) { |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
1797 |
case 0xC4: /* Station class name */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1798 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
3761
b8468ecd6dda
(svn r4752) - NewGRF: brokenness slipped through...
peter1138
parents:
3760
diff
changeset
|
1799 |
grfmsg(GMS_WARN, "VehicleNewName: Attempt to name undefined station 0x%X, ignoring.", GB(id, 0, 8)); |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
1800 |
} else { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1801 |
StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass; |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
1802 |
SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name)); |
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
1803 |
} |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1804 |
break; |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
1805 |
|
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
1806 |
case 0xC5: /* Station name */ |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1807 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
3761
b8468ecd6dda
(svn r4752) - NewGRF: brokenness slipped through...
peter1138
parents:
3760
diff
changeset
|
1808 |
grfmsg(GMS_WARN, "VehicleNewName: Attempt to name undefined station 0x%X, ignoring.", GB(id, 0, 8)); |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
1809 |
} else { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1810 |
_cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name); |
3760
68d223d2df89
(svn r4751) - NewGRF: when assigning new texts, ignore the feature byte as some sets use generic feature always. Also, don't add vehicle id shifts if the vehicle id is out of range.
peter1138
parents:
3750
diff
changeset
|
1811 |
} |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1812 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1813 |
|
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1814 |
default: |
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1815 |
DEBUG(grf, 7) ("VehicleNewName: Unsupported ID (0x%04X)", id); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1816 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1817 |
} |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1818 |
break; |
3642
8da309b5fd2b
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
1819 |
|
8da309b5fd2b
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
1820 |
#if 0 |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1821 |
case GSF_CANAL : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1822 |
case GSF_BRIDGE : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1823 |
case GSF_TOWNHOUSE : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1824 |
AddGRFString(_cur_spriteid, id, lang, name); |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1825 |
switch (GB(id, 8,8)) { |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1826 |
case 0xC9: /* House name */ |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1827 |
default: |
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1828 |
DEBUG(grf, 7) ("VehicleNewName: Unsupported ID (0x%04X)", id); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1829 |
} |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1830 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1831 |
|
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1832 |
case GSF_INDUSTRIES : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1833 |
case 0x48 : /* for generic strings */ |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1834 |
AddGRFString(_cur_spriteid, id, lang, name); |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1835 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1836 |
default : |
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
1837 |
DEBUG(grf,7) ("VehicleNewName: Unsupported feature (0x%02X)", feature); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1838 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1839 |
#endif |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
1840 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1841 |
} else { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1842 |
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
|
1843 |
} |
1329 | 1844 |
name += ofs; |
1845 |
len -= ofs; |
|
452
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 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1848 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1849 |
/* Action 0x05 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1850 |
static void GraphicsNew(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1851 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1852 |
/* <05> <graphics-type> <num-sprites> <other data...> |
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 |
* B graphics-type What set of graphics the sprites define. |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1855 |
* E num-sprites How many sprites are in this set? |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1856 |
* 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
|
1857 |
/* TODO */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1858 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1859 |
uint8 type; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1860 |
uint16 num; |
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1861 |
SpriteID replace = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1862 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1863 |
check_length(len, 2, "GraphicsNew"); |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1864 |
buf++; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1865 |
type = grf_load_byte(&buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
1866 |
num = grf_load_extended(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1867 |
|
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1868 |
switch (type) { |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1869 |
case 0x04: /* Signal graphics */ |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1870 |
if (num != 112 && num != 240) { |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1871 |
grfmsg(GMS_WARN, "GraphicsNews: Signal graphics sprite count must be 112 or 240, skipping."); |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1872 |
return; |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1873 |
} |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1874 |
_signal_base = _cur_spriteid; |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1875 |
break; |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1876 |
|
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1877 |
case 0x05: /* Catenary graphics */ |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1878 |
if (num != 48) { |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1879 |
grfmsg(GMS_WARN, "GraphicsNews: Catenary graphics sprite count must be 48, skipping."); |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1880 |
return; |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1881 |
} |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1882 |
replace = SPR_ELRAIL_BASE + 3; |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1883 |
break; |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1884 |
|
3709
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1885 |
case 0x06: /* Foundations */ |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1886 |
if (num != 74) { |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1887 |
grfmsg(GMS_WARN, "GraphicsNews: Foundation graphics sprite count must be 74, skipping."); |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1888 |
return; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1889 |
} |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1890 |
replace = SPR_SLOPES_BASE; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1891 |
break; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1892 |
|
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1893 |
case 0x08: /* Canal graphics */ |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1894 |
if (num != 65) { |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1895 |
grfmsg(GMS_WARN, "GraphicsNews: Canal graphics sprite count must be 65, skipping."); |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1896 |
return; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1897 |
} |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1898 |
replace = SPR_CANALS_BASE + 5; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1899 |
break; |
ccccabc1e8bc
(svn r4652) - NewGRF: support loading of foundation and canal graphics from NewGRF files via action 5
peter1138
parents:
3708
diff
changeset
|
1900 |
|
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1901 |
default: |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1902 |
grfmsg(GMS_NOTICE, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring).\n", |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1903 |
type, num); |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1904 |
return; |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1905 |
} |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1906 |
|
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1907 |
if (replace == 0) { |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1908 |
grfmsg(GMS_NOTICE, "GraphicsNew: Loading %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, _cur_spriteid); |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1909 |
} else { |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1910 |
grfmsg(GMS_NOTICE, "GraphicsNew: Replacing %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, replace); |
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1911 |
} |
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1912 |
|
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1913 |
for (; num > 0; num--) { |
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
1914 |
LoadNextSprite(replace == 0 ? _cur_spriteid++ : replace++, _file_index); |
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1915 |
_nfo_line++; |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
1916 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1917 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1918 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1919 |
/* Action 0x06 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1920 |
static void CfgApply(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1921 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1922 |
/* <06> <param-num> <param-size> <offset> ... <FF> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1923 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1924 |
* 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
|
1925 |
* 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
|
1926 |
* 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
|
1927 |
* 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
|
1928 |
* case, nothing is applied unless *all* parameters |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1929 |
* were specified. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1930 |
* 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
|
1931 |
* to place where parameter is to be stored. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1932 |
/* TODO */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1933 |
grfmsg(GMS_NOTICE, "CfgApply: Ignoring (not implemented).\n"); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1934 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1935 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1936 |
/* Action 0x07 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1937 |
/* Action 0x09 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1938 |
static void SkipIf(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1939 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1940 |
/* <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
|
1941 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1942 |
* B param-num |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1943 |
* B param-size |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1944 |
* B condition-type |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1945 |
* V value |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1946 |
* B num-sprites */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1947 |
/* TODO: More params. More condition types. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1948 |
uint8 param; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1949 |
uint8 paramsize; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1950 |
uint8 condtype; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1951 |
uint8 numsprites; |
2336
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
1952 |
uint32 param_val = 0; |
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
1953 |
uint32 cond_val = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1954 |
bool result; |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
1955 |
GRFLabel *label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
1956 |
GRFLabel *choice = NULL; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1957 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1958 |
check_length(len, 6, "SkipIf"); |
3714
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1959 |
buf++; |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1960 |
param = grf_load_byte(&buf); |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1961 |
paramsize = grf_load_byte(&buf); |
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
1962 |
condtype = grf_load_byte(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1963 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1964 |
if (condtype < 2) { |
1611 | 1965 |
/* Always 1 for bit tests, the given value should be ignored. */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1966 |
paramsize = 1; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1967 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1968 |
|
1611 | 1969 |
switch (paramsize) { |
1970 |
case 4: cond_val = grf_load_dword(&buf); break; |
|
1971 |
case 2: cond_val = grf_load_word(&buf); break; |
|
1972 |
case 1: cond_val = grf_load_byte(&buf); break; |
|
1973 |
default: break; |
|
1974 |
} |
|
452
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 |
switch (param) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1977 |
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
|
1978 |
param_val = _opt.landscape; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1979 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1980 |
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
|
1981 |
param_val = _cur_stage; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1982 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1983 |
case 0x85: /* TTDPatch flags, only for bit tests */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1984 |
param_val = _ttdpatch_flags[cond_val / 0x20]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1985 |
cond_val %= 0x20; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1986 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1987 |
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
|
1988 |
param_val = _opt.road_side << 4; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1989 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1990 |
case 0x88: { /* see if specified GRFID is active */ |
1611 | 1991 |
param_val = (GetFileByGRFID(cond_val) != NULL); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1992 |
} break; |
2336
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
1993 |
|
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
1994 |
case 0x8B: { /* TTDPatch version */ |
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
1995 |
uint major = 2; |
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
1996 |
uint minor = 0; |
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
1997 |
uint revision = 10; // special case: 2.0.1 is 2.0.10 |
3704
e99d981ea898
(svn r4645) - NewGRF: pretend to be the last alpha version of TTDPatch in our version value.
peter1138
parents:
3695
diff
changeset
|
1998 |
uint build = 73; |
2336
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
1999 |
param_val = (major << 24) | (minor << 20) | (revision << 16) | (build * 10); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2000 |
break; |
2336
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
2001 |
} |
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
2002 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2003 |
case 0x8D: /* TTD Version, 00=DOS, 01=Windows */ |
2582
1b7f3a2f477e
(svn r3119) Don't pretend to be the Windows version of TTD all the time. When being asked answer according to _use_dos_palette. (Suggestion by Belugas)
tron
parents:
2549
diff
changeset
|
2004 |
param_val = !_use_dos_palette; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2005 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2006 |
case 0x8E: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2007 |
param_val = _traininfo_vehicle_pitch; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2008 |
break; |
2614
b6d1a127a6e4
(svn r3152) - NewGRF: [ 1340189 ] Action 7/9 new value : is it TTDPatch or OpenTTD? (belugas)
peter1138
parents:
2611
diff
changeset
|
2009 |
case 0x9D: /* TTD Platform, 00=TTDPatch, 01=OpenTTD */ |
b6d1a127a6e4
(svn r3152) - NewGRF: [ 1340189 ] Action 7/9 new value : is it TTDPatch or OpenTTD? (belugas)
peter1138
parents:
2611
diff
changeset
|
2010 |
param_val = 1; |
b6d1a127a6e4
(svn r3152) - NewGRF: [ 1340189 ] Action 7/9 new value : is it TTDPatch or OpenTTD? (belugas)
peter1138
parents:
2611
diff
changeset
|
2011 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2012 |
/* TODO */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2013 |
case 0x8F: /* Track type cost multipliers */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2014 |
default: |
2345 | 2015 |
if (param < 0x80) { |
2016 |
/* Parameter. */ |
|
2017 |
param_val = _cur_grffile->param[param]; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2018 |
} else { |
2345 | 2019 |
/* In-game variable. */ |
2020 |
grfmsg(GMS_WARN, "Unsupported in-game variable 0x%02X. Ignoring test.", param); |
|
2021 |
return; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2022 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2023 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2024 |
|
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
2025 |
DEBUG(grf, 7) ("Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2026 |
switch (condtype) { |
1606
d15a9fdea49e
(svn r2110) - Fix: Fixed test for various flags (e.g. newtrains in usset). result is bool so !! any non-zero values before assigning them to it - they apparently didn't fit. ;-)
pasky
parents:
1542
diff
changeset
|
2027 |
case 0: result = !!(param_val & (1 << cond_val)); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2028 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2029 |
case 1: result = !(param_val & (1 << cond_val)); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2030 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2031 |
/* 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
|
2032 |
case 2: result = (param_val == cond_val); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2033 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2034 |
case 3: result = (param_val != cond_val); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2035 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2036 |
case 4: result = (param_val < cond_val); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2037 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2038 |
case 5: result = (param_val > cond_val); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2039 |
break; |
1606
d15a9fdea49e
(svn r2110) - Fix: Fixed test for various flags (e.g. newtrains in usset). result is bool so !! any non-zero values before assigning them to it - they apparently didn't fit. ;-)
pasky
parents:
1542
diff
changeset
|
2040 |
case 6: result = !!param_val; /* GRFID is active (only for param-num=88) */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2041 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2042 |
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
|
2043 |
break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2044 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2045 |
grfmsg(GMS_WARN, "Unsupported test %d. Ignoring.", condtype); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2046 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2047 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2048 |
|
1607
fd027776f222
(svn r2111) So, result is bool therefore no need for this horrible == 0 thing.
pasky
parents:
1606
diff
changeset
|
2049 |
if (!result) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2050 |
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
|
2051 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2052 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2053 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2054 |
numsprites = grf_load_byte(&buf); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2055 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2056 |
/* numsprites can be a GOTO label if it has been defined in the GRF |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2057 |
* file. The jump will always be the first matching label that follows |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2058 |
* the current nfo_line. If no matching label is found, the first matching |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2059 |
* label in the file is used. */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2060 |
for (label = _cur_grffile->label; label != NULL; label = label->next) { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2061 |
if (label->label != numsprites) continue; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2062 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2063 |
/* Remember a goto before the current line */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2064 |
if (choice == NULL) choice = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2065 |
/* If we find a label here, this is definitely good */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2066 |
if (label->nfo_line > _nfo_line) { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2067 |
choice = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2068 |
break; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2069 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2070 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2071 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2072 |
if (choice != NULL) { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2073 |
grfmsg(GMS_NOTICE, "Jumping to label 0x%0X at line %d, test was true.", choice->label, choice->nfo_line); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2074 |
FioSeekTo(choice->pos, SEEK_SET); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2075 |
_nfo_line = choice->nfo_line; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2076 |
return; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2077 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2078 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2079 |
grfmsg(GMS_NOTICE, "Skipping %d sprites, test was true.", numsprites); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2080 |
_skip_sprites = numsprites; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2081 |
if (_skip_sprites == 0) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2082 |
/* 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
|
2083 |
* we use -1 to indicate that all further |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2084 |
* sprites should be skipped. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2085 |
_skip_sprites = -1; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2086 |
} |
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 |
|
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2089 |
/* Action 0x08 */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2090 |
static void GRFInfo(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2091 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2092 |
/* <08> <version> <grf-id> <name> <info> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2093 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2094 |
* B version newgrf version, currently 06 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2095 |
* 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
|
2096 |
* S name name of this .grf set |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2097 |
* 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
|
2098 |
/* 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
|
2099 |
uint8 version; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2100 |
uint32 grfid; |
1329 | 2101 |
const char *name; |
2102 |
const char *info; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2103 |
|
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
2104 |
check_length(len, 8, "GRFInfo"); buf++; |
3712
0ad6fed91f3c
(svn r4655) - Fix [NewGRF r4654]: /me bangs head against the wall....gaah
Darkvater
parents:
3711
diff
changeset
|
2105 |
version = grf_load_byte(&buf); |
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
2106 |
grfid = grf_load_dword(&buf); |
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
2107 |
name = (const char*)buf; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2108 |
info = name + strlen(name) + 1; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2109 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2110 |
_cur_grffile->grfid = grfid; |
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2111 |
_cur_grffile->grf_version = version; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2112 |
_cur_grffile->flags |= 0x0001; /* set active flag */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2113 |
|
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
2114 |
/* Do swap the GRFID for displaying purposes since people expect that */ |
2013
c83b52340eee
(svn r2521) -Codechange: Removed trailing "\n"s from DEBUG statements
celestar
parents:
1968
diff
changeset
|
2115 |
DEBUG(grf, 1) ("[%s] Loaded GRFv%d set %08lx - %s:\n%s", |
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
2116 |
_cur_grffile->filename, version, BSWAP32(grfid), name, info); |
452
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 |
|
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
2119 |
/* Action 0x0A */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2120 |
static void SpriteReplace(byte *buf, int len) |
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 |
/* <0A> <num-sets> <set1> [<set2> ...] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2123 |
* <set>: <num-sprites> <first-sprite> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2124 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2125 |
* 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
|
2126 |
* Each set: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2127 |
* 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
|
2128 |
* W first-sprite First sprite number to replace */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2129 |
uint8 num_sets; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2130 |
uint i; |
452
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 |
buf++; /* skip action byte */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2133 |
num_sets = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2134 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2135 |
for (i = 0; i < num_sets; i++) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2136 |
uint8 num_sprites = grf_load_byte(&buf); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2137 |
uint16 first_sprite = grf_load_word(&buf); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2138 |
uint j; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2139 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2140 |
grfmsg(GMS_NOTICE, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2141 |
"SpriteReplace: [Set %d] Changing %d sprites, beginning with %d", |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2142 |
i, num_sprites, first_sprite |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2143 |
); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2144 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2145 |
for (j = 0; j < num_sprites; j++) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2146 |
LoadNextSprite(first_sprite + j, _file_index); // XXX |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
2147 |
_nfo_line++; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2148 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2149 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2150 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2151 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2152 |
/* Action 0x0B */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2153 |
static void GRFError(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2154 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2155 |
/* <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
|
2156 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2157 |
* B severity 00: notice, contine loading grf file |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2158 |
* 01: warning, continue loading grf file |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2159 |
* 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
|
2160 |
* 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
|
2161 |
* 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
|
2162 |
* the future (only when restarting the patch) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2163 |
* 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
|
2164 |
* B message-id message to show, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2165 |
* 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
|
2166 |
* not present for built-in messages. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2167 |
* 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
|
2168 |
* 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
|
2169 |
/* 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
|
2170 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2171 |
static const char * const msgstr[4] = { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2172 |
"Requires at least pseudo-TTDPatch version %s.", |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2173 |
"This file is for %s version of TTD.", |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2174 |
"Designed to be used with %s.", |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2175 |
"Invalid parameter %s.", |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2176 |
}; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2177 |
uint8 severity; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2178 |
uint8 msgid; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2179 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2180 |
check_length(len, 6, "GRFError"); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2181 |
severity = buf[1]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2182 |
msgid = buf[3]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2183 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2184 |
// Undocumented TTDPatch feature. |
3588
69817310ddf8
(svn r4474) - NewGRF: Skip non-fatal errors when not in stage 2.
peter1138
parents:
3577
diff
changeset
|
2185 |
if ((severity & 0x80) == 0 && _cur_stage < 2) { |
69817310ddf8
(svn r4474) - NewGRF: Skip non-fatal errors when not in stage 2.
peter1138
parents:
3577
diff
changeset
|
2186 |
DEBUG(grf, 7) ("Skipping non-fatal GRFError in stage 1"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2187 |
return; |
3588
69817310ddf8
(svn r4474) - NewGRF: Skip non-fatal errors when not in stage 2.
peter1138
parents:
3577
diff
changeset
|
2188 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2189 |
severity &= 0x7F; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2190 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2191 |
if (msgid == 0xFF) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2192 |
grfmsg(severity, "%s", buf+4); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2193 |
} else { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2194 |
grfmsg(severity, msgstr[msgid], buf+4); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2195 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2196 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2197 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2198 |
/* Action 0x0C */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2199 |
static void GRFComment(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2200 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2201 |
/* <0C> [<ignored...>] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2202 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2203 |
* V ignored Anything following the 0C is ignored */ |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2204 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2205 |
static char comment[256]; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2206 |
if (len == 1) return; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2207 |
|
3571 | 2208 |
ttd_strlcpy(comment, (char*)(buf + 1), minu(sizeof(comment), len)); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2209 |
grfmsg(GMS_NOTICE, "GRFComment: %s", comment); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2210 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2211 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2212 |
/* Action 0x0D */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2213 |
static void ParamSet(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2214 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2215 |
/* <0D> <target> <operation> <source1> <source2> [<data>] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2216 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2217 |
* B target parameter number where result is stored |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2218 |
* B operation operation to perform, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2219 |
* B source1 first source operand |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2220 |
* B source2 second source operand |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2221 |
* 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
|
2222 |
* 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
|
2223 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2224 |
* Operations |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2225 |
* 00 Set parameter equal to source1 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2226 |
* 01 Addition, source1 + source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2227 |
* 02 Subtraction, source1 - source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2228 |
* 03 Unsigned multiplication, source1 * source2 (both unsigned) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2229 |
* 04 Signed multiplication, source1 * source2 (both signed) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2230 |
* 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
|
2231 |
* 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
|
2232 |
* negative, source1 is unsigned) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2233 |
* 06 Signed bit shift, source1 by source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2234 |
* (source2 like in 05, and source1 as well) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2235 |
*/ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2236 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2237 |
byte target; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2238 |
byte oper; |
2345 | 2239 |
uint32 src1; |
2240 |
uint32 src2; |
|
2241 |
uint32 data = 0; |
|
2242 |
uint32 res; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2243 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2244 |
check_length(len, 5, "ParamSet"); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2245 |
buf++; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2246 |
target = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2247 |
oper = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2248 |
src1 = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2249 |
src2 = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2250 |
|
2345 | 2251 |
if (len >= 8) data = grf_load_dword(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2252 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2253 |
/* 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
|
2254 |
* 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
|
2255 |
* defined if any of the following applies: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2256 |
* - 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
|
2257 |
* - 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
|
2258 |
* an earlier action D */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2259 |
if (oper & 0x80) { |
2345 | 2260 |
if (_cur_grffile->param_end < target) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2261 |
oper &= 0x7F; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2262 |
else |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2263 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2264 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2265 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2266 |
/* 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
|
2267 |
* 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
|
2268 |
* 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
|
2269 |
* 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
|
2270 |
* of 0 is used instead. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2271 |
if (src1 == 0xFF) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2272 |
src1 = data; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2273 |
} else { |
2345 | 2274 |
src1 = _cur_grffile->param_end >= src1 ? _cur_grffile->param[src1] : 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2275 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2276 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2277 |
if (src2 == 0xFF) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2278 |
src2 = data; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2279 |
} else { |
2345 | 2280 |
src2 = _cur_grffile->param_end >= src2 ? _cur_grffile->param[src2] : 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2281 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2282 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2283 |
/* 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
|
2284 |
* 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
|
2285 |
* 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
|
2286 |
* 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
|
2287 |
* instead. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2288 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2289 |
switch (oper) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2290 |
case 0x00: |
2345 | 2291 |
res = src1; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2292 |
break; |
2345 | 2293 |
|
2294 |
case 0x01: |
|
2295 |
res = src1 + src2; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2296 |
break; |
2345 | 2297 |
|
2298 |
case 0x02: |
|
2299 |
res = src1 - src2; |
|
2300 |
break; |
|
2301 |
||
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2302 |
case 0x03: |
2345 | 2303 |
res = src1 * src2; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2304 |
break; |
2345 | 2305 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2306 |
case 0x04: |
2345 | 2307 |
res = (int32)src1 * (int32)src2; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2308 |
break; |
2345 | 2309 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2310 |
case 0x05: |
2345 | 2311 |
if ((int32)src2 < 0) |
2312 |
res = src1 >> -(int32)src2; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2313 |
else |
2345 | 2314 |
res = src1 << src2; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2315 |
break; |
2345 | 2316 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2317 |
case 0x06: |
2345 | 2318 |
if ((int32)src2 < 0) |
2319 |
res = (int32)src1 >> -(int32)src2; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2320 |
else |
2345 | 2321 |
res = (int32)src1 << src2; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2322 |
break; |
2345 | 2323 |
|
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2324 |
case 0x07: /* Bitwise AND */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2325 |
res = src1 & src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2326 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2327 |
|
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2328 |
case 0x08: /* Bitwise OR */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2329 |
res = src1 | src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2330 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2331 |
|
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2332 |
case 0x09: /* Unsigned division */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2333 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2334 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2335 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2336 |
res = src1 / src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2337 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2338 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2339 |
|
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2340 |
case 0x0A: /* Signed divison */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2341 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2342 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2343 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2344 |
res = (int32)src1 / (int32)src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2345 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2346 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2347 |
|
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2348 |
case 0x0B: /* Unsigned modulo */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2349 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2350 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2351 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2352 |
res = src1 % src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2353 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2354 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2355 |
|
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2356 |
case 0x0C: /* Signed modulo */ |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2357 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2358 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2359 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2360 |
res = (int32)src1 % (int32)src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2361 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2362 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
2363 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2364 |
default: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2365 |
grfmsg(GMS_ERROR, "ParamSet: Unknown operation %d, skipping.", oper); |
2345 | 2366 |
return; |
2367 |
} |
|
2368 |
||
2369 |
switch (target) { |
|
2370 |
case 0x8E: // Y-Offset for train sprites |
|
2371 |
_traininfo_vehicle_pitch = res; |
|
2372 |
break; |
|
2373 |
||
2374 |
// TODO implement |
|
2375 |
case 0x8F: // Rail track type cost factors |
|
2376 |
case 0x93: // Tile refresh offset to left |
|
2377 |
case 0x94: // Tile refresh offset to right |
|
2378 |
case 0x95: // Tile refresh offset upwards |
|
2379 |
case 0x96: // Tile refresh offset downwards |
|
2380 |
case 0x97: // Snow line height |
|
2381 |
case 0x99: // Global ID offset |
|
2382 |
DEBUG(grf, 7) ("ParamSet: Skipping unimplemented target 0x%02X", target); |
|
2383 |
break; |
|
2384 |
||
2385 |
default: |
|
2386 |
if (target < 0x80) { |
|
2387 |
_cur_grffile->param[target] = res; |
|
2388 |
if (target + 1U > _cur_grffile->param_end) _cur_grffile->param_end = target + 1; |
|
2389 |
} else { |
|
2390 |
DEBUG(grf, 7) ("ParamSet: Skipping unknown target 0x%02X", target); |
|
2391 |
} |
|
2392 |
break; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2393 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2394 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2395 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2396 |
/* Action 0x0E */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2397 |
static void GRFInhibit(byte *buf, int len) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2398 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2399 |
/* <0E> <num> <grfids...> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2400 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2401 |
* B num Number of GRFIDs that follow |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2402 |
* D grfids GRFIDs of the files to deactivate */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2403 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2404 |
byte num; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2405 |
int i; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2406 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2407 |
check_length(len, 1, "GRFInhibit"); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2408 |
buf++, len--; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2409 |
num = grf_load_byte(&buf); len--; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2410 |
check_length(len, 4 * num, "GRFInhibit"); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2411 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2412 |
for (i = 0; i < num; i++) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2413 |
uint32 grfid = grf_load_dword(&buf); |
1477 | 2414 |
GRFFile *file = GetFileByGRFID(grfid); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2415 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2416 |
/* Unset activation flag */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2417 |
if (file != NULL) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2418 |
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
|
2419 |
file->flags &= 0xFFFE; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2420 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2421 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2422 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2423 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
2424 |
/* Action 0x10 */ |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2425 |
static void DefineGotoLabel(byte *buf, int len) |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2426 |
{ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2427 |
/* <10> <label> [<comment>] |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2428 |
* |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2429 |
* B label The label to define |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2430 |
* V comment Optional comment - ignored */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2431 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2432 |
GRFLabel *label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2433 |
|
3566
21db83574baf
(svn r4447) - NewGRF: It seems I committed printing action NOP Action 0x0C which is mainly used for comments. So leave it in, but fix the created warning. Use proper action name for check_length() in Action 0x10
Darkvater
parents:
3561
diff
changeset
|
2434 |
check_length(len, 1, "DefineGotoLabel"); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2435 |
buf++; len--; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2436 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2437 |
label = malloc(sizeof(*label)); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2438 |
label->label = grf_load_byte(&buf); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2439 |
label->nfo_line = _nfo_line; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2440 |
label->pos = FioGetPos(); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2441 |
label->next = NULL; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2442 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2443 |
/* Set up a linked list of goto targets which we will search in an Action 0x7/0x9 */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2444 |
if (_cur_grffile->label == NULL) { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2445 |
_cur_grffile->label = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2446 |
} else { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2447 |
/* Attach the label to the end of the list */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2448 |
GRFLabel *l; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2449 |
for (l = _cur_grffile->label; l->next != NULL; l = l->next); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2450 |
l->next = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2451 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2452 |
|
3630
13278b8ed023
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
Darkvater
parents:
3628
diff
changeset
|
2453 |
grfmsg(GMS_NOTICE, "DefineGotoLabel: GOTO target with label 0x%02X", label->label); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2454 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2455 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2456 |
static void InitializeGRFSpecial(void) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2457 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2458 |
/* 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
|
2459 |
|
2628
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2460 |
_ttdpatch_flags[0] = (_patches.always_small_airport ? (1 << 0x0C) : 0) /* keepsmallairport */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2461 |
| (1 << 0x0E) /* largestations */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2462 |
| (_patches.longbridges ? (1 << 0x0F) : 0) /* longbridges */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2463 |
| (1 << 0x12) /* presignals */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2464 |
| (1 << 0x13) /* extpresignals */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2465 |
| (_patches.never_expire_vehicles ? (1 << 0x16) : 0) /* enginespersist */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2466 |
| (1 << 0x1B); /* multihead */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2467 |
_ttdpatch_flags[1] = (_patches.mammoth_trains ? (1 << 0x08) : 0) /* mammothtrains */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2468 |
| (1 << 0x09) /* trainrefit */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2469 |
| (1 << 0x14) /* bridgespeedlimits */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2470 |
| (1 << 0x16) /* eternalgame */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2471 |
| (1 << 0x17) /* newtrains */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2472 |
| (1 << 0x18) /* newrvs */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2473 |
| (1 << 0x19) /* newships */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2474 |
| (1 << 0x1A) /* newplanes */ |
3355
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3095
diff
changeset
|
2475 |
| (_patches.signal_side ? (1 << 0x1B) : 0) /* signalsontrafficside */ |
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3095
diff
changeset
|
2476 |
| (1 << 0x1C); /* electrifiedrailway */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2477 |
|
2628
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2478 |
_ttdpatch_flags[2] = (_patches.build_on_slopes ? (1 << 0x0D) : 0) /* buildonslopes */ |
3777
455c0c7b657e
(svn r4769) - Newstations: add newstations ttdpatch flag
peter1138
parents:
3775
diff
changeset
|
2479 |
| (1 << 0x12) /* newstations */ |
2628
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2480 |
| (_patches.build_on_slopes ? (1 << 0x15) : 0) /* buildoncoasts */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2481 |
| (1 << 0x16) /* canals */ |
2456
2317dd6f4b19
(svn r2982) Newgrf: Added patch option for wagon speed limits. This is enabled by default.
peter1138
parents:
2445
diff
changeset
|
2482 |
| (1 << 0x17) /* newstartyear */ |
2628
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2483 |
| (1 << 0x1A) /* newbridges */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2484 |
| (_patches.wagon_speed_limits ? (1 << 0x1D) : 0); /* wagonspeedlimits */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2485 |
_ttdpatch_flags[3] = (1 << 0x03) /* pathbasedsignalling */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2486 |
| (1 << 0x0C) /* enhancemultiplayer */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2487 |
| (1 << 0x0E) /* irregularstations */ |
3e7c4506346c
(svn r3170) - NewGRF: make ttdpatch flags to reflect patch option status, and added some more values.
peter1138
parents:
2627
diff
changeset
|
2488 |
| (1 << 0x10); /* autoreplace */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2489 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2490 |
|
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2491 |
static void ResetCustomStations(void) |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2492 |
{ |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2493 |
StationSpec *statspec; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2494 |
GRFFile *file; |
2627
7a29af37b416
(svn r3169) Little bit of coding style fixing, and change from value to lengthof()
peter1138
parents:
2625
diff
changeset
|
2495 |
uint i; |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2496 |
uint t; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2497 |
|
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2498 |
for (file = _first_grffile; file != NULL; file = file->next) { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
2499 |
if (file->stations == NULL) continue; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
2500 |
for (i = 0; i < MAX_STATIONS; i++) { |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
2501 |
if (file->stations[i] == NULL) continue; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
2502 |
statspec = file->stations[i]; |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2503 |
|
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2504 |
/* Release renderdata, if it wasn't copied from another custom station spec */ |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2505 |
if (!statspec->copied_renderdata) { |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2506 |
for (t = 0; t < statspec->tiles; t++) { |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2507 |
free((void*)statspec->renderdata[t].seq); |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2508 |
} |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2509 |
free(statspec->renderdata); |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2510 |
} |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2511 |
|
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
2512 |
// TODO: Release platforms and layouts |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
2513 |
|
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
2514 |
/* Release this station */ |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
2515 |
free(statspec); |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2516 |
} |
3501
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
2517 |
|
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
2518 |
/* Free and reset the station data */ |
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
2519 |
free(file->stations); |
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
2520 |
file->stations = NULL; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2521 |
} |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2522 |
} |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2523 |
|
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
2524 |
/** |
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2525 |
* Reset all NewGRF loaded data |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2526 |
* TODO |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2527 |
*/ |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2528 |
static void ResetNewGRFData(void) |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2529 |
{ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2530 |
uint i; |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
2531 |
|
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2532 |
CleanUpStrings(); |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
2533 |
|
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2534 |
// Copy/reset original engine info data |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2535 |
memcpy(&_engine_info, &orig_engine_info, sizeof(orig_engine_info)); |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2536 |
memcpy(&_rail_vehicle_info, &orig_rail_vehicle_info, sizeof(orig_rail_vehicle_info)); |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2537 |
memcpy(&_ship_vehicle_info, &orig_ship_vehicle_info, sizeof(orig_ship_vehicle_info)); |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2538 |
memcpy(&_aircraft_vehicle_info, &orig_aircraft_vehicle_info, sizeof(orig_aircraft_vehicle_info)); |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2539 |
memcpy(&_road_vehicle_info, &orig_road_vehicle_info, sizeof(orig_road_vehicle_info)); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
2540 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
2541 |
// Copy/reset original bridge info data |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
2542 |
// First, free sprite table data |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
2543 |
for (i = 0; i < MAX_BRIDGES; i++) { |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
2544 |
if (_bridge[i].sprite_table != NULL) { |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2545 |
uint j; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2546 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2547 |
for (j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
2548 |
free(_bridge[i].sprite_table); |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
2549 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
2550 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
2551 |
memcpy(&_bridge, &orig_bridge, sizeof(_bridge)); |
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
2552 |
|
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2553 |
// Reset refit/cargo class data |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2554 |
memset(&cargo_allowed, 0, sizeof(cargo_allowed)); |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2555 |
memset(&cargo_disallowed, 0, sizeof(cargo_disallowed)); |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2556 |
|
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
2557 |
// Unload sprite group data |
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
2558 |
UnloadWagonOverrides(); |
3695
e1d5608f4d32
(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)
peter1138
parents:
3694
diff
changeset
|
2559 |
UnloadRotorOverrideSprites(); |
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
2560 |
UnloadCustomEngineSprites(); |
2769
eab49a86038e
(svn r3316) - NewGRF: Unload engine names before loading grf files. This fixes names in climates where the engines don't get loaded. Renamed function to reflect its purpose.
peter1138
parents:
2766
diff
changeset
|
2561 |
UnloadCustomEngineNames(); |
2971
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
2562 |
ResetEngineListOrder(); |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
2563 |
|
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
2564 |
// Reset price base data |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
2565 |
ResetPriceBaseMultipliers(); |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2566 |
|
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2567 |
// Reset station classes |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2568 |
ResetStationClasses(); |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
2569 |
ResetCustomStations(); |
2812
95102021c840
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
2570 |
|
95102021c840
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
2571 |
// Add engine type to engine data. This is needed for the refit precalculation. |
95102021c840
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
2572 |
AddTypeToEngines(); |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2573 |
|
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2574 |
InitializeSpriteGroupPool(); |
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2575 |
} |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2576 |
|
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2577 |
/** Reset all NewGRFData that was used only while processing data */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2578 |
static void ClearTemporaryNewGRFData(void) |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2579 |
{ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2580 |
/* Clear the GOTO labels used for GRF processing */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2581 |
GRFLabel *l; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2582 |
for (l = _cur_grffile->label; l != NULL;) { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2583 |
GRFLabel *l2 = l->next; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2584 |
free(l); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2585 |
l = l2; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2586 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2587 |
_cur_grffile->label = NULL; |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2588 |
|
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2589 |
/* Clear the list of spritegroups */ |
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2590 |
free(_cur_grffile->spritegroups); |
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2591 |
_cur_grffile->spritegroups = NULL; |
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2592 |
_cur_grffile->spritegroups_count = 0; |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2593 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2594 |
|
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2595 |
static void InitNewGRFFile(const GRFConfig *config, int sprite_offset) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2596 |
{ |
1477 | 2597 |
GRFFile *newfile; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2598 |
|
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2599 |
newfile = GetFileByFilename(config->filename); |
490
03e2d2abeec7
(svn r772) Whoops, I know. Do not consider pointer to be a boolean value. Sorry 'bout that, sirs.
pasky
parents:
489
diff
changeset
|
2600 |
if (newfile != NULL) { |
489
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
|
2601 |
/* 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
|
2602 |
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
|
2603 |
_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
|
2604 |
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
|
2605 |
} |
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
|
2606 |
|
1477 | 2607 |
newfile = calloc(1, sizeof(*newfile)); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2608 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2609 |
if (newfile == NULL) error ("Out of memory"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2610 |
|
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2611 |
newfile->filename = strdup(config->filename); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2612 |
newfile->sprite_offset = sprite_offset; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2613 |
|
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2614 |
/* Copy the initial parameter list */ |
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2615 |
assert(lengthof(newfile->param) == lengthof(config->param) && lengthof(config->param) == 0x80); |
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2616 |
newfile->param_end = config->num_params; |
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2617 |
memcpy(newfile->param, config->param, 0x80 * sizeof(newfile->param[0])); |
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2618 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2619 |
if (_first_grffile == NULL) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2620 |
_cur_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2621 |
_first_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2622 |
} else { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2623 |
_cur_grffile->next = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2624 |
_cur_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2625 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2626 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2627 |
|
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2628 |
/** |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2629 |
* Precalculate refit masks from cargo classes for all vehicles. |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2630 |
*/ |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2631 |
static void CalculateRefitMasks(void) |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2632 |
{ |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2633 |
EngineID engine; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2634 |
|
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2635 |
for (engine = 0; engine < TOTAL_NUM_ENGINES; engine++) { |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2636 |
uint32 mask = 0; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2637 |
uint32 not_mask = 0; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2638 |
uint32 xor_mask = _engine_info[engine].refit_mask; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2639 |
byte i; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2640 |
|
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2641 |
if (cargo_allowed[engine] != 0) { |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2642 |
// Build up the list of cargo types from the set cargo classes. |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2643 |
for (i = 0; i < lengthof(cargo_classes); i++) { |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2644 |
if (HASBIT(cargo_allowed[engine], i)) mask |= cargo_classes[i]; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2645 |
if (HASBIT(cargo_disallowed[engine], i)) not_mask |= cargo_classes[i]; |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2646 |
} |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2647 |
} else { |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2648 |
// Don't apply default refit mask to wagons or engines with no capacity |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2649 |
if (xor_mask == 0 && ( |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2650 |
GetEngine(engine)->type != VEH_Train || ( |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2651 |
RailVehInfo(engine)->capacity != 0 && |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2652 |
!(RailVehInfo(engine)->flags & RVI_WAGON) |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2653 |
) |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2654 |
)) { |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2655 |
xor_mask = _default_refitmasks[GetEngine(engine)->type - VEH_Train]; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2656 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2657 |
} |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2658 |
_engine_info[engine].refit_mask = ((mask & ~not_mask) ^ xor_mask) & _landscape_global_cargo_mask[_opt.landscape]; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2659 |
} |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2660 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2661 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2662 |
/* 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
|
2663 |
* 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
|
2664 |
* partial implementation yet). */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2665 |
/* 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
|
2666 |
* 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
|
2667 |
* better make this more robust in the future. */ |
2958
ac0a9673b522
(svn r3520) Remove unused parameters from some functions
tron
parents:
2935
diff
changeset
|
2668 |
static void DecodeSpecialSprite(uint num, uint stage) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2669 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2670 |
/* 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
|
2671 |
* here. In TTDPatch, for some reason actions 1 and 2 are carried out |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2672 |
* during stage 1, whilst action 3 is carried out during stage 2 (to |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2673 |
* "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
|
2674 |
* 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
|
2675 |
* 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
|
2676 |
* in an earlier stage than associating, so... We just process actions |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2677 |
* 1 and 2 in stage 2 now, let's hope that won't get us into problems. |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2678 |
* --pasky */ |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2679 |
/* We need a pre-stage to set up GOTO labels of Action 0x10 because the grf |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2680 |
* is not in memory and scanning the file every time would be too expensive. |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2681 |
* In other stages we skip action 0x10 since it's already dealt with. */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2682 |
static const uint32 action_mask[] = {0x10000, 0x0000FB40, 0x0000FFBF}; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2683 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2684 |
static const SpecialSpriteHandler handlers[] = { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2685 |
/* 0x00 */ VehicleChangeInfo, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2686 |
/* 0x01 */ NewSpriteSet, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2687 |
/* 0x02 */ NewSpriteGroup, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2688 |
/* 0x03 */ NewVehicle_SpriteGroupMapping, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2689 |
/* 0x04 */ VehicleNewName, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2690 |
/* 0x05 */ GraphicsNew, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2691 |
/* 0x06 */ CfgApply, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2692 |
/* 0x07 */ SkipIf, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2693 |
/* 0x08 */ GRFInfo, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2694 |
/* 0x09 */ SkipIf, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2695 |
/* 0x0A */ SpriteReplace, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2696 |
/* 0x0B */ GRFError, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2697 |
/* 0x0C */ GRFComment, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2698 |
/* 0x0D */ ParamSet, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2699 |
/* 0x0E */ GRFInhibit, |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2700 |
/* 0x0F */ NULL, // TODO implement |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2701 |
/* 0x10 */ DefineGotoLabel, |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2702 |
}; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2703 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2704 |
byte* buf = malloc(num); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2705 |
byte action; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2706 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2707 |
if (buf == NULL) error("DecodeSpecialSprite: Could not allocate memory"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2708 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2709 |
FioReadBlock(buf, num); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2710 |
action = buf[0]; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2711 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2712 |
if (action >= lengthof(handlers)) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2713 |
DEBUG(grf, 7) ("Skipping unknown action 0x%02X", action); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2714 |
} else if (!HASBIT(action_mask[stage], action)) { |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2715 |
DEBUG(grf, 7) ("Skipping action 0x%02X in stage %d", action, stage); |
2645
841087328e0e
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
2716 |
} else if (handlers[action] == NULL) { |
841087328e0e
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
2717 |
DEBUG(grf, 7) ("Skipping unsupported Action 0x%02X", action); |
841087328e0e
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
2718 |
} else { |
841087328e0e
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
2719 |
DEBUG(grf, 7) ("Handling action 0x%02X in stage %d", action, stage); |
841087328e0e
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
2720 |
handlers[action](buf, num); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2721 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2722 |
free(buf); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2723 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2724 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2725 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2726 |
static void LoadNewGRFFile(const char* filename, uint file_index, uint stage) |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2727 |
{ |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2728 |
uint16 num; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2729 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2730 |
/* A .grf file is activated only if it was active when the game was |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2731 |
* started. If a game is loaded, only its active .grfs will be |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2732 |
* reactivated, unless "loadallgraphics on" is used. A .grf file is |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2733 |
* considered active if its action 8 has been processed, i.e. its |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2734 |
* action 8 hasn't been skipped using an action 7. |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2735 |
* |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2736 |
* During activation, only actions 0, 1, 2, 3, 4, 5, 7, 8, 9, 0A and 0B are |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2737 |
* carried out. All others are ignored, because they only need to be |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2738 |
* processed once at initialization. */ |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2739 |
if (stage != 0) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2740 |
_cur_grffile = GetFileByFilename(filename); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2741 |
if (_cur_grffile == NULL) error("File ``%s'' lost in cache.\n", filename); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2742 |
if (stage > 1 && !(_cur_grffile->flags & 0x0001)) return; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2743 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2744 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2745 |
FioOpenFile(file_index, filename); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2746 |
_file_index = file_index; // XXX |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2747 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2748 |
DEBUG(grf, 7) ("Reading NewGRF-file '%s'", filename); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2749 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2750 |
/* Skip the first sprite; we don't care about how many sprites this |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2751 |
* does contain; newest TTDPatches and George's longvehicles don't |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2752 |
* neither, apparently. */ |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2753 |
if (FioReadWord() == 4 && FioReadByte() == 0xFF) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2754 |
FioReadDword(); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2755 |
} else { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2756 |
error("Custom .grf has invalid format."); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2757 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2758 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2759 |
_skip_sprites = 0; // XXX |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
2760 |
_nfo_line = 0; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2761 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2762 |
while ((num = FioReadWord()) != 0) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2763 |
byte type = FioReadByte(); |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
2764 |
_nfo_line++; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2765 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2766 |
if (type == 0xFF) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2767 |
if (_skip_sprites == 0) { |
2958
ac0a9673b522
(svn r3520) Remove unused parameters from some functions
tron
parents:
2935
diff
changeset
|
2768 |
DecodeSpecialSprite(num, stage); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2769 |
continue; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2770 |
} else { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2771 |
FioSkipBytes(num); |
1611 | 2772 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2773 |
} else { |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2774 |
if (_skip_sprites == 0) DEBUG(grf, 7) ("Skipping unexpected sprite"); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2775 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2776 |
FioSkipBytes(7); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2777 |
num -= 8; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2778 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2779 |
if (type & 2) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2780 |
FioSkipBytes(num); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2781 |
} else { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2782 |
while (num > 0) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2783 |
int8 i = FioReadByte(); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2784 |
if (i >= 0) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2785 |
num -= i; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2786 |
FioSkipBytes(i); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2787 |
} else { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2788 |
i = -(i >> 3); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2789 |
num -= i; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2790 |
FioReadByte(); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2791 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2792 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2793 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2794 |
} |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2795 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2796 |
if (_skip_sprites > 0) _skip_sprites--; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2797 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2798 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2799 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2800 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2801 |
void LoadNewGRF(uint load_index, uint file_index) |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2802 |
{ |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2803 |
uint stage; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2804 |
|
2930
99088d4aba31
(svn r3486) - NewGRF fix: Always reinitialize the ttdpatch flags as patch settings may have changed.
peter1138
parents:
2895
diff
changeset
|
2805 |
InitializeGRFSpecial(); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2806 |
|
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2807 |
ResetNewGRFData(); |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
2808 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2809 |
/* Load newgrf sprites |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2810 |
* in each loading stage, (try to) open each file specified in the config |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2811 |
* and load information from it. */ |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2812 |
_custom_sprites_base = load_index; |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2813 |
for (stage = 0; stage <= 2; stage++) { |
2400
2b258097156f
(svn r2926) -Fix: Use the same file slots in both initialisation stages when loading a patch grf
tron
parents:
2346
diff
changeset
|
2814 |
uint slot = file_index; |
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2815 |
GRFConfig *c; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2816 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2817 |
_cur_stage = stage; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2818 |
_cur_spriteid = load_index; |
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2819 |
for (c = _first_grfconfig; c != NULL; c = c->next) { |
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2820 |
if (!FiosCheckFileExists(c->filename)) { |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2821 |
// TODO: usrerror() |
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2822 |
error("NewGRF file missing: %s", c->filename); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2823 |
} |
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2824 |
|
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2825 |
if (stage == 0) InitNewGRFFile(c, _cur_spriteid); |
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
2826 |
LoadNewGRFFile(c->filename, slot++, stage); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
2827 |
if (stage == 2) ClearTemporaryNewGRFData(); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2828 |
DEBUG(spritecache, 2) ("Currently %i sprites are loaded", load_index); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2829 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2830 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2831 |
|
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2832 |
// Pre-calculate all refit masks after loading GRF files |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
2833 |
CalculateRefitMasks(); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2834 |
} |