author | truebrain |
Thu, 12 Jun 2008 21:07:25 +0000 | |
branch | noai |
changeset 10943 | 5f5a5dd407d8 |
parent 10920 | e33442a2b239 |
child 10955 | 56b381e5253f |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
3 |
/** @file newgrf.cpp Base of all NewGRF support. */ |
9505 | 4 |
|
0 | 5 |
#include "stdafx.h" |
6 |
||
7 |
#include <stdarg.h> |
|
8 |
||
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1883
diff
changeset
|
9 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1183
diff
changeset
|
10 |
#include "debug.h" |
0 | 11 |
#include "fileio.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
12 |
#include "engine_func.h" |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
13 |
#include "engine_base.h" |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
14 |
#include "spritecache.h" |
405
6830ae7a0d5d
(svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents:
404
diff
changeset
|
15 |
#include "sprite.h" |
452
520e4ed6945d
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
449
diff
changeset
|
16 |
#include "newgrf.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2013
diff
changeset
|
17 |
#include "variables.h" |
2478
16b05f1de6bb
(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
|
18 |
#include "bridge.h" |
9476 | 19 |
#include "town.h" |
2962
dbd168a4703a
(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
|
20 |
#include "newgrf_engine.h" |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
21 |
#include "newgrf_text.h" |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
22 |
#include "fontcache.h" |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
23 |
#include "currency.h" |
9505 | 24 |
#include "landscape.h" |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
25 |
#include "newgrf_config.h" |
9476 | 26 |
#include "newgrf_house.h" |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
27 |
#include "newgrf_sound.h" |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
28 |
#include "newgrf_spritegroup.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
29 |
#include "newgrf_station.h" |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6416
diff
changeset
|
30 |
#include "cargotype.h" |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
31 |
#include "industry.h" |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
32 |
#include "newgrf_canal.h" |
9624 | 33 |
#include "newgrf_commons.h" |
9629 | 34 |
#include "newgrf_townname.h" |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
35 |
#include "newgrf_industries.h" |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
36 |
#include "gfxinit.h" |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
37 |
#include "rev.h" |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
38 |
#include "fios.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
39 |
#include "rail.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
40 |
#include "strings_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
41 |
#include "gfx_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
42 |
#include "date_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
43 |
#include "vehicle_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
44 |
#include "sound_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
45 |
#include "string_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
46 |
#include "road_func.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
47 |
#include "player_base.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
48 |
#include "settings_type.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
49 |
#include "map_func.h" |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
50 |
#include <map> |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
51 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
52 |
#include "table/strings.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
53 |
#include "table/sprites.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
54 |
#include "table/town_land.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
55 |
#include "table/build_industry.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
56 |
#include "table/landscape_sprite.h" |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
57 |
|
0 | 58 |
/* TTDPatch extended GRF format codec |
59 |
* (c) Petr Baudis 2004 (GPL'd) |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
60 |
* Changes by Florian octo Forster are (c) by the OpenTTD development team. |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
61 |
* |
0 | 62 |
* Contains portions of documentation by TTDPatch team. |
63 |
* Thanks especially to Josef Drexler for the documentation as well as a lot |
|
64 |
* of help at #tycoon. Also thanks to Michael Blunck for is GRF files which |
|
65 |
* served as subject to the initial testing of this codec. */ |
|
66 |
||
455 | 67 |
|
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
68 |
static int _skip_sprites; // XXX |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
69 |
static uint _file_index; // XXX |
0 | 70 |
|
2340
0a9f3eeccb96
(svn r2866) Move all functions and tables which aren't directly involved in managing the sprite heap to a new file gfxinit.c.
tron
parents:
2336
diff
changeset
|
71 |
static GRFFile *_cur_grffile; |
1477 | 72 |
GRFFile *_first_grffile; |
3707
2999a89e8abd
(svn r4650) - NewGRF: use the correct type for _cur_spriteid
peter1138
parents:
3704
diff
changeset
|
73 |
static SpriteID _cur_spriteid; |
5225
52ddcedcc6f7
(svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents:
5211
diff
changeset
|
74 |
static GrfLoadingStage _cur_stage; |
3561
29c95ab685c0
(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
|
75 |
static uint32 _nfo_line; |
0 | 76 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
77 |
static GRFConfig *_cur_grfconfig; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
78 |
|
3814
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
79 |
/* Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E */ |
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
80 |
static byte _misc_grf_features = 0; |
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
81 |
|
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
82 |
/* 32 * 8 = 256 flags. Apparently TTDPatch uses this many.. */ |
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
83 |
static uint32 _ttdpatch_flags[8]; |
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
84 |
|
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
85 |
/* Used by Action 0x06 to preload a pseudo sprite and modify its content */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
86 |
static byte *_preload_sprite = NULL; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
87 |
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
88 |
/* Indicates which are the newgrf features currently loaded ingame */ |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
89 |
GRFLoadedFeatures _loaded_newgrf_features; |
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
90 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
91 |
enum GrfDataType { |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
92 |
GDT_SOUND, |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
93 |
}; |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
94 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
95 |
static byte _grf_data_blocks; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
96 |
static GrfDataType _grf_data_type; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
97 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
98 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
99 |
typedef void (*SpecialSpriteHandler)(byte *buf, size_t len); |
0 | 100 |
|
3768
46d328178509
(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
|
101 |
enum { |
46d328178509
(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
|
102 |
MAX_STATIONS = 256, |
46d328178509
(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
|
103 |
}; |
46d328178509
(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
|
104 |
|
10355
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
105 |
/* Temporary data used when loading only */ |
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
106 |
struct GRFTempEngineData { |
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
107 |
uint16 cargo_allowed; |
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
108 |
uint16 cargo_disallowed; |
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
109 |
}; |
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
110 |
|
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
111 |
static GRFTempEngineData *_gted; |
0 | 112 |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
113 |
/* Contains the GRF ID of the owner of a vehicle if it has been reserved. |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
114 |
* GRM for vehicles is only used if dynamic engine allocation is disabled, |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
115 |
* so 256 is the number of original engines. */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
116 |
static uint32 _grm_engines[256]; |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
117 |
|
9626 | 118 |
/* Contains the GRF ID of the owner of a cargo if it has been reserved */ |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
119 |
static uint32 _grm_cargos[NUM_CARGO * 2]; |
9626 | 120 |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
121 |
struct GRFLocation { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
122 |
uint32 grfid; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
123 |
uint32 nfoline; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
124 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
125 |
GRFLocation(uint32 grfid, uint32 nfoline) : grfid(grfid), nfoline(nfoline) { } |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
126 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
127 |
bool operator<(const GRFLocation &other) const |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
128 |
{ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
129 |
return this->grfid < other.grfid || (this->grfid == other.grfid && this->nfoline < other.nfoline); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
130 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
131 |
}; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
132 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
133 |
static std::map<GRFLocation, SpriteID> _grm_sprites; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
134 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
135 |
/** DEBUG() function dedicated to newGRF debugging messages |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
136 |
* Function is essentialy the same as DEBUG(grf, severity, ...) with the |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
137 |
* addition of file:line information when parsing grf files. |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
138 |
* NOTE: for the above reason(s) grfmsg() should ONLY be used for |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
139 |
* loading/parsing grf files, not for runtime debug messages as there |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
140 |
* is no file information available during that time. |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
141 |
* @param severity debugging severity level, see debug.h |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
142 |
* @param str message in printf() format */ |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
143 |
void CDECL grfmsg(int severity, const char *str, ...) |
0 | 144 |
{ |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
51
diff
changeset
|
145 |
char buf[1024]; |
0 | 146 |
va_list va; |
147 |
||
148 |
va_start(va, str); |
|
1477 | 149 |
vsnprintf(buf, sizeof(buf), str, va); |
0 | 150 |
va_end(va); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
151 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
152 |
DEBUG(grf, severity, "[%s:%d] %s", _cur_grfconfig->filename, _nfo_line, buf); |
0 | 153 |
} |
154 |
||
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
155 |
static inline bool check_length(size_t real, size_t wanted, const char *str) |
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
156 |
{ |
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
157 |
if (real >= wanted) return true; |
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
158 |
grfmsg(0, "%s: Invalid pseudo sprite length %d (expected %d)!", str, real, wanted); |
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
159 |
return false; |
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
160 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
161 |
|
500
ef288590e096
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
490
diff
changeset
|
162 |
static inline byte grf_load_byte(byte **buf) |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
163 |
{ |
0 | 164 |
return *(*buf)++; |
165 |
} |
|
166 |
||
167 |
static uint16 grf_load_word(byte **buf) |
|
168 |
{ |
|
3711
4a0d1c635b56
(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
|
169 |
uint16 val = grf_load_byte(buf); |
4a0d1c635b56
(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 |
return val | (grf_load_byte(buf) << 8); |
0 | 171 |
} |
172 |
||
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
173 |
static uint16 grf_load_extended(byte** buf) |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
174 |
{ |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
175 |
uint16 val; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
176 |
val = grf_load_byte(buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
177 |
if (val == 0xFF) val = grf_load_word(buf); |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
178 |
return val; |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
179 |
} |
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
180 |
|
2324 | 181 |
static uint32 grf_load_dword(byte **buf) |
0 | 182 |
{ |
3711
4a0d1c635b56
(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
|
183 |
uint32 val = grf_load_word(buf); |
4a0d1c635b56
(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
|
184 |
return val | (grf_load_word(buf) << 16); |
0 | 185 |
} |
186 |
||
3668
d7ed0a867b49
(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
|
187 |
static uint32 grf_load_var(byte size, byte **buf) |
d7ed0a867b49
(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
|
188 |
{ |
d7ed0a867b49
(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
|
189 |
switch (size) { |
d7ed0a867b49
(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
|
190 |
case 1: return grf_load_byte(buf); |
d7ed0a867b49
(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
|
191 |
case 2: return grf_load_word(buf); |
d7ed0a867b49
(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
|
192 |
case 4: return grf_load_dword(buf); |
d7ed0a867b49
(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
|
193 |
default: |
d7ed0a867b49
(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
|
194 |
NOT_REACHED(); |
d7ed0a867b49
(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
|
195 |
return 0; |
d7ed0a867b49
(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
|
196 |
} |
d7ed0a867b49
(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
|
197 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
198 |
|
6416
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
199 |
static const char *grf_load_string(byte **buf, size_t max_len) |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
200 |
{ |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
201 |
const char *string = *(const char **)buf; |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
202 |
size_t string_length = ttd_strnlen(string, max_len); |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
203 |
|
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
204 |
if (string_length == max_len) { |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
205 |
/* String was not NUL terminated, so make sure it is now. */ |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
206 |
(*buf)[string_length - 1] = '\0'; |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
207 |
grfmsg(7, "String was not terminated with a zero byte."); |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
208 |
} else { |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
209 |
/* Increase the string length to include the NUL byte. */ |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
210 |
string_length++; |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
211 |
} |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
212 |
*buf += string_length; |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
213 |
|
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
214 |
return string; |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
215 |
} |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
216 |
|
1477 | 217 |
static GRFFile *GetFileByGRFID(uint32 grfid) |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
218 |
{ |
1477 | 219 |
GRFFile *file; |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
220 |
|
1477 | 221 |
for (file = _first_grffile; file != NULL; file = file->next) { |
222 |
if (file->grfid == grfid) break; |
|
223 |
} |
|
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
224 |
return file; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
225 |
} |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
226 |
|
1477 | 227 |
static GRFFile *GetFileByFilename(const char *filename) |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
228 |
{ |
1477 | 229 |
GRFFile *file; |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
230 |
|
1477 | 231 |
for (file = _first_grffile; file != NULL; file = file->next) { |
232 |
if (strcmp(file->filename, filename) == 0) break; |
|
233 |
} |
|
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
234 |
return file; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
235 |
} |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
236 |
|
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
237 |
|
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
238 |
typedef std::map<StringID *, uint32> StringIDToGRFIDMapping; |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
239 |
StringIDToGRFIDMapping _string_to_grf_mapping; |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
240 |
|
9476 | 241 |
/** Used when setting an object's property to map to the GRF's strings |
242 |
* while taking in consideration the "drift" between TTDPatch string system and OpenTTD's one |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
243 |
* @param grfid Id of the grf file |
9476 | 244 |
* @param str StringID that we want to have the equivalent in OoenTTD |
245 |
* @return the properly adjusted StringID |
|
246 |
*/ |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
247 |
StringID MapGRFStringID(uint32 grfid, StringID str) |
9476 | 248 |
{ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
249 |
/* StringID table for TextIDs 0x4E->0x6D */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
250 |
static StringID units_volume[] = { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
251 |
STR_NOTHING, STR_PASSENGERS, STR_TONS, STR_BAGS, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
252 |
STR_LITERS, STR_ITEMS, STR_CRATES, STR_TONS, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
253 |
STR_TONS, STR_TONS, STR_TONS, STR_BAGS, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
254 |
STR_TONS, STR_TONS, STR_TONS, STR_BAGS, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
255 |
STR_TONS, STR_TONS, STR_BAGS, STR_LITERS, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
256 |
STR_TONS, STR_LITERS, STR_TONS, STR_NOTHING, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
257 |
STR_BAGS, STR_LITERS, STR_TONS, STR_NOTHING, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
258 |
STR_TONS, STR_NOTHING, STR_LITERS, STR_NOTHING |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
259 |
}; |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
260 |
|
9476 | 261 |
/* 0xD0 and 0xDC stand for all the TextIDs in the range |
9505 | 262 |
* of 0xD000 (misc graphics texts) and 0xDC00 (misc persistent texts). |
9476 | 263 |
* These strings are unique to each grf file, and thus require to be used with the |
264 |
* grfid in which they are declared */ |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
265 |
switch (GB(str, 8, 8)) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
266 |
case 0xD0: case 0xD1: case 0xD2: case 0xD3: |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
267 |
case 0xDC: |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
268 |
return GetGRFStringID(grfid, str); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
269 |
|
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
270 |
case 0xD4: case 0xD5: case 0xD6: case 0xD7: |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
271 |
/* Strings embedded via 0x81 have 0x400 added to them (no real |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
272 |
* explanation why...) */ |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
273 |
return GetGRFStringID(grfid, str - 0x400); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
274 |
|
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
275 |
default: break; |
9476 | 276 |
} |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
277 |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
278 |
#define TEXID_TO_STRINGID(begin, end, stringid) if (str >= begin && str <= end) return str + (stringid - begin) |
9517 | 279 |
/* We have some changes in our cargo strings, resulting in some missing. */ |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
280 |
TEXID_TO_STRINGID(0x000E, 0x002D, STR_000E); |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
281 |
TEXID_TO_STRINGID(0x002E, 0x004D, STR_002E); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
282 |
if (str >= 0x004E && str <= 0x006D) str = units_volume[str - 0x004E]; |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
283 |
TEXID_TO_STRINGID(0x006E, 0x008D, STR_QUANTITY_NOTHING); |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
284 |
TEXID_TO_STRINGID(0x008E, 0x00AD, STR_ABBREV_NOTHING); |
9517 | 285 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
286 |
/* Map building names according to our lang file changes. There are several |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
287 |
* ranges of house ids, all of which need to be remapped to allow newgrfs |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
288 |
* to use original house names. */ |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
289 |
TEXID_TO_STRINGID(0x200F, 0x201F, STR_200F_TALL_OFFICE_BLOCK); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
290 |
TEXID_TO_STRINGID(0x2036, 0x2041, STR_2036_COTTAGES); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
291 |
TEXID_TO_STRINGID(0x2059, 0x205C, STR_2059_IGLOO); |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
292 |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
293 |
/* Same thing for industries, since the introduction of 4 new strings above STR_482A_PRODUCTION_LAST_MONTH */ |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
294 |
TEXID_TO_STRINGID(0x482A, 0x483B, STR_482A_PRODUCTION_LAST_MONTH); |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
295 |
#undef TEXTID_TO_STRINGID |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
296 |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
297 |
if (str == STR_NULL) return STR_EMPTY; |
9476 | 298 |
|
299 |
return str; |
|
300 |
} |
|
301 |
||
9545 | 302 |
static uint8 MapDOSColour(uint8 colour) |
303 |
{ |
|
304 |
if (_use_dos_palette) return colour; |
|
305 |
||
306 |
if (colour < 10) { |
|
307 |
static uint8 dos_to_win_colour_map[] = { 0, 215, 216, 136, 88, 106, 32, 33, 40, 245 }; |
|
308 |
return dos_to_win_colour_map[colour]; |
|
309 |
} |
|
310 |
||
311 |
if (colour >= 245 && colour < 254) return colour - 28; |
|
312 |
||
313 |
return colour; |
|
314 |
} |
|
315 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
316 |
static std::map<uint32, uint32> _grf_id_overrides; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
317 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
318 |
static void SetNewGRFOverride(uint32 source_grfid, uint32 target_grfid) |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
319 |
{ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
320 |
_grf_id_overrides[source_grfid] = target_grfid; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
321 |
grfmsg(5, "SetNewGRFOverride: Added override of 0x%X to 0x%X", BSWAP32(source_grfid), BSWAP32(target_grfid)); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
322 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
323 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
324 |
static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 internal_id) |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
325 |
{ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
326 |
/* Hack for add-on GRFs that need to modify another GRF's engines. This lets |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
327 |
* them use the same engine slots. */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
328 |
const GRFFile *grf_match = NULL; |
10776 | 329 |
if (_settings_game.vehicle.dynamic_engines) { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
330 |
uint32 override = _grf_id_overrides[file->grfid]; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
331 |
if (override != 0) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
332 |
grf_match = GetFileByGRFID(override); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
333 |
if (grf_match == NULL) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
334 |
grfmsg(5, "Tried mapping from GRFID %x to %x but target is not loaded", BSWAP32(file->grfid), BSWAP32(override)); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
335 |
} else { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
336 |
grfmsg(5, "Mapping from GRFID %x to %x", BSWAP32(file->grfid), BSWAP32(override)); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
337 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
338 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
339 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
340 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
341 |
/* Check if this vehicle is already defined... */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
342 |
Engine *e = NULL; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
343 |
FOR_ALL_ENGINES(e) { |
10776 | 344 |
if (_settings_game.vehicle.dynamic_engines && e->grffile != NULL && e->grffile != file && e->grffile != grf_match) continue; |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
345 |
if (e->type != type) continue; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
346 |
if (e->internal_id != internal_id) continue; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
347 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
348 |
if (e->grffile == NULL) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
349 |
e->grffile = file; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
350 |
grfmsg(5, "Replaced engine at index %d for GRFID %x, type %d, index %d", e->index, BSWAP32(file->grfid), type, internal_id); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
351 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
352 |
return e; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
353 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
354 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
355 |
uint engine_pool_size = GetEnginePoolSize(); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
356 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
357 |
/* ... it's not, so create a new one based off an existing engine */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
358 |
e = new Engine(type, internal_id); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
359 |
e->grffile = file; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
360 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
361 |
if (engine_pool_size != GetEnginePoolSize()) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
362 |
/* Resize temporary engine data ... */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
363 |
_gted = ReallocT(_gted, GetEnginePoolSize()); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
364 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
365 |
/* and blank the new block. */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
366 |
size_t len = (GetEnginePoolSize() - engine_pool_size) * sizeof(*_gted); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
367 |
memset(_gted + engine_pool_size, 0, len); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
368 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
369 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
370 |
grfmsg(5, "Created new engine at index %d for GRFID %x, type %d, index %d", e->index, BSWAP32(file->grfid), type, internal_id); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
371 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
372 |
return e; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
373 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
374 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
375 |
EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id) |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
376 |
{ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
377 |
extern uint32 GetNewGRFOverride(uint32 grfid); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
378 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
379 |
const GRFFile *grf_match = NULL; |
10776 | 380 |
if (_settings_game.vehicle.dynamic_engines) { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
381 |
uint32 override = _grf_id_overrides[file->grfid]; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
382 |
if (override != 0) grf_match = GetFileByGRFID(override); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
383 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
384 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
385 |
const Engine *e = NULL; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
386 |
FOR_ALL_ENGINES(e) { |
10776 | 387 |
if (_settings_game.vehicle.dynamic_engines && e->grffile != file && (grf_match == NULL || e->grffile != grf_match)) continue; |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
388 |
if (e->type != type) continue; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
389 |
if (e->internal_id != internal_id) continue; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
390 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
391 |
return e->index; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
392 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
393 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
394 |
return INVALID_ENGINE; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
395 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
396 |
|
9732 | 397 |
/** Map the colour modifiers of TTDPatch to those that Open is using. |
398 |
* @param grf_sprite pointer to the structure been modified |
|
399 |
*/ |
|
400 |
static void MapSpriteMappingRecolour(PalSpriteID *grf_sprite) |
|
401 |
{ |
|
402 |
if (HasBit(grf_sprite->pal, 14)) { |
|
403 |
ClrBit(grf_sprite->pal, 14); |
|
404 |
SetBit(grf_sprite->sprite, SPRITE_MODIFIER_OPAQUE); |
|
405 |
} |
|
406 |
||
407 |
if (HasBit(grf_sprite->sprite, 14)) { |
|
408 |
ClrBit(grf_sprite->sprite, 14); |
|
409 |
SetBit(grf_sprite->sprite, PALETTE_MODIFIER_TRANSPARENT); |
|
410 |
} |
|
411 |
||
412 |
if (HasBit(grf_sprite->sprite, 15)) { |
|
413 |
ClrBit(grf_sprite->sprite, 15); |
|
414 |
SetBit(grf_sprite->sprite, PALETTE_MODIFIER_COLOR); |
|
415 |
} |
|
416 |
} |
|
9476 | 417 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
418 |
typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); |
0 | 419 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
420 |
static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 421 |
{ |
422 |
byte *buf = *bufp; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
423 |
bool ret = false; |
0 | 424 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
425 |
for (int i = 0; i < numinfo; i++) { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
426 |
Engine *e = GetNewEngine(_cur_grffile, VEH_TRAIN, engine + i); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
427 |
EngineInfo *ei = &e->info; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
428 |
RailVehicleInfo *rvi = &e->u.rail; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
429 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
430 |
switch (prop) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
431 |
case 0x05: { // Track type |
0 | 432 |
uint8 tracktype = grf_load_byte(&buf); |
433 |
||
3026
6401a6942660
(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
|
434 |
switch (tracktype) { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
435 |
case 0: rvi->railtype = rvi->engclass >= 2 ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
436 |
case 1: rvi->railtype = RAILTYPE_MONO; break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
437 |
case 2: rvi->railtype = RAILTYPE_MAGLEV; break; |
3026
6401a6942660
(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
|
438 |
default: |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
439 |
grfmsg(1, "RailVehicleChangeInfo: Invalid track type %d specified, ignoring", tracktype); |
3026
6401a6942660
(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
|
440 |
break; |
6401a6942660
(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
|
441 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
442 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
443 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
444 |
case 0x08: // AI passenger service |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
445 |
/* Tells the AI that this engine is designed for |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
446 |
* passenger services and shouldn't be used for freight. */ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
447 |
rvi->ai_passenger_only = grf_load_byte(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
448 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
449 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
450 |
case 0x09: { // Speed (1 unit is 1 kmh) |
0 | 451 |
uint16 speed = grf_load_word(&buf); |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
452 |
if (speed == 0xFFFF) speed = 0; |
0 | 453 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
454 |
rvi->max_speed = speed; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
455 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
456 |
|
10645 | 457 |
case 0x0B: // Power |
458 |
rvi->power = grf_load_word(&buf); |
|
10867
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
459 |
|
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
460 |
/* Set engine / wagon state based on power */ |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
461 |
if (rvi->power != 0) { |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
462 |
if (rvi->railveh_type == RAILVEH_WAGON) { |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
463 |
rvi->railveh_type = RAILVEH_SINGLEHEAD; |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
464 |
} |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
465 |
} else { |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
466 |
rvi->railveh_type = RAILVEH_WAGON; |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
467 |
} |
10645 | 468 |
break; |
469 |
||
470 |
case 0x0D: // Running cost factor |
|
471 |
rvi->running_cost = grf_load_byte(&buf); |
|
472 |
break; |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
473 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
474 |
case 0x0E: { // Running cost base |
0 | 475 |
uint32 base = grf_load_dword(&buf); |
476 |
||
9732 | 477 |
/* These magic numbers are used in GRFs to specify the base cost: |
478 |
* http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts |
|
479 |
*/ |
|
480 |
if (base == 0) { |
|
481 |
rvi->running_cost_class = 0xFF; |
|
482 |
} else if (base < 0x4B34 || base > 0x4C54 || (base - 0x4B34) % 6 != 0) { |
|
483 |
grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base); |
|
484 |
} else { |
|
485 |
/* Convert the magic number to an index into the price data */ |
|
486 |
rvi->running_cost_class = (base - 0x4B34) / 6; |
|
0 | 487 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
488 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
489 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
490 |
case 0x12: { // Sprite ID |
0 | 491 |
uint8 spriteid = grf_load_byte(&buf); |
492 |
||
2895
943612f25754
(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
|
493 |
/* TTD sprite IDs point to a location in a 16bit array, but we use it |
943612f25754
(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
|
494 |
* as an array index, so we need it to be half the original value. */ |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
495 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
943612f25754
(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
|
496 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
497 |
rvi->image_index = spriteid; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
498 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
499 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
500 |
case 0x13: { // Dual-headed |
0 | 501 |
uint8 dual = grf_load_byte(&buf); |
502 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
503 |
if (dual != 0) { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
504 |
rvi->railveh_type = RAILVEH_MULTIHEAD; |
0 | 505 |
} else { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
506 |
rvi->railveh_type = rvi->power == 0 ? |
6126
40a18030c3aa
(svn r8465) -Regression (r8455): Switching from dual to single head should switch to wagon if power is zero. .Or something.
peter1138
parents:
6119
diff
changeset
|
507 |
RAILVEH_WAGON : RAILVEH_SINGLEHEAD; |
0 | 508 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
509 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
510 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
511 |
case 0x14: // Cargo capacity |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
512 |
rvi->capacity = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
513 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
514 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
515 |
case 0x15: { // Cargo type |
0 | 516 |
uint8 ctype = grf_load_byte(&buf); |
517 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
518 |
if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
519 |
rvi->cargo_type = ctype; |
2846
ac8731dd4121
(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
|
520 |
} else { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
521 |
rvi->cargo_type = CT_INVALID; |
6468
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
522 |
grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, using first refittable", ctype); |
2846
ac8731dd4121
(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
|
523 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
524 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
525 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
526 |
case 0x16: // Weight |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
527 |
SB(rvi->weight, 0, 8, grf_load_byte(&buf)); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
528 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
529 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
530 |
case 0x17: // Cost factor |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
531 |
rvi->base_cost = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
532 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
533 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
534 |
case 0x18: // AI rank |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
535 |
rvi->ai_rank = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
536 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
537 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
538 |
case 0x19: { // Engine traction type |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
539 |
/* What do the individual numbers mean? |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
540 |
* 0x00 .. 0x07: Steam |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
541 |
* 0x08 .. 0x27: Diesel |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
542 |
* 0x28 .. 0x31: Electric |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
543 |
* 0x32 .. 0x37: Monorail |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
544 |
* 0x38 .. 0x41: Maglev |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
545 |
*/ |
0 | 546 |
uint8 traction = grf_load_byte(&buf); |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
547 |
EngineClass engclass; |
0 | 548 |
|
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
549 |
if (traction <= 0x07) { |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
550 |
engclass = EC_STEAM; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
551 |
} else if (traction <= 0x27) { |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
552 |
engclass = EC_DIESEL; |
3355
a653b8e47f27
(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
|
553 |
} else if (traction <= 0x31) { |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
554 |
engclass = EC_ELECTRIC; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
555 |
} else if (traction <= 0x37) { |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
556 |
engclass = EC_MONORAIL; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
557 |
} else if (traction <= 0x41) { |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
558 |
engclass = EC_MAGLEV; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
559 |
} else { |
0 | 560 |
break; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
561 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
562 |
if (rvi->railtype == RAILTYPE_RAIL && engclass >= EC_ELECTRIC) rvi->railtype = RAILTYPE_ELECTRIC; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
563 |
if (rvi->railtype == RAILTYPE_ELECTRIC && engclass < EC_ELECTRIC) rvi->railtype = RAILTYPE_RAIL; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
564 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
565 |
rvi->engclass = engclass; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
566 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
567 |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
568 |
case 0x1A: // Alter purchase list sort order |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
569 |
AlterRailVehListOrder(e->index, grf_load_byte(&buf)); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
570 |
break; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
571 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
572 |
case 0x1B: // Powered wagons power bonus |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
573 |
rvi->pow_wag_power = grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
574 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
575 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
576 |
case 0x1C: // Refit cost |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
577 |
ei->refit_cost = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
578 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
579 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
580 |
case 0x1D: // Refit cargo |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
581 |
ei->refit_mask = grf_load_dword(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
582 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
583 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
584 |
case 0x1E: // Callback |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
585 |
ei->callbackmask = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
586 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
587 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
588 |
case 0x1F: // Tractive effort coefficient |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
589 |
rvi->tractive_effort = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
590 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
591 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
592 |
case 0x20: // Air drag |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
593 |
/** @todo Air drag for trains. */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
594 |
grf_load_byte(&buf); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
595 |
ret = true; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
596 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
597 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
598 |
case 0x21: // Shorter vehicle |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
599 |
rvi->shorten_factor = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
600 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
601 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
602 |
case 0x22: // Visual effect |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
603 |
/** @see note in engine.h about rvi->visual_effect */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
604 |
rvi->visual_effect = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
605 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
606 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
607 |
case 0x23: // Powered wagons weight bonus |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
608 |
rvi->pow_wag_weight = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
609 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
610 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
611 |
case 0x24: { // High byte of vehicle weight |
2542
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
612 |
byte weight = grf_load_byte(&buf); |
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
613 |
|
2545
d1965652e523
(svn r3074) -NewGrf: Fix stupid typo in weight setting.
peter1138
parents:
2542
diff
changeset
|
614 |
if (weight > 4) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
615 |
grfmsg(2, "RailVehicleChangeInfo: Nonsensical weight of %d tons, ignoring", weight << 8); |
2542
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
616 |
} else { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
617 |
SB(rvi->weight, 8, 8, weight); |
2542
fdea27216e48
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
618 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
619 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
620 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
621 |
case 0x25: // User-defined bit mask to set when checking veh. var. 42 |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
622 |
rvi->user_def_data = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
623 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
624 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
625 |
case 0x26: // Retire vehicle early |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
626 |
ei->retire_early = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
627 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
628 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
629 |
case 0x27: // Miscellaneous flags |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
630 |
ei->misc_flags = grf_load_byte(&buf); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
631 |
_loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
632 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
633 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
634 |
case 0x28: // Cargo classes allowed |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
635 |
_gted[e->index].cargo_allowed = grf_load_word(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
636 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
637 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
638 |
case 0x29: // Cargo classes disallowed |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
639 |
_gted[e->index].cargo_disallowed = grf_load_word(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
640 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
641 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
642 |
case 0x2A: // Long format introduction date (days since year 0) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
643 |
ei->base_intro = grf_load_dword(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
644 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
645 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
646 |
default: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
647 |
ret = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
648 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
649 |
} |
0 | 650 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
651 |
|
0 | 652 |
*bufp = buf; |
653 |
return ret; |
|
654 |
} |
|
655 |
||
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
656 |
static bool RoadVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
657 |
{ |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
658 |
byte *buf = *bufp; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
659 |
bool ret = false; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
660 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
661 |
for (int i = 0; i < numinfo; i++) { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
662 |
Engine *e = GetNewEngine(_cur_grffile, VEH_ROAD, engine + i); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
663 |
EngineInfo *ei = &e->info; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
664 |
RoadVehicleInfo *rvi = &e->u.road; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
665 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
666 |
switch (prop) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
667 |
case 0x08: // Speed (1 unit is 0.5 kmh) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
668 |
rvi->max_speed = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
669 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
670 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
671 |
case 0x09: // Running cost factor |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
672 |
rvi->running_cost = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
673 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
674 |
|
9732 | 675 |
case 0x0A: { // Running cost base |
676 |
uint32 base= grf_load_dword(&buf); |
|
677 |
||
678 |
/* These magic numbers are used in GRFs to specify the base cost: |
|
679 |
* http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts |
|
680 |
*/ |
|
681 |
if (base == 0) { |
|
682 |
rvi->running_cost_class = 0xFF; |
|
683 |
} else if (base < 0x4B34 || base > 0x4C54 || (base - 0x4B34) % 6 != 0) { |
|
684 |
grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base); |
|
685 |
} else { |
|
686 |
/* Convert the magic number to an index into the price data */ |
|
687 |
rvi->running_cost_class = (base - 0x4B34) / 6; |
|
688 |
} |
|
689 |
||
690 |
break; |
|
691 |
} |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
692 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
693 |
case 0x0E: { // Sprite ID |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
694 |
uint8 spriteid = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
695 |
|
9505 | 696 |
/* cars have different custom id in the GRF file */ |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
697 |
if (spriteid == 0xFF) spriteid = 0xFD; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
698 |
|
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
699 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
943612f25754
(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
|
700 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
701 |
rvi->image_index = spriteid; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
702 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
703 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
704 |
case 0x0F: // Cargo capacity |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
705 |
rvi->capacity = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
706 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
707 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
708 |
case 0x10: { // Cargo type |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
709 |
uint8 cargo = grf_load_byte(&buf); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
710 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
711 |
if (cargo < NUM_CARGO && HasBit(_cargo_mask, cargo)) { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
712 |
rvi->cargo_type = cargo; |
2846
ac8731dd4121
(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
|
713 |
} else { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
714 |
rvi->cargo_type = CT_INVALID; |
6468
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
715 |
grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); |
2846
ac8731dd4121
(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
|
716 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
717 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
718 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
719 |
case 0x11: // Cost factor |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
720 |
rvi->base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
721 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
722 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
723 |
case 0x12: // SFX |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
724 |
rvi->sfx = (SoundFx)grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
725 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
726 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
727 |
case 0x13: // Power in 10hp |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
728 |
case 0x14: // Weight in 1/4 tons |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
729 |
case 0x15: // Speed in mph*0.8 |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
730 |
/** @todo Support for road vehicles realistic power |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
731 |
* computations (called rvpower in TTDPatch) is just |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
732 |
* missing in OTTD yet. --pasky */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
733 |
grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
734 |
ret = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
735 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
736 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
737 |
case 0x16: // Cargos available for refitting |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
738 |
ei->refit_mask = grf_load_dword(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
739 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
740 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
741 |
case 0x17: // Callback mask |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
742 |
ei->callbackmask = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
743 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
744 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
745 |
case 0x18: // Tractive effort |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
746 |
case 0x19: // Air drag |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
747 |
/** @todo Tractive effort and air drag for road vehicles. */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
748 |
grf_load_byte(&buf); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
749 |
ret = true; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
750 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
751 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
752 |
case 0x1A: // Refit cost |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
753 |
ei->refit_cost = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
754 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
755 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
756 |
case 0x1B: // Retire vehicle early |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
757 |
ei->retire_early = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
758 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
759 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
760 |
case 0x1C: // Miscellaneous flags |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
761 |
ei->misc_flags = grf_load_byte(&buf); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
762 |
_loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
763 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
764 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
765 |
case 0x1D: // Cargo classes allowed |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
766 |
_gted[e->index].cargo_allowed = grf_load_word(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
767 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
768 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
769 |
case 0x1E: // Cargo classes disallowed |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
770 |
_gted[e->index].cargo_disallowed = grf_load_word(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
771 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
772 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
773 |
case 0x1F: // Long format introduction date (days since year 0) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
774 |
ei->base_intro = grf_load_dword(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
775 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
776 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
777 |
default: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
778 |
ret = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
779 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
780 |
} |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
781 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
782 |
|
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
783 |
*bufp = buf; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
784 |
return ret; |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
785 |
} |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
786 |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
787 |
static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
0 | 788 |
{ |
789 |
byte *buf = *bufp; |
|
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
790 |
bool ret = false; |
0 | 791 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
792 |
for (int i = 0; i < numinfo; i++) { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
793 |
Engine *e = GetNewEngine(_cur_grffile, VEH_SHIP, engine + i); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
794 |
EngineInfo *ei = &e->info; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
795 |
ShipVehicleInfo *svi = &e->u.ship; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
796 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
797 |
switch (prop) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
798 |
case 0x08: { // Sprite ID |
0 | 799 |
uint8 spriteid = grf_load_byte(&buf); |
800 |
||
9505 | 801 |
/* ships have different custom id in the GRF file */ |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
802 |
if (spriteid == 0xFF) spriteid = 0xFD; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
803 |
|
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
804 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
943612f25754
(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
|
805 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
806 |
svi->image_index = spriteid; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
807 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
808 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
809 |
case 0x09: // Refittable |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
810 |
svi->refittable = (grf_load_byte(&buf) != 0); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
811 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
812 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
813 |
case 0x0A: // Cost factor |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
814 |
svi->base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
815 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
816 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
817 |
case 0x0B: // Speed (1 unit is 0.5 kmh) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
818 |
svi->max_speed = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
819 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
820 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
821 |
case 0x0C: { // Cargo type |
0 | 822 |
uint8 cargo = grf_load_byte(&buf); |
823 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
824 |
if (cargo < NUM_CARGO && HasBit(_cargo_mask, cargo)) { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
825 |
svi->cargo_type = cargo; |
2846
ac8731dd4121
(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
|
826 |
} else { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
827 |
svi->cargo_type = CT_INVALID; |
6468
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
828 |
grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); |
2846
ac8731dd4121
(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
|
829 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
830 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
831 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
832 |
case 0x0D: // Cargo capacity |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
833 |
svi->capacity = grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
834 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
835 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
836 |
case 0x0F: // Running cost factor |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
837 |
svi->running_cost = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
838 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
839 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
840 |
case 0x10: // SFX |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
841 |
svi->sfx = (SoundFx)grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
842 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
843 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
844 |
case 0x11: // Cargos available for refitting |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
845 |
ei->refit_mask = grf_load_dword(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
846 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
847 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
848 |
case 0x12: // Callback mask |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
849 |
ei->callbackmask = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
850 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
851 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
852 |
case 0x13: // Refit cost |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
853 |
ei->refit_cost = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
854 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
855 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
856 |
case 0x14: // Ocean speed fraction |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
857 |
case 0x15: // Canal speed fraction |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
858 |
/** @todo Speed fractions for ships on oceans and canals */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
859 |
grf_load_byte(&buf); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
860 |
ret = true; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
861 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
862 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
863 |
case 0x16: // Retire vehicle early |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
864 |
ei->retire_early = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
865 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
866 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
867 |
case 0x17: // Miscellaneous flags |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
868 |
ei->misc_flags = grf_load_byte(&buf); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
869 |
_loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
870 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
871 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
872 |
case 0x18: // Cargo classes allowed |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
873 |
_gted[e->index].cargo_allowed = grf_load_word(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
874 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
875 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
876 |
case 0x19: // Cargo classes disallowed |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
877 |
_gted[e->index].cargo_disallowed = grf_load_word(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
878 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
879 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
880 |
case 0x1A: // Long format introduction date (days since year 0) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
881 |
ei->base_intro = grf_load_dword(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
882 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
883 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
884 |
default: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
885 |
ret = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
886 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
887 |
} |
0 | 888 |
} |
889 |
||
890 |
*bufp = buf; |
|
891 |
return ret; |
|
892 |
} |
|
893 |
||
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
894 |
static bool AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
895 |
{ |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
896 |
byte *buf = *bufp; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
897 |
bool ret = false; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
898 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
899 |
for (int i = 0; i < numinfo; i++) { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
900 |
Engine *e = GetNewEngine(_cur_grffile, VEH_AIRCRAFT, engine + i); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
901 |
EngineInfo *ei = &e->info; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
902 |
AircraftVehicleInfo *avi = &e->u.air; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
903 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
904 |
switch (prop) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
905 |
case 0x08: { // Sprite ID |
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
906 |
uint8 spriteid = grf_load_byte(&buf); |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
907 |
|
9505 | 908 |
/* aircraft have different custom id in the GRF file */ |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
909 |
if (spriteid == 0xFF) spriteid = 0xFD; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
910 |
|
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
911 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
943612f25754
(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
|
912 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
913 |
avi->image_index = spriteid; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
914 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
915 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
916 |
case 0x09: // Helicopter |
4926
f67f27fb122f
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
917 |
if (grf_load_byte(&buf) == 0) { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
918 |
avi->subtype = AIR_HELI; |
4926
f67f27fb122f
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
919 |
} else { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
920 |
SB(avi->subtype, 0, 1, 1); // AIR_CTOL |
4926
f67f27fb122f
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
921 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
922 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
923 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
924 |
case 0x0A: // Large |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
925 |
SB(avi->subtype, 1, 1, (grf_load_byte(&buf) != 0 ? 1 : 0)); // AIR_FAST |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
926 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
927 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
928 |
case 0x0B: // Cost factor |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
929 |
avi->base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
930 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
931 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
932 |
case 0x0C: // Speed (1 unit is 8 mph, we translate to 1 unit is 1 km/h) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
933 |
avi->max_speed = (grf_load_byte(&buf) * 129) / 10; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
934 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
935 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
936 |
case 0x0D: // Acceleration |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
937 |
avi->acceleration = (grf_load_byte(&buf) * 129) / 10; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
938 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
939 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
940 |
case 0x0E: // Running cost factor |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
941 |
avi->running_cost = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
942 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
943 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
944 |
case 0x0F: // Passenger capacity |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
945 |
avi->passenger_capacity = grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
946 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
947 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
948 |
case 0x11: // Mail capacity |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
949 |
avi->mail_capacity = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
950 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
951 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
952 |
case 0x12: // SFX |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
953 |
avi->sfx = (SoundFx)grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
954 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
955 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
956 |
case 0x13: // Cargos available for refitting |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
957 |
ei->refit_mask = grf_load_dword(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
958 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
959 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
960 |
case 0x14: // Callback mask |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
961 |
ei->callbackmask = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
962 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
963 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
964 |
case 0x15: // Refit cost |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
965 |
ei->refit_cost = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
966 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
967 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
968 |
case 0x16: // Retire vehicle early |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
969 |
ei->retire_early = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
970 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
971 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
972 |
case 0x17: // Miscellaneous flags |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
973 |
ei->misc_flags = grf_load_byte(&buf); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
974 |
_loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
975 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
976 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
977 |
case 0x18: // Cargo classes allowed |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
978 |
_gted[e->index].cargo_allowed = grf_load_word(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
979 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
980 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
981 |
case 0x19: // Cargo classes disallowed |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
982 |
_gted[e->index].cargo_disallowed = grf_load_word(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
983 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
984 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
985 |
case 0x1A: // Long format introduction date (days since year 0) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
986 |
ei->base_intro = grf_load_dword(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
987 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
988 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
989 |
default: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
990 |
ret = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
991 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
992 |
} |
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
993 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
994 |
|
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
995 |
*bufp = buf; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
996 |
return ret; |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
997 |
} |
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
379
diff
changeset
|
998 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
999 |
static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int len) |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1000 |
{ |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1001 |
byte *buf = *bufp; |
3505
e9a3a6b79561
(svn r4356) - NewGRF: Load more newstation properties.
peter1138
parents:
3504
diff
changeset
|
1002 |
bool ret = false; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1003 |
|
3768
46d328178509
(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
|
1004 |
if (stid + numinfo > MAX_STATIONS) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1005 |
grfmsg(1, "StationChangeInfo: Station %u is invalid, max %u, ignoring", stid + numinfo, MAX_STATIONS); |
3768
46d328178509
(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
|
1006 |
return false; |
46d328178509
(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
|
1007 |
} |
46d328178509
(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
|
1008 |
|
3501
cf7d2c33e7fc
(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
|
1009 |
/* Allocate station specs if necessary */ |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
1010 |
if (_cur_grffile->stations == NULL) _cur_grffile->stations = CallocT<StationSpec*>(MAX_STATIONS); |
3768
46d328178509
(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
|
1011 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1012 |
for (int i = 0; i < numinfo; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1013 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1014 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1015 |
/* Check that the station we are modifying is defined. */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1016 |
if (statspec == NULL && prop != 0x08) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1017 |
grfmsg(2, "StationChangeInfo: Attempt to modify undefined station %u, ignoring", stid + i); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1018 |
continue; |
3501
cf7d2c33e7fc
(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
|
1019 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1020 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1021 |
switch (prop) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1022 |
case 0x08: { // Class ID |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1023 |
StationSpec **spec = &_cur_grffile->stations[stid + i]; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1024 |
|
3768
46d328178509
(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
|
1025 |
/* Property 0x08 is special; it is where the station is allocated */ |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1026 |
if (*spec == NULL) *spec = CallocT<StationSpec>(1); |
3768
46d328178509
(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
|
1027 |
|
3711
4a0d1c635b56
(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
|
1028 |
/* Swap classid because we read it in BE meaning WAYP or DFLT */ |
6607 | 1029 |
uint32 classid = grf_load_dword(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1030 |
(*spec)->sclass = AllocateStationClass(BSWAP32(classid)); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1031 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1032 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1033 |
case 0x09: // Define sprite layout |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1034 |
statspec->tiles = grf_load_extended(&buf); |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
1035 |
statspec->renderdata = CallocT<DrawTileSprites>(statspec->tiles); |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
1036 |
statspec->copied_renderdata = false; |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
1037 |
|
6607 | 1038 |
for (uint t = 0; t < statspec->tiles; t++) { |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1039 |
DrawTileSprites *dts = &statspec->renderdata[t]; |
3570
f9749bae861e
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
1040 |
uint seq_count = 0; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
1041 |
|
3737
26341085bbbf
(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
|
1042 |
dts->seq = NULL; |
9732 | 1043 |
dts->ground.sprite = grf_load_word(&buf); |
1044 |
dts->ground.pal = grf_load_word(&buf); |
|
1045 |
if (dts->ground.sprite == 0) continue; |
|
1046 |
if (HasBit(dts->ground.pal, 15)) { |
|
1047 |
ClrBit(dts->ground.pal, 15); |
|
1048 |
SetBit(dts->ground.sprite, SPRITE_MODIFIER_USE_OFFSET); |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5868
diff
changeset
|
1049 |
} |
9732 | 1050 |
|
1051 |
MapSpriteMappingRecolour(&dts->ground); |
|
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
1052 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1053 |
while (buf < *bufp + len) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1054 |
DrawTileSeqStruct *dtss; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1055 |
|
9505 | 1056 |
/* no relative bounding box support */ |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
1057 |
dts->seq = ReallocT((DrawTileSeqStruct*)dts->seq, ++seq_count); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1058 |
dtss = (DrawTileSeqStruct*) &dts->seq[seq_count - 1]; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1059 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1060 |
dtss->delta_x = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1061 |
if ((byte) dtss->delta_x == 0x80) break; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1062 |
dtss->delta_y = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1063 |
dtss->delta_z = grf_load_byte(&buf); |
4230
cd86b1c47f33
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
1064 |
dtss->size_x = grf_load_byte(&buf); |
cd86b1c47f33
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
1065 |
dtss->size_y = grf_load_byte(&buf); |
cd86b1c47f33
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
1066 |
dtss->size_z = grf_load_byte(&buf); |
9732 | 1067 |
dtss->image.sprite = grf_load_word(&buf); |
1068 |
dtss->image.pal = grf_load_word(&buf); |
|
3771
b34d07131ad1
(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
|
1069 |
|
3775
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
1070 |
/* Remap flags as ours collide */ |
9732 | 1071 |
if (HasBit(dtss->image.pal, 15)) { |
1072 |
ClrBit(dtss->image.pal, 15); |
|
1073 |
SetBit(dtss->image.sprite, SPRITE_MODIFIER_USE_OFFSET); |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1074 |
} |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5868
diff
changeset
|
1075 |
|
9732 | 1076 |
MapSpriteMappingRecolour(&dtss->image); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1077 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1078 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1079 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1080 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1081 |
case 0x0A: { // Copy sprite layout |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1082 |
byte srcid = grf_load_byte(&buf); |
3768
46d328178509
(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
|
1083 |
const StationSpec *srcstatspec = _cur_grffile->stations[srcid]; |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
1084 |
|
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1085 |
statspec->tiles = srcstatspec->tiles; |
3738
d41775f0f3fb
(svn r4720) - Newstations: instead of literally copying sprite layout data, just copy the pointer to the existing data.
peter1138
parents:
3737
diff
changeset
|
1086 |
statspec->renderdata = srcstatspec->renderdata; |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
1087 |
statspec->copied_renderdata = true; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1088 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1089 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1090 |
case 0x0B: // Callback mask |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1091 |
statspec->callbackmask = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1092 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1093 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1094 |
case 0x0C: // Disallowed number of platforms |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1095 |
statspec->disallowed_platforms = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1096 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1097 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1098 |
case 0x0D: // Disallowed platform lengths |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1099 |
statspec->disallowed_lengths = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1100 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1101 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1102 |
case 0x0E: // Define custom layout |
5060
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1103 |
statspec->copied_layouts = false; |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1104 |
|
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1105 |
while (buf < *bufp + len) { |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1106 |
byte length = grf_load_byte(&buf); |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1107 |
byte number = grf_load_byte(&buf); |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1108 |
StationLayout layout; |
3570
f9749bae861e
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
1109 |
uint l, p; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1110 |
|
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1111 |
if (length == 0 || number == 0) break; |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1112 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1113 |
//debug("l %d > %d ?", length, stat->lengths); |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1114 |
if (length > statspec->lengths) { |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
1115 |
statspec->platforms = ReallocT(statspec->platforms, length); |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1116 |
memset(statspec->platforms + statspec->lengths, 0, length - statspec->lengths); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1117 |
|
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
1118 |
statspec->layouts = ReallocT(statspec->layouts, length); |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1119 |
memset(statspec->layouts + statspec->lengths, 0, |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1120 |
(length - statspec->lengths) * sizeof(*statspec->layouts)); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1121 |
|
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1122 |
statspec->lengths = length; |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1123 |
} |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1124 |
l = length - 1; // index is zero-based |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1125 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1126 |
//debug("p %d > %d ?", number, stat->platforms[l]); |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1127 |
if (number > statspec->platforms[l]) { |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
1128 |
statspec->layouts[l] = ReallocT(statspec->layouts[l], number); |
9505 | 1129 |
/* We expect NULL being 0 here, but C99 guarantees that. */ |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1130 |
memset(statspec->layouts[l] + statspec->platforms[l], 0, |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1131 |
(number - statspec->platforms[l]) * sizeof(**statspec->layouts)); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1132 |
|
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1133 |
statspec->platforms[l] = number; |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1134 |
} |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1135 |
|
542 | 1136 |
p = 0; |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
1137 |
layout = MallocT<byte>(length * number); |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1138 |
for (l = 0; l < length; l++) { |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1139 |
for (p = 0; p < number; p++) { |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1140 |
layout[l * number + p] = grf_load_byte(&buf); |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1141 |
} |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1142 |
} |
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1143 |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1144 |
l--; |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
448
diff
changeset
|
1145 |
p--; |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1146 |
free(statspec->layouts[l][p]); |
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1147 |
statspec->layouts[l][p] = layout; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1148 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1149 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1150 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1151 |
case 0x0F: { // Copy custom layout |
5060
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1152 |
byte srcid = grf_load_byte(&buf); |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1153 |
const StationSpec *srcstatspec = _cur_grffile->stations[srcid]; |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1154 |
|
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1155 |
statspec->lengths = srcstatspec->lengths; |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1156 |
statspec->platforms = srcstatspec->platforms; |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1157 |
statspec->layouts = srcstatspec->layouts; |
2d577061b0ec
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1158 |
statspec->copied_layouts = true; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1159 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1160 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1161 |
case 0x10: // Little/lots cargo threshold |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1162 |
statspec->cargo_threshold = grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1163 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1164 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1165 |
case 0x11: // Pylon placement |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1166 |
statspec->pylons = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1167 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1168 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1169 |
case 0x12: // Cargo types for random triggers |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1170 |
statspec->cargo_triggers = grf_load_dword(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1171 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1172 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1173 |
case 0x13: // General flags |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1174 |
statspec->flags = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1175 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1176 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1177 |
case 0x14: // Overhead wire placement |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1178 |
statspec->wires = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1179 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1180 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1181 |
case 0x15: // Blocked tiles |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1182 |
statspec->blocked = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1183 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1184 |
|
10294 | 1185 |
case 0x16: // Animation info |
1186 |
statspec->anim_frames = grf_load_byte(&buf); |
|
1187 |
statspec->anim_status = grf_load_byte(&buf); |
|
1188 |
break; |
|
1189 |
||
1190 |
case 0x17: // Animation speed |
|
1191 |
statspec->anim_speed = grf_load_byte(&buf); |
|
1192 |
break; |
|
1193 |
||
1194 |
case 0x18: // Animation triggers |
|
1195 |
statspec->anim_triggers = grf_load_word(&buf); |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1196 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1197 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1198 |
default: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1199 |
ret = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1200 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1201 |
} |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1202 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1203 |
|
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1204 |
*bufp = buf; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1205 |
return ret; |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1206 |
} |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1207 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1208 |
static bool CanalChangeInfo(uint id, int numinfo, int prop, byte **bufp, int len) |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1209 |
{ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1210 |
byte *buf = *bufp; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1211 |
bool ret = false; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1212 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1213 |
if (id + numinfo > CF_END) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1214 |
grfmsg(1, "CanalChangeInfo: Canal feature %u is invalid, max %u, ignoreing", id + numinfo, CF_END); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1215 |
return false; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1216 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1217 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1218 |
for (int i = 0; i < numinfo; i++) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1219 |
WaterFeature *wf = &_water_feature[id + i]; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1220 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1221 |
switch (prop) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1222 |
case 0x08: |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1223 |
wf->callbackmask = grf_load_byte(&buf); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1224 |
break; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1225 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1226 |
case 0x09: |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1227 |
wf->flags = grf_load_byte(&buf); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1228 |
break; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1229 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1230 |
default: |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1231 |
ret = true; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1232 |
break; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1233 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1234 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1235 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1236 |
*bufp = buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1237 |
return ret; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1238 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1239 |
|
2478
16b05f1de6bb
(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
|
1240 |
static bool BridgeChangeInfo(uint brid, int numinfo, int prop, byte **bufp, int len) |
16b05f1de6bb
(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
|
1241 |
{ |
16b05f1de6bb
(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
|
1242 |
byte *buf = *bufp; |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1243 |
bool ret = false; |
2478
16b05f1de6bb
(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
|
1244 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1245 |
if (brid + numinfo > MAX_BRIDGES) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1246 |
grfmsg(1, "BridgeChangeInfo: Bridge %u is invalid, max %u, ignoring", brid + numinfo, MAX_BRIDGES); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1247 |
return false; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1248 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1249 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1250 |
for (int i = 0; i < numinfo; i++) { |
9732 | 1251 |
BridgeSpec *bridge = &_bridge[brid + i]; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1252 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1253 |
switch (prop) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1254 |
case 0x08: // Year of availability |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1255 |
bridge->avail_year = ORIGINAL_BASE_YEAR + grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1256 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1257 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1258 |
case 0x09: // Minimum length |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1259 |
bridge->min_length = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1260 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1261 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1262 |
case 0x0A: // Maximum length |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1263 |
bridge->max_length = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1264 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1265 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1266 |
case 0x0B: // Cost factor |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1267 |
bridge->price = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1268 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1269 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1270 |
case 0x0C: // Maximum speed |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1271 |
bridge->speed = grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1272 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1273 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1274 |
case 0x0D: { // Bridge sprite tables |
2478
16b05f1de6bb
(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
|
1275 |
byte tableid = grf_load_byte(&buf); |
16b05f1de6bb
(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
|
1276 |
byte numtables = grf_load_byte(&buf); |
16b05f1de6bb
(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
|
1277 |
|
16b05f1de6bb
(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
|
1278 |
if (bridge->sprite_table == NULL) { |
3555
7a4f6e2aee0f
(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
|
1279 |
/* Allocate memory for sprite table pointers and zero out */ |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
1280 |
bridge->sprite_table = CallocT<PalSpriteID*>(7); |
2478
16b05f1de6bb
(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
|
1281 |
} |
16b05f1de6bb
(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
|
1282 |
|
3555
7a4f6e2aee0f
(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
|
1283 |
for (; numtables-- != 0; tableid++) { |
7a4f6e2aee0f
(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
|
1284 |
if (tableid >= 7) { // skip invalid data |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1285 |
grfmsg(1, "BridgeChangeInfo: Table %d >= 7, skipping", tableid); |
6607 | 1286 |
for (byte sprite = 0; sprite < 32; sprite++) grf_load_dword(&buf); |
3555
7a4f6e2aee0f
(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
|
1287 |
continue; |
2478
16b05f1de6bb
(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
|
1288 |
} |
3555
7a4f6e2aee0f
(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
|
1289 |
|
7a4f6e2aee0f
(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
|
1290 |
if (bridge->sprite_table[tableid] == NULL) { |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
1291 |
bridge->sprite_table[tableid] = MallocT<PalSpriteID>(32); |
3555
7a4f6e2aee0f
(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
|
1292 |
} |
7a4f6e2aee0f
(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
|
1293 |
|
6607 | 1294 |
for (byte sprite = 0; sprite < 32; sprite++) { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5868
diff
changeset
|
1295 |
SpriteID image = grf_load_word(&buf); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5868
diff
changeset
|
1296 |
SpriteID pal = grf_load_word(&buf); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5868
diff
changeset
|
1297 |
|
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5868
diff
changeset
|
1298 |
bridge->sprite_table[tableid][sprite].sprite = image; |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5868
diff
changeset
|
1299 |
bridge->sprite_table[tableid][sprite].pal = pal; |
9732 | 1300 |
|
1301 |
MapSpriteMappingRecolour(&bridge->sprite_table[tableid][sprite]); |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5868
diff
changeset
|
1302 |
} |
2478
16b05f1de6bb
(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
|
1303 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1304 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1305 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1306 |
case 0x0E: // Flags; bit 0 - disable far pillars |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1307 |
bridge->flags = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1308 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1309 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1310 |
case 0x0F: // Long format year of availability (year since year 0) |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1311 |
bridge->avail_year = Clamp(grf_load_dword(&buf), MIN_YEAR, MAX_YEAR); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1312 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1313 |
|
9732 | 1314 |
case 0x10: { // purchase string |
1315 |
StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf)); |
|
1316 |
if (newone != STR_UNDEFINED) bridge->material = newone; |
|
1317 |
} break; |
|
1318 |
||
1319 |
case 0x11: // description of bridge with rails or roads |
|
1320 |
case 0x12: { |
|
1321 |
StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf)); |
|
1322 |
if (newone != STR_UNDEFINED) bridge->transport_name[prop - 0x11] = newone; |
|
1323 |
} break; |
|
1324 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1325 |
default: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1326 |
ret = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1327 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1328 |
} |
2478
16b05f1de6bb
(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
|
1329 |
} |
16b05f1de6bb
(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
|
1330 |
|
16b05f1de6bb
(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
|
1331 |
*bufp = buf; |
16b05f1de6bb
(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
|
1332 |
return ret; |
16b05f1de6bb
(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
|
1333 |
} |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
1334 |
|
9476 | 1335 |
static bool TownHouseChangeInfo(uint hid, int numinfo, int prop, byte **bufp, int len) |
1336 |
{ |
|
1337 |
byte *buf = *bufp; |
|
1338 |
bool ret = false; |
|
1339 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1340 |
if (hid + numinfo > HOUSE_MAX) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1341 |
grfmsg(1, "TownHouseChangeInfo: Too many houses loaded (%u), max (%u). Ignoring.", hid + numinfo, HOUSE_MAX); |
9476 | 1342 |
return false; |
1343 |
} |
|
1344 |
||
1345 |
/* Allocate house specs if they haven't been allocated already. */ |
|
1346 |
if (_cur_grffile->housespec == NULL) { |
|
1347 |
_cur_grffile->housespec = CallocT<HouseSpec*>(HOUSE_MAX); |
|
1348 |
} |
|
1349 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1350 |
for (int i = 0; i < numinfo; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1351 |
HouseSpec *housespec = _cur_grffile->housespec[hid + i]; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1352 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1353 |
if (prop != 0x08 && housespec == NULL) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1354 |
grfmsg(2, "TownHouseChangeInfo: Attempt to modify undefined house %u. Ignoring.", hid + i); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1355 |
continue; |
9476 | 1356 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1357 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1358 |
switch (prop) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1359 |
case 0x08: { // Substitute building type, and definition of a new house |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1360 |
HouseSpec **house = &_cur_grffile->housespec[hid + i]; |
9476 | 1361 |
byte subs_id = grf_load_byte(&buf); |
1362 |
||
1363 |
if (subs_id == 0xFF) { |
|
1364 |
/* Instead of defining a new house, a substitute house id |
|
1365 |
* of 0xFF disables the old house with the current id. */ |
|
1366 |
_house_specs[hid + i].enabled = false; |
|
1367 |
continue; |
|
1368 |
} else if (subs_id >= NEW_HOUSE_OFFSET) { |
|
1369 |
/* The substitute id must be one of the original houses. */ |
|
1370 |
grfmsg(2, "TownHouseChangeInfo: Attempt to use new house %u as substitute house for %u. Ignoring.", subs_id, hid + i); |
|
1371 |
return false; |
|
1372 |
} |
|
1373 |
||
1374 |
/* Allocate space for this house. */ |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1375 |
if (*house == NULL) *house = CallocT<HouseSpec>(1); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1376 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1377 |
housespec = *house; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1378 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1379 |
memcpy(housespec, &_house_specs[subs_id], sizeof(_house_specs[subs_id])); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1380 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1381 |
housespec->enabled = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1382 |
housespec->local_id = hid + i; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1383 |
housespec->substitute_id = subs_id; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1384 |
housespec->grffile = _cur_grffile; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1385 |
housespec->random_colour[0] = 0x04; // those 4 random colours are the base colour |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1386 |
housespec->random_colour[1] = 0x08; // for all new houses |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1387 |
housespec->random_colour[2] = 0x0C; // they stand for red, blue, orange and green |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1388 |
housespec->random_colour[3] = 0x06; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1389 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1390 |
/* Make sure that the third cargo type is valid in this |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1391 |
* climate. This can cause problems when copying the properties |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1392 |
* of a house that accepts food, where the new house is valid |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1393 |
* in the temperate climate. */ |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1394 |
if (!GetCargo(housespec->accepts_cargo[2])->IsValid()) { |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1395 |
housespec->cargo_acceptance[2] = 0; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1396 |
} |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1397 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1398 |
/** |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1399 |
* New houses do not (currently) expect to have a default start |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1400 |
* date before 1930, as this breaks the build date stuff. |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1401 |
* @see FinaliseHouseArray() for more details. |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1402 |
*/ |
10829 | 1403 |
if (housespec->min_year < 1930) housespec->min_year = 1930; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1404 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1405 |
_loaded_newgrf_features.has_newhouses = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1406 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1407 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1408 |
case 0x09: // Building flags |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1409 |
housespec->building_flags = (BuildingFlags)grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1410 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1411 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1412 |
case 0x0A: { // Availability years |
9476 | 1413 |
uint16 years = grf_load_word(&buf); |
10829 | 1414 |
housespec->min_year = GB(years, 0, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 0, 8); |
1415 |
housespec->max_year = GB(years, 8, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 8, 8); |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1416 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1417 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1418 |
case 0x0B: // Population |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1419 |
housespec->population = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1420 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1421 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1422 |
case 0x0C: // Mail generation multiplier |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1423 |
housespec->mail_generation = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1424 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1425 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1426 |
case 0x0D: // Passenger acceptance |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1427 |
case 0x0E: // Mail acceptance |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1428 |
housespec->cargo_acceptance[prop - 0x0D] = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1429 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1430 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1431 |
case 0x0F: { // Goods/candy, food/fizzy drinks acceptance |
9476 | 1432 |
int8 goods = grf_load_byte(&buf); |
9505 | 1433 |
|
1434 |
/* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance. |
|
1435 |
* Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */ |
|
10776 | 1436 |
CargoID cid = (goods >= 0) ? ((_settings_game.game_creation.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) : |
1437 |
((_settings_game.game_creation.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD); |
|
9505 | 1438 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1439 |
/* Make sure the cargo type is valid in this climate. */ |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1440 |
if (!GetCargo(cid)->IsValid()) goods = 0; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1441 |
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1442 |
housespec->accepts_cargo[2] = cid; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1443 |
housespec->cargo_acceptance[2] = abs(goods); // but we do need positive value here |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1444 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1445 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1446 |
case 0x10: // Local authority rating decrease on removal |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1447 |
housespec->remove_rating_decrease = grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1448 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1449 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1450 |
case 0x11: // Removal cost multiplier |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1451 |
housespec->removal_cost = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1452 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1453 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1454 |
case 0x12: // Building name ID |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1455 |
housespec->building_name = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1456 |
_string_to_grf_mapping[&housespec->building_name] = _cur_grffile->grfid; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1457 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1458 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1459 |
case 0x13: // Building availability mask |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1460 |
housespec->building_availability = (HouseZones)grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1461 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1462 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1463 |
case 0x14: // House callback flags |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1464 |
housespec->callback_mask = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1465 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1466 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1467 |
case 0x15: { // House override byte |
9476 | 1468 |
byte override = grf_load_byte(&buf); |
1469 |
||
1470 |
/* The house being overridden must be an original house. */ |
|
1471 |
if (override >= NEW_HOUSE_OFFSET) { |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1472 |
grfmsg(2, "TownHouseChangeInfo: Attempt to override new house %u with house id %u. Ignoring.", override, hid + i); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1473 |
continue; |
9476 | 1474 |
} |
1475 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1476 |
_house_mngr.Add(hid + i, _cur_grffile->grfid, override); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1477 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1478 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1479 |
case 0x16: // Periodic refresh multiplier |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1480 |
housespec->processing_time = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1481 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1482 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1483 |
case 0x17: // Four random colours to use |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1484 |
for (uint j = 0; j < 4; j++) housespec->random_colour[j] = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1485 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1486 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1487 |
case 0x18: // Relative probability of appearing |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1488 |
housespec->probability = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1489 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1490 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1491 |
case 0x19: // Extra flags |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1492 |
housespec->extra_flags = (HouseExtraFlags)grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1493 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1494 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1495 |
case 0x1A: // Animation frames |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1496 |
housespec->animation_frames = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1497 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1498 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1499 |
case 0x1B: // Animation speed |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1500 |
housespec->animation_speed = Clamp(grf_load_byte(&buf), 2, 16); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1501 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1502 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1503 |
case 0x1C: // Class of the building type |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1504 |
housespec->class_id = AllocateHouseClassID(grf_load_byte(&buf), _cur_grffile->grfid); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1505 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1506 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1507 |
case 0x1D: // Callback flags 2 |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1508 |
housespec->callback_mask |= (grf_load_byte(&buf) << 8); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1509 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1510 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1511 |
case 0x1E: { // Accepted cargo types |
9599 | 1512 |
uint32 cargotypes = grf_load_dword(&buf); |
1513 |
||
1514 |
/* Check if the cargo types should not be changed */ |
|
1515 |
if (cargotypes == 0xFFFFFFFF) break; |
|
1516 |
||
1517 |
for (uint j = 0; j < 3; j++) { |
|
1518 |
/* Get the cargo number from the 'list' */ |
|
1519 |
uint8 cargo_part = GB(cargotypes, 8 * j, 8); |
|
1520 |
CargoID cargo = GetCargoTranslation(cargo_part, _cur_grffile); |
|
1521 |
||
1522 |
if (cargo == CT_INVALID) { |
|
1523 |
/* Disable acceptance of invalid cargo type */ |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1524 |
housespec->cargo_acceptance[j] = 0; |
9599 | 1525 |
} else { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1526 |
housespec->accepts_cargo[j] = cargo; |
9599 | 1527 |
} |
1528 |
} |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1529 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1530 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1531 |
case 0x1F: // Minimum life span |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1532 |
housespec->minimum_life = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1533 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1534 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1535 |
case 0x20: { // @todo Cargo acceptance watch list |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1536 |
byte count = grf_load_byte(&buf); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1537 |
for (byte j = 0; j < count; j++) grf_load_byte(&buf); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1538 |
ret = true; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1539 |
} break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1540 |
|
10920 | 1541 |
case 0x21: // long introduction year |
1542 |
housespec->min_year = grf_load_word(&buf); |
|
1543 |
break; |
|
1544 |
||
1545 |
case 0x22: // long maximum year |
|
1546 |
housespec->max_year = grf_load_word(&buf); |
|
1547 |
break; |
|
1548 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1549 |
default: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1550 |
ret = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1551 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1552 |
} |
9476 | 1553 |
} |
1554 |
||
1555 |
*bufp = buf; |
|
1556 |
return ret; |
|
1557 |
} |
|
1558 |
||
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1559 |
static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, int len) |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1560 |
{ |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1561 |
byte *buf = *bufp; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1562 |
bool ret = false; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1563 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1564 |
for (int i = 0; i < numinfo; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1565 |
switch (prop) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1566 |
case 0x08: { // Cost base factor |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1567 |
byte factor = grf_load_byte(&buf); |
2508
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1568 |
uint price = gvid + i; |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1569 |
|
2508
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1570 |
if (price < NUM_PRICES) { |
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1571 |
SetPriceBaseMultiplier(price, factor); |
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1572 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1573 |
grfmsg(1, "GlobalVarChangeInfo: Price %d out of range, ignoring", price); |
2508
c1a1af1920ce
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1574 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1575 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1576 |
|
9732 | 1577 |
case 0x09: // Cargo translation table |
1578 |
/* This is loaded during the reservation stage, so just skip it here. */ |
|
1579 |
/* Each entry is 4 bytes. */ |
|
1580 |
buf += 4; |
|
1581 |
break; |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1582 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1583 |
case 0x0A: { // Currency display names |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1584 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1585 |
StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf)); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1586 |
|
4504
3d20af4bd525
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1587 |
if ((newone != STR_UNDEFINED) && (curidx < NUM_CURRENCY)) { |
3d20af4bd525
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1588 |
_currency_specs[curidx].name = newone; |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1589 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1590 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1591 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1592 |
case 0x0B: { // Currency multipliers |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1593 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1594 |
uint32 rate = grf_load_dword(&buf); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1595 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1596 |
if (curidx < NUM_CURRENCY) { |
4602
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1597 |
/* TTDPatch uses a multiple of 1000 for its conversion calculations, |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1598 |
* which OTTD does not. For this reason, divide grf value by 1000, |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1599 |
* to be compatible */ |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1600 |
_currency_specs[curidx].rate = rate / 1000; |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1601 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1602 |
grfmsg(1, "GlobalVarChangeInfo: Currency multipliers %d out of range, ignoring", curidx); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1603 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1604 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1605 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1606 |
case 0x0C: { // Currency options |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1607 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1608 |
uint16 options = grf_load_word(&buf); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1609 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1610 |
if (curidx < NUM_CURRENCY) { |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1611 |
_currency_specs[curidx].separator = GB(options, 0, 8); |
4602
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1612 |
/* By specifying only one bit, we prevent errors, |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1613 |
* since newgrf specs said that only 0 and 1 can be set for symbol_pos */ |
36e779efee9a
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1614 |
_currency_specs[curidx].symbol_pos = GB(options, 8, 1); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1615 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1616 |
grfmsg(1, "GlobalVarChangeInfo: Currency option %d out of range, ignoring", curidx); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1617 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1618 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1619 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1620 |
case 0x0D: { // Currency prefix symbol |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1621 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1622 |
uint32 tempfix = grf_load_dword(&buf); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1623 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1624 |
if (curidx < NUM_CURRENCY) { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1625 |
memcpy(_currency_specs[curidx].prefix, &tempfix, 4); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1626 |
_currency_specs[curidx].prefix[4] = 0; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1627 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1628 |
grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1629 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1630 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1631 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1632 |
case 0x0E: { // Currency suffix symbol |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1633 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1634 |
uint32 tempfix = grf_load_dword(&buf); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1635 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1636 |
if (curidx < NUM_CURRENCY) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
1637 |
memcpy(&_currency_specs[curidx].suffix, &tempfix, 4); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1638 |
_currency_specs[curidx].suffix[4] = 0; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1639 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1640 |
grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1641 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1642 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1643 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1644 |
case 0x0F: { // Euro introduction dates |
4625
3e45c59b5d64
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1645 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1646 |
Year year_euro = grf_load_word(&buf); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1647 |
|
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1648 |
if (curidx < NUM_CURRENCY) { |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1649 |
_currency_specs[curidx].to_euro = year_euro; |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1650 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1651 |
grfmsg(1, "GlobalVarChangeInfo: Euro intro date %d out of range, ignoring", curidx); |
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1652 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1653 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1654 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1655 |
case 0x10: // Snow line height table |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1656 |
if (numinfo > 1 || IsSnowLineSet()) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1657 |
grfmsg(1, "GlobalVarChangeInfo: The snowline can only be set once (%d)", numinfo); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1658 |
} else if (len < SNOW_LINE_MONTHS * SNOW_LINE_DAYS) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1659 |
grfmsg(1, "GlobalVarChangeInfo: Not enough entries set in the snowline table (%d)", len); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1660 |
} else { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1661 |
byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1662 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1663 |
for (uint i = 0; i < SNOW_LINE_MONTHS; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1664 |
for (uint j = 0; j < SNOW_LINE_DAYS; j++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1665 |
table[i][j] = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1666 |
} |
9505 | 1667 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1668 |
SetSnowLine(table); |
9505 | 1669 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1670 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1671 |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
1672 |
case 0x11: // GRF match for engine allocation |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
1673 |
/* This is loaded during the reservation stage, so just skip it here. */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
1674 |
/* Each entry is 8 bytes. */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
1675 |
buf += 8; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
1676 |
break; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
1677 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1678 |
default: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1679 |
ret = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1680 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1681 |
} |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1682 |
} |
3504
546b53897c01
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1683 |
|
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1684 |
*bufp = buf; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1685 |
return ret; |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1686 |
} |
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1687 |
|
9517 | 1688 |
static bool CargoChangeInfo(uint cid, int numinfo, int prop, byte **bufp, int len) |
1689 |
{ |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1690 |
byte *buf = *bufp; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1691 |
bool ret = false; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1692 |
|
9517 | 1693 |
if (cid + numinfo > NUM_CARGO) { |
1694 |
grfmsg(2, "CargoChangeInfo: Cargo type %d out of range (max %d)", cid + numinfo, NUM_CARGO - 1); |
|
1695 |
return false; |
|
1696 |
} |
|
1697 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1698 |
for (int i = 0; i < numinfo; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1699 |
CargoSpec *cs = &_cargo[cid + i]; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1700 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1701 |
switch (prop) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1702 |
case 0x08: /* Bit number of cargo */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1703 |
cs->bitnum = grf_load_byte(&buf); |
9517 | 1704 |
if (cs->IsValid()) { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
1705 |
cs->grfid = _cur_grffile->grfid; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1706 |
SetBit(_cargo_mask, cid + i); |
9517 | 1707 |
} else { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1708 |
ClrBit(_cargo_mask, cid + i); |
9517 | 1709 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1710 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1711 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1712 |
case 0x09: /* String ID for cargo type name */ |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1713 |
cs->name = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1714 |
_string_to_grf_mapping[&cs->name] = _cur_grffile->grfid; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1715 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1716 |
|
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9641
diff
changeset
|
1717 |
case 0x0A: /* String for 1 unit of cargo */ |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1718 |
cs->name_single = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1719 |
_string_to_grf_mapping[&cs->name_single] = _cur_grffile->grfid; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1720 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1721 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1722 |
case 0x0B: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1723 |
/* String for units of cargo. This is different in OpenTTD to TTDPatch |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1724 |
* (e.g. 10 tonnes of coal) */ |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1725 |
cs->units_volume = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1726 |
_string_to_grf_mapping[&cs->units_volume] = _cur_grffile->grfid; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1727 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1728 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1729 |
case 0x0C: /* String for quantity of cargo (e.g. 10 tonnes of coal) */ |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1730 |
cs->quantifier = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1731 |
_string_to_grf_mapping[&cs->quantifier] = _cur_grffile->grfid; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1732 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1733 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1734 |
case 0x0D: /* String for two letter cargo abbreviation */ |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1735 |
cs->abbrev = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
1736 |
_string_to_grf_mapping[&cs->abbrev] = _cur_grffile->grfid; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1737 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1738 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1739 |
case 0x0E: /* Sprite ID for cargo icon */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1740 |
cs->sprite = grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1741 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1742 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1743 |
case 0x0F: /* Weight of one unit of cargo */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1744 |
cs->weight = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1745 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1746 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1747 |
case 0x10: /* Used for payment calculation */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1748 |
cs->transit_days[0] = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1749 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1750 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1751 |
case 0x11: /* Used for payment calculation */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1752 |
cs->transit_days[1] = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1753 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1754 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1755 |
case 0x12: /* Base cargo price */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1756 |
cs->initial_payment = grf_load_dword(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1757 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1758 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1759 |
case 0x13: /* Colour for station rating bars */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1760 |
cs->rating_colour = MapDOSColour(grf_load_byte(&buf)); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1761 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1762 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1763 |
case 0x14: /* Colour for cargo graph */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1764 |
cs->legend_colour = MapDOSColour(grf_load_byte(&buf)); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1765 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1766 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1767 |
case 0x15: /* Freight status */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1768 |
cs->is_freight = (grf_load_byte(&buf) != 0); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1769 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1770 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1771 |
case 0x16: /* Cargo classes */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1772 |
cs->classes = grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1773 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1774 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1775 |
case 0x17: /* Cargo label */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1776 |
cs->label = grf_load_dword(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1777 |
cs->label = BSWAP32(cs->label); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1778 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1779 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1780 |
case 0x18: { /* Town growth substitute type */ |
9517 | 1781 |
uint8 substitute_type = grf_load_byte(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1782 |
|
9517 | 1783 |
switch (substitute_type) { |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1784 |
case 0x00: cs->town_effect = TE_PASSENGERS; break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1785 |
case 0x02: cs->town_effect = TE_MAIL; break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1786 |
case 0x05: cs->town_effect = TE_GOODS; break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1787 |
case 0x09: cs->town_effect = TE_WATER; break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1788 |
case 0x0B: cs->town_effect = TE_FOOD; break; |
9517 | 1789 |
default: |
1790 |
grfmsg(1, "CargoChangeInfo: Unknown town growth substitute value %d, setting to none.", substitute_type); |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1791 |
case 0xFF: cs->town_effect = TE_NONE; break; |
9517 | 1792 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1793 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1794 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1795 |
case 0x19: /* Town growth coefficient */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1796 |
cs->multipliertowngrowth = grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1797 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1798 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1799 |
case 0x1A: /* Bitmask of callbacks to use */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1800 |
cs->callback_mask = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1801 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1802 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1803 |
default: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1804 |
ret = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1805 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1806 |
} |
9517 | 1807 |
} |
1808 |
||
1809 |
*bufp = buf; |
|
1810 |
return ret; |
|
1811 |
} |
|
1812 |
||
1813 |
||
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1814 |
static bool SoundEffectChangeInfo(uint sid, int numinfo, int prop, byte **bufp, int len) |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1815 |
{ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1816 |
byte *buf = *bufp; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1817 |
bool ret = false; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1818 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1819 |
if (_cur_grffile->sound_offset == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
1820 |
grfmsg(1, "SoundEffectChangeInfo: No effects defined, skipping"); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1821 |
return false; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1822 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1823 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1824 |
for (int i = 0; i < numinfo; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1825 |
uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1826 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1827 |
if (sound >= GetNumSounds()) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1828 |
grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1829 |
continue; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1830 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1831 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1832 |
switch (prop) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1833 |
case 0x08: // Relative volume |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1834 |
GetSound(sound)->volume = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1835 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1836 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1837 |
case 0x09: // Priority |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1838 |
GetSound(sound)->priority = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1839 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1840 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1841 |
case 0x0A: { // Override old sound |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1842 |
uint orig_sound = grf_load_byte(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1843 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1844 |
if (orig_sound >= GetNumSounds()) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1845 |
grfmsg(1, "SoundEffectChangeInfo: Original sound %d not defined (max %d)", orig_sound, GetNumSounds()); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1846 |
} else { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1847 |
FileEntry *newfe = GetSound(sound); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1848 |
FileEntry *oldfe = GetSound(orig_sound); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1849 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1850 |
/* Literally copy the data of the new sound over the original */ |
5024
f13f2f2d43f9
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5011
diff
changeset
|
1851 |
*oldfe = *newfe; |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1852 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1853 |
} break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1854 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1855 |
default: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1856 |
ret = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1857 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1858 |
} |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1859 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1860 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1861 |
*bufp = buf; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1862 |
return ret; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1863 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1864 |
|
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1865 |
static bool IndustrytilesChangeInfo(uint indtid, int numinfo, int prop, byte **bufp, int len) |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1866 |
{ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1867 |
byte *buf = *bufp; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1868 |
bool ret = false; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1869 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1870 |
if (indtid + numinfo > NUM_INDUSTRYTILES) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1871 |
grfmsg(1, "IndustryTilesChangeInfo: Too many industry tiles loaded (%u), max (%u). Ignoring.", indtid + numinfo, NUM_INDUSTRYTILES); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1872 |
return false; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1873 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1874 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1875 |
/* Allocate industry tile specs if they haven't been allocated already. */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1876 |
if (_cur_grffile->indtspec == NULL) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1877 |
_cur_grffile->indtspec = CallocT<IndustryTileSpec*>(NUM_INDUSTRYTILES); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1878 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1879 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1880 |
for (int i = 0; i < numinfo; i++) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1881 |
IndustryTileSpec *tsp = _cur_grffile->indtspec[indtid + i]; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1882 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1883 |
if (prop != 0x08 && tsp == NULL) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1884 |
grfmsg(2, "IndustryTilesChangeInfo: Attempt to modify undefined industry tile %u. Ignoring.", indtid + i); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1885 |
continue; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1886 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1887 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1888 |
switch (prop) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1889 |
case 0x08: { // Substitute industry tile type |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1890 |
IndustryTileSpec **tilespec = &_cur_grffile->indtspec[indtid + i]; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1891 |
byte subs_id = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1892 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9686
diff
changeset
|
1893 |
if (subs_id >= NEW_INDUSTRYTILEOFFSET) { |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1894 |
/* The substitute id must be one of the original industry tile. */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1895 |
grfmsg(2, "IndustryTilesChangeInfo: Attempt to use new industry tile %u as substitute industry tile for %u. Ignoring.", subs_id, indtid + i); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1896 |
return false; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1897 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1898 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1899 |
/* Allocate space for this industry. */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1900 |
if (*tilespec == NULL) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1901 |
int tempid; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1902 |
*tilespec = CallocT<IndustryTileSpec>(1); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1903 |
tsp = *tilespec; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1904 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1905 |
memcpy(tsp, &_industry_tile_specs[subs_id], sizeof(_industry_tile_specs[subs_id])); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1906 |
tsp->enabled = true; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1907 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1908 |
/* A copied tile should not have the animation infos copied too. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1909 |
* The anim_state should be left untouched, though |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1910 |
* It is up to the author to animate them himself */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1911 |
tsp->anim_production = INDUSTRYTILE_NOANIM; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1912 |
tsp->anim_next = INDUSTRYTILE_NOANIM; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1913 |
|
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1914 |
tsp->grf_prop.local_id = indtid + i; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1915 |
tsp->grf_prop.subst_id = subs_id; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1916 |
tsp->grf_prop.grffile = _cur_grffile; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1917 |
tempid = _industile_mngr.AddEntityID(indtid + i, _cur_grffile->grfid, subs_id); // pre-reserve the tile slot |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1918 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1919 |
} break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1920 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1921 |
case 0x09: { // Industry tile override |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1922 |
byte ovrid = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1923 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1924 |
/* The industry being overridden must be an original industry. */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1925 |
if (ovrid >= NEW_INDUSTRYTILEOFFSET) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1926 |
grfmsg(2, "IndustryTilesChangeInfo: Attempt to override new industry tile %u with industry tile id %u. Ignoring.", ovrid, indtid + i); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1927 |
return false; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1928 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1929 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1930 |
_industile_mngr.Add(indtid + i, _cur_grffile->grfid, ovrid); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1931 |
} break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1932 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1933 |
case 0x0A: // Tile acceptance |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1934 |
case 0x0B: |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1935 |
case 0x0C: { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1936 |
uint16 acctp = grf_load_word(&buf); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1937 |
tsp->accepts_cargo[prop - 0x0A] = GetCargoTranslation(GB(acctp, 0, 8), _cur_grffile); |
9704 | 1938 |
tsp->acceptance[prop - 0x0A] = GB(acctp, 8, 8); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1939 |
} break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1940 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1941 |
case 0x0D: // Land shape flags |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1942 |
tsp->slopes_refused = (Slope)grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1943 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1944 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1945 |
case 0x0E: // Callback flags |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1946 |
tsp->callback_flags = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1947 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1948 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1949 |
case 0x0F: // Animation information |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1950 |
tsp->animation_info = grf_load_word(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1951 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1952 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1953 |
case 0x10: // Animation speed |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1954 |
tsp->animation_speed = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1955 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1956 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1957 |
case 0x11: // Triggers for callback 25 |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1958 |
tsp->animation_triggers = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1959 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1960 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1961 |
case 0x12: // Special flags |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1962 |
tsp->animation_special_flags = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1963 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1964 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1965 |
default: |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1966 |
ret = true; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1967 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1968 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1969 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1970 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1971 |
*bufp = buf; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1972 |
return ret; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1973 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1974 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1975 |
static bool IndustriesChangeInfo(uint indid, int numinfo, int prop, byte **bufp, int len) |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1976 |
{ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1977 |
byte *buf = *bufp; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1978 |
bool ret = false; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1979 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1980 |
if (indid + numinfo > NUM_INDUSTRYTYPES) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1981 |
grfmsg(1, "IndustriesChangeInfo: Too many industries loaded (%u), max (%u). Ignoring.", indid + numinfo, NUM_INDUSTRYTYPES); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1982 |
return false; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1983 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1984 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1985 |
grfmsg(1, "IndustriesChangeInfo: newid %u", indid); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1986 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1987 |
/* Allocate industry specs if they haven't been allocated already. */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1988 |
if (_cur_grffile->industryspec == NULL) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1989 |
_cur_grffile->industryspec = CallocT<IndustrySpec*>(NUM_INDUSTRYTYPES); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1990 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1991 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1992 |
for (int i = 0; i < numinfo; i++) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1993 |
IndustrySpec *indsp = _cur_grffile->industryspec[indid + i]; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1994 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1995 |
if (prop != 0x08 && indsp == NULL) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1996 |
grfmsg(2, "IndustriesChangeInfo: Attempt to modify undefined industry %u. Ignoring.", indid + i); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1997 |
continue; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1998 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
1999 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2000 |
switch (prop) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2001 |
case 0x08: { // Substitute industry type |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2002 |
IndustrySpec **indspec = &_cur_grffile->industryspec[indid + i]; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2003 |
byte subs_id = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2004 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2005 |
if (subs_id == 0xFF) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2006 |
/* Instead of defining a new industry, a substitute industry id |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2007 |
* of 0xFF disables the old industry with the current id. */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2008 |
_industry_specs[indid + i].enabled = false; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2009 |
continue; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2010 |
} else if (subs_id >= NEW_INDUSTRYOFFSET) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2011 |
/* The substitute id must be one of the original industry. */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2012 |
grfmsg(2, "_industry_specs: Attempt to use new industry %u as substitute industry for %u. Ignoring.", subs_id, indid + i); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2013 |
return false; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2014 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2015 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2016 |
/* Allocate space for this industry. |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2017 |
* Only need to do it once. If ever it is called again, it should not |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2018 |
* do anything */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2019 |
if (*indspec == NULL) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2020 |
*indspec = CallocT<IndustrySpec>(1); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2021 |
indsp = *indspec; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2022 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2023 |
memcpy(indsp, &_origin_industry_specs[subs_id], sizeof(_industry_specs[subs_id])); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2024 |
indsp->enabled = true; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2025 |
indsp->grf_prop.local_id = indid + i; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2026 |
indsp->grf_prop.subst_id = subs_id; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2027 |
indsp->grf_prop.grffile = _cur_grffile; |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2028 |
/* If the grf industry needs to check its surounding upon creation, it should |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2029 |
* rely on callbacks, not on the original placement functions */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2030 |
indsp->check_proc = CHECK_NOTHING; |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2031 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2032 |
} break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2033 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2034 |
case 0x09: { // Industry type override |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2035 |
byte ovrid = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2036 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2037 |
/* The industry being overridden must be an original industry. */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2038 |
if (ovrid >= NEW_INDUSTRYOFFSET) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2039 |
grfmsg(2, "IndustriesChangeInfo: Attempt to override new industry %u with industry id %u. Ignoring.", ovrid, indid + i); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2040 |
return false; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2041 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2042 |
indsp->grf_prop.override = ovrid; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2043 |
_industry_mngr.Add(indid + i, _cur_grffile->grfid, ovrid); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2044 |
} break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2045 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2046 |
case 0x0A: { // Set industry layout(s) |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2047 |
indsp->num_table = grf_load_byte(&buf); // Number of layaouts |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2048 |
uint32 defsize = grf_load_dword(&buf); // Total size of the definition |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2049 |
IndustryTileTable **tile_table = CallocT<IndustryTileTable*>(indsp->num_table); // Table with tiles to compose an industry |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2050 |
IndustryTileTable *itt = CallocT<IndustryTileTable>(defsize); // Temporary array to read the tile layouts from the GRF |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2051 |
int size; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2052 |
IndustryTileTable *copy_from; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2053 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2054 |
for (byte j = 0; j < indsp->num_table; j++) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2055 |
for (int k = 0;; k++) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2056 |
itt[k].ti.x = grf_load_byte(&buf); // Offsets from northermost tile |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2057 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2058 |
if (itt[k].ti.x == 0xFE && k == 0) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2059 |
/* This means we have to borrow the layout from an old industry */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2060 |
IndustryType type = grf_load_byte(&buf); //industry holding required layout |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2061 |
byte laynbr = grf_load_byte(&buf); //layout number to borrow |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2062 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2063 |
copy_from = (IndustryTileTable*)_origin_industry_specs[type].table[laynbr]; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2064 |
for (size = 1;; size++) { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2065 |
if (copy_from[size - 1].ti.x == -0x80 && copy_from[size - 1].ti.y == 0) break; |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2066 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2067 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2068 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2069 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2070 |
itt[k].ti.y = grf_load_byte(&buf); // Or table definition finalisation |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2071 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2072 |
if (itt[k].ti.x == 0 && itt[k].ti.y == 0x80) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2073 |
/* Not the same terminator. The one we are using is rather |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2074 |
x= -80, y = x . So, adjust it. */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2075 |
itt[k].ti.x = -0x80; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2076 |
itt[k].ti.y = 0; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2077 |
itt[k].gfx = 0; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2078 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2079 |
size = k + 1; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2080 |
copy_from = itt; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2081 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2082 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2083 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2084 |
itt[k].gfx = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2085 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2086 |
if (itt[k].gfx == 0xFE) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2087 |
/* Use a new tile from this GRF */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2088 |
int local_tile_id = grf_load_word(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2089 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2090 |
/* Read the ID from the _industile_mngr. */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2091 |
int tempid = _industile_mngr.GetID(local_tile_id, _cur_grffile->grfid); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2092 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2093 |
if (tempid == INVALID_INDUSTRYTILE) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2094 |
grfmsg(2, "IndustriesChangeInfo: Attempt to use industry tile %u with industry id %u, not yet defined. Ignoring.", local_tile_id, indid); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2095 |
} else { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2096 |
/* Declared as been valid, can be used */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2097 |
itt[k].gfx = tempid; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2098 |
size = k + 1; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2099 |
copy_from = itt; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2100 |
} |
9704 | 2101 |
} else if (itt[k].gfx == 0xFF) { |
2102 |
itt[k].ti.x = (int8)GB(itt[k].ti.x, 0, 8); |
|
2103 |
itt[k].ti.y = (int8)GB(itt[k].ti.y, 0, 8); |
|
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2104 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2105 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2106 |
tile_table[j] = CallocT<IndustryTileTable>(size); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2107 |
memcpy(tile_table[j], copy_from, sizeof(*copy_from) * size); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2108 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2109 |
/* Install final layout construction in the industry spec */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2110 |
indsp->table = tile_table; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2111 |
SetBit(indsp->cleanup_flag, 1); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2112 |
free(itt); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2113 |
} break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2114 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2115 |
case 0x0B: // Industry production flags |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2116 |
indsp->life_type = (IndustryLifeType)grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2117 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2118 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2119 |
case 0x0C: // Industry closure message |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2120 |
indsp->closure_text = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2121 |
_string_to_grf_mapping[&indsp->closure_text] = _cur_grffile->grfid; |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2122 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2123 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2124 |
case 0x0D: // Production increase message |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2125 |
indsp->production_up_text = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2126 |
_string_to_grf_mapping[&indsp->production_up_text] = _cur_grffile->grfid; |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2127 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2128 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2129 |
case 0x0E: // Production decrease message |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2130 |
indsp->production_down_text = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2131 |
_string_to_grf_mapping[&indsp->production_down_text] = _cur_grffile->grfid; |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2132 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2133 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2134 |
case 0x0F: // Fund cost multiplier |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2135 |
indsp->cost_multiplier = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2136 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2137 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2138 |
case 0x10: // Production cargo types |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2139 |
for (byte j = 0; j < 2; j++) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2140 |
indsp->produced_cargo[j] = GetCargoTranslation(grf_load_byte(&buf), _cur_grffile); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2141 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2142 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2143 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2144 |
case 0x11: // Acceptance cargo types |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2145 |
for (byte j = 0; j < 3; j++) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2146 |
indsp->accepts_cargo[j] = GetCargoTranslation(grf_load_byte(&buf), _cur_grffile); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2147 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2148 |
grf_load_byte(&buf); // Unnused, eat it up |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2149 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2150 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2151 |
case 0x12: // Production multipliers |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2152 |
case 0x13: |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2153 |
indsp->production_rate[prop - 0x12] = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2154 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2155 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2156 |
case 0x14: // Minimal amount of cargo distributed |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2157 |
indsp->minimal_cargo = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2158 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2159 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2160 |
case 0x15: { // Random sound effects |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2161 |
indsp->number_of_sounds = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2162 |
uint8 *sounds = MallocT<uint8>(indsp->number_of_sounds); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2163 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2164 |
for (uint8 j = 0; j < indsp->number_of_sounds; j++) sounds[j] = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2165 |
indsp->random_sounds = sounds; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2166 |
SetBit(indsp->cleanup_flag, 0); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2167 |
} break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2168 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2169 |
case 0x16: // Conflicting industry types |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2170 |
for (byte j = 0; j < 3; j++) indsp->conflicting[j] = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2171 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2172 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2173 |
case 0x17: // Probability in random game |
10776 | 2174 |
indsp->appear_creation[_settings_game.game_creation.landscape] = grf_load_byte(&buf); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2175 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2176 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2177 |
case 0x18: // Probability during gameplay |
10776 | 2178 |
indsp->appear_ingame[_settings_game.game_creation.landscape] = grf_load_byte(&buf); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2179 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2180 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2181 |
case 0x19: // Map color |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2182 |
indsp->map_colour = MapDOSColour(grf_load_byte(&buf)); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2183 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2184 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2185 |
case 0x1A: // Special industry flags to define special behavior |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2186 |
indsp->behaviour = (IndustryBehaviour)grf_load_dword(&buf); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2187 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2188 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2189 |
case 0x1B: // New industry text ID |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2190 |
indsp->new_industry_text = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2191 |
_string_to_grf_mapping[&indsp->new_industry_text] = _cur_grffile->grfid; |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2192 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2193 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2194 |
case 0x1C: // Input cargo multipliers for the three input cargo types |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2195 |
case 0x1D: |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2196 |
case 0x1E: { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2197 |
uint32 multiples = grf_load_dword(&buf); |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2198 |
indsp->input_cargo_multiplier[prop - 0x1C][0] = GB(multiples, 0, 15); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2199 |
indsp->input_cargo_multiplier[prop - 0x1C][1] = GB(multiples, 15, 15); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2200 |
} break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2201 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2202 |
case 0x1F: // Industry name |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2203 |
indsp->name = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2204 |
_string_to_grf_mapping[&indsp->name] = _cur_grffile->grfid; |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2205 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2206 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2207 |
case 0x20: // Prospecting success chance |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2208 |
indsp->prospecting_chance = grf_load_dword(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2209 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2210 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2211 |
case 0x21: // Callback flags |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2212 |
case 0x22: { // Callback additional flags |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2213 |
byte aflag = grf_load_byte(&buf); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2214 |
SB(indsp->callback_flags, (prop - 0x21) * 8, 8, aflag); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2215 |
} break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2216 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2217 |
case 0x23: // removal cost multiplier |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2218 |
indsp->removal_cost_multiplier = grf_load_dword(&buf); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2219 |
break; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2220 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2221 |
case 0x24: // name for nearby station |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2222 |
indsp->station_name = grf_load_word(&buf); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
2223 |
_string_to_grf_mapping[&indsp->station_name] = _cur_grffile->grfid; |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2224 |
break; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2225 |
|
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2226 |
default: |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2227 |
ret = true; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2228 |
break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2229 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2230 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2231 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2232 |
*bufp = buf; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2233 |
return ret; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2234 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2235 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2236 |
/* Action 0x00 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
2237 |
static void FeatureChangeInfo(byte *buf, size_t len) |
0 | 2238 |
{ |
2239 |
byte *bufend = buf + len; |
|
2240 |
||
2241 |
/* <00> <feature> <num-props> <num-info> <id> (<property <new-info>)... |
|
2242 |
* |
|
2243 |
* B feature 0, 1, 2 or 3 for trains, road vehicles, ships or planes |
|
2244 |
* 4 for defining new train station sets |
|
2245 |
* B num-props how many properties to change per vehicle/station |
|
2246 |
* B num-info how many vehicles/stations to change |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2247 |
* E id ID of first vehicle/station to change, if num-info is |
0 | 2248 |
* greater than one, this one and the following |
2249 |
* vehicles/stations will be changed |
|
2250 |
* B property what property to change, depends on the feature |
|
2251 |
* V new-info new bytes of info (variable size; depends on properties) */ |
|
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
2252 |
/* TODO: Bridges, town houses. */ |
0 | 2253 |
|
2438
eaef2b29fa3d
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
2254 |
static const VCI_Handler handler[] = { |
3825 | 2255 |
/* GSF_TRAIN */ RailVehicleChangeInfo, |
2256 |
/* GSF_ROAD */ RoadVehicleChangeInfo, |
|
2257 |
/* GSF_SHIP */ ShipVehicleChangeInfo, |
|
2258 |
/* GSF_AIRCRAFT */ AircraftVehicleChangeInfo, |
|
2259 |
/* GSF_STATION */ StationChangeInfo, |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2260 |
/* GSF_CANAL */ CanalChangeInfo, |
3825 | 2261 |
/* GSF_BRIDGE */ BridgeChangeInfo, |
9476 | 2262 |
/* GSF_TOWNHOUSE */ TownHouseChangeInfo, |
9732 | 2263 |
/* GSF_GLOBALVAR */ GlobalVarChangeInfo, |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2264 |
/* GSF_INDUSTRYTILES */IndustrytilesChangeInfo, |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
2265 |
/* GSF_INDUSTRIES */ IndustriesChangeInfo, |
9517 | 2266 |
/* GSF_CARGOS */ NULL, /* Cargo is handled during reservation */ |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
2267 |
/* GSF_SOUNDFX */ SoundEffectChangeInfo, |
0 | 2268 |
}; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
2269 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
2270 |
if (!check_length(len, 6, "FeatureChangeInfo")) return; |
3714
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
2271 |
buf++; |
6607 | 2272 |
uint8 feature = grf_load_byte(&buf); |
2273 |
uint8 numprops = grf_load_byte(&buf); |
|
6614
b41f2210a494
(svn r9108) -Fix(9093) : MSVC was a bit unhappy with some of the type changes. So basically, widening the types makes the difference
belugas
parents:
6610
diff
changeset
|
2274 |
uint numinfo = grf_load_byte(&buf); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2275 |
uint engine = grf_load_extended(&buf); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
2276 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2277 |
grfmsg(6, "FeatureChangeInfo: feature %d, %d properties, to apply to %d+%d", |
378
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
2278 |
feature, numprops, engine, numinfo); |
9f170b63d48e
(svn r567) -newgrf: Support for road vehicles customization (seems to work at
celestar
parents:
373
diff
changeset
|
2279 |
|
2440
443e2f3cce75
(svn r2966) Fix: newgrf: Replace special case with a check for the existence of a handler in VehicleChangeInfo.
peter1138
parents:
2439
diff
changeset
|
2280 |
if (feature >= lengthof(handler) || handler[feature] == NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2281 |
grfmsg(1, "FeatureChangeInfo: Unsupported feature %d, skipping", feature); |
391
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
2282 |
return; |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
2283 |
} |
573193308396
(svn r583) -newgrf: Hopefully prevent GRF files introducing new bridges or townhouses to crash the game (pasky).
darkvater
parents:
389
diff
changeset
|
2284 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2285 |
while (numprops-- && buf < bufend) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2286 |
uint8 prop = grf_load_byte(&buf); |
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
2287 |
bool ignoring = false; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2288 |
|
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
2289 |
switch (feature) { |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
2290 |
case GSF_TRAIN: |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
2291 |
case GSF_ROAD: |
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
2292 |
case GSF_SHIP: |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2293 |
case GSF_AIRCRAFT: { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2294 |
bool handled = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2295 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2296 |
for (uint i = 0; i < numinfo; i++) { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2297 |
Engine *e = GetNewEngine(_cur_grffile, (VehicleType)feature, engine + i); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2298 |
EngineInfo *ei = &e->info; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2299 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2300 |
/* Common properties for vehicles */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2301 |
switch (prop) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2302 |
case 0x00: // Introduction date |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2303 |
ei->base_intro = grf_load_word(&buf) + DAYS_TILL_ORIGINAL_BASE_YEAR; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2304 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2305 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2306 |
case 0x02: // Decay speed |
10867
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
2307 |
ei->decay_speed = grf_load_byte(&buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2308 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2309 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2310 |
case 0x03: // Vehicle life |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2311 |
ei->lifelength = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2312 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2313 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2314 |
case 0x04: // Model life |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2315 |
ei->base_life = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2316 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2317 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2318 |
case 0x06: // Climates available |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2319 |
ei->climates = grf_load_byte(&buf); |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2320 |
// XXX sometimes a grf wants hidden vehicles :o |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2321 |
if (ei->climates == 0) ei->climates = 0x80; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2322 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2323 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2324 |
case 0x07: // Loading speed |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2325 |
/* Hyronymus explained me what does |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2326 |
* this mean and insists on having a |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2327 |
* credit ;-). --pasky */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2328 |
ei->load_amount = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2329 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2330 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2331 |
default: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2332 |
handled = false; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2333 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2334 |
} |
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
2335 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2336 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2337 |
if (handled) break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2338 |
} /* FALL THROUGH */ |
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
2339 |
|
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
2340 |
default: |
6607 | 2341 |
if (handler[feature](engine, numinfo, prop, &buf, bufend - buf)) { |
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
2342 |
ignoring = true; |
6607 | 2343 |
} |
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
2344 |
break; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2345 |
} |
2421
7b6750d797bd
(svn r2947) Reorder some code to prepare for future enhancements and get rid of some gotos (peter1138)
tron
parents:
2400
diff
changeset
|
2346 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2347 |
if (ignoring) grfmsg(1, "FeatureChangeInfo: Ignoring property 0x%02X of feature 0x%02X (not implemented)", prop, feature); |
0 | 2348 |
} |
2349 |
} |
|
2350 |
||
5776
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2351 |
/* Action 0x00 (GLS_SAFETYSCAN) */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
2352 |
static void SafeChangeInfo(byte *buf, size_t len) |
5776
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2353 |
{ |
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
2354 |
if (!check_length(len, 6, "SafeChangeInfo")) return; |
5776
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2355 |
buf++; |
6607 | 2356 |
uint8 feature = grf_load_byte(&buf); |
2357 |
uint8 numprops = grf_load_byte(&buf); |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2358 |
grf_load_byte(&buf); // num-info |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2359 |
grf_load_extended(&buf); // id |
5776
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2360 |
|
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2361 |
if (feature == GSF_BRIDGE && numprops == 1) { |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2362 |
uint8 prop = grf_load_byte(&buf); |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2363 |
/* Bridge property 0x0D is redefinition of sprite layout tables, which |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2364 |
* is considered safe. */ |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2365 |
if (prop == 0x0D) return; |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2366 |
} |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2367 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2368 |
SetBit(_cur_grfconfig->flags, GCF_UNSAFE); |
5776
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2369 |
|
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2370 |
/* Skip remainder of GRF */ |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2371 |
_skip_sprites = -1; |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2372 |
} |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
2373 |
|
9517 | 2374 |
/* Action 0x00 (GLS_RESERVE) */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
2375 |
static void ReserveChangeInfo(byte *buf, size_t len) |
9517 | 2376 |
{ |
2377 |
byte *bufend = buf + len; |
|
2378 |
||
9732 | 2379 |
if (!check_length(len, 6, "ReserveChangeInfo")) return; |
9517 | 2380 |
buf++; |
2381 |
uint8 feature = grf_load_byte(&buf); |
|
2382 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2383 |
if (feature != GSF_CARGOS && feature != GSF_GLOBALVAR) return; |
9517 | 2384 |
|
2385 |
uint8 numprops = grf_load_byte(&buf); |
|
2386 |
uint8 numinfo = grf_load_byte(&buf); |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2387 |
uint8 index = grf_load_extended(&buf); |
9517 | 2388 |
|
2389 |
while (numprops-- && buf < bufend) { |
|
2390 |
uint8 prop = grf_load_byte(&buf); |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2391 |
bool ignoring = false; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2392 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2393 |
switch (feature) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2394 |
default: NOT_REACHED(); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2395 |
case GSF_CARGOS: |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2396 |
ignoring = CargoChangeInfo(index, numinfo, prop, &buf, bufend - buf); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2397 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2398 |
case GSF_GLOBALVAR: |
9732 | 2399 |
switch (prop) { |
2400 |
case 0x09: // Cargo Translation Table |
|
2401 |
if (index != 0) { |
|
2402 |
grfmsg(1, "ReserveChangeInfo: Cargo translation table must start at zero"); |
|
2403 |
return; |
|
2404 |
} |
|
2405 |
||
2406 |
free(_cur_grffile->cargo_list); |
|
2407 |
_cur_grffile->cargo_max = numinfo; |
|
2408 |
_cur_grffile->cargo_list = MallocT<CargoLabel>(numinfo); |
|
2409 |
||
2410 |
for (uint i = 0; i < numinfo; i++) { |
|
2411 |
CargoLabel cl = grf_load_dword(&buf); |
|
2412 |
_cur_grffile->cargo_list[i] = BSWAP32(cl); |
|
2413 |
} |
|
2414 |
break; |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2415 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2416 |
case 0x11: // GRF match for engine allocation |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2417 |
for (uint i = 0; i < numinfo; i++) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2418 |
uint32 s = grf_load_dword(&buf); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2419 |
uint32 t = grf_load_dword(&buf); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2420 |
SetNewGRFOverride(s, t); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2421 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
2422 |
break; |
9732 | 2423 |
} |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2424 |
break; |
9517 | 2425 |
} |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2426 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2427 |
if (ignoring) grfmsg(2, "ReserveChangeInfo: Ignoring property 0x%02X (not implemented)", prop); |
9517 | 2428 |
} |
2429 |
} |
|
2430 |
||
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2431 |
/** |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2432 |
* Creates a spritegroup representing a callback result |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2433 |
* @param value The value that was used to represent this callback result |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2434 |
* @return A spritegroup representing that callback result |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2435 |
*/ |
4893
07d158194395
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
2436 |
static const SpriteGroup* NewCallBackResultSpriteGroup(uint16 value) |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2437 |
{ |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2438 |
SpriteGroup *group = AllocateSpriteGroup(); |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2439 |
|
2488
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
2440 |
group->type = SGT_CALLBACK; |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2441 |
|
9505 | 2442 |
/* Old style callback results have the highest byte 0xFF so signify it is a callback result |
2443 |
* New style ones only have the highest bit set (allows 15-bit results, instead of just 8) */ |
|
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2444 |
if ((value >> 8) == 0xFF) { |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2445 |
value &= ~0xFF00; |
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2446 |
} else { |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2447 |
value &= ~0x8000; |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2448 |
} |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2449 |
|
2488
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
2450 |
group->g.callback.result = value; |
1883
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2451 |
|
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2452 |
return group; |
3b02000cfbe0
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2453 |
} |
0 | 2454 |
|
2489
88827d8ae517
(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
|
2455 |
/** |
88827d8ae517
(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
|
2456 |
* Creates a spritegroup representing a sprite number result. |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2457 |
* @param sprite The sprite number. |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2458 |
* @param num_sprites The number of sprites per set. |
2489
88827d8ae517
(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
|
2459 |
* @return A spritegroup representing the sprite number result. |
88827d8ae517
(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
|
2460 |
*/ |
4893
07d158194395
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
2461 |
static const SpriteGroup* NewResultSpriteGroup(SpriteID sprite, byte num_sprites) |
2489
88827d8ae517
(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
|
2462 |
{ |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2463 |
SpriteGroup *group = AllocateSpriteGroup(); |
2489
88827d8ae517
(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
|
2464 |
group->type = SGT_RESULT; |
3668
d7ed0a867b49
(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
|
2465 |
group->g.result.sprite = sprite; |
d7ed0a867b49
(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
|
2466 |
group->g.result.num_sprites = num_sprites; |
2489
88827d8ae517
(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
|
2467 |
return group; |
88827d8ae517
(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
|
2468 |
} |
88827d8ae517
(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
|
2469 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2470 |
/* Action 0x01 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
2471 |
static void NewSpriteSet(byte *buf, size_t len) |
0 | 2472 |
{ |
2473 |
/* <01> <feature> <num-sets> <num-ent> |
|
2474 |
* |
|
2475 |
* B feature feature to define sprites for |
|
2476 |
* 0, 1, 2, 3: veh-type, 4: train stations |
|
2477 |
* B num-sets number of sprite sets |
|
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2478 |
* E num-ent how many entries per sprite set |
0 | 2479 |
* For vehicles, this is the number of different |
2480 |
* vehicle directions in each sprite set |
|
2481 |
* Set num-dirs=8, unless your sprites are symmetric. |
|
2482 |
* In that case, use num-dirs=4. |
|
6607 | 2483 |
*/ |
0 | 2484 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
2485 |
if (!check_length(len, 4, "NewSpriteSet")) return; |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2486 |
buf++; |
6607 | 2487 |
uint8 feature = grf_load_byte(&buf); |
2488 |
uint8 num_sets = grf_load_byte(&buf); |
|
2489 |
uint16 num_ents = grf_load_extended(&buf); |
|
0 | 2490 |
|
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2491 |
_cur_grffile->spriteset_start = _cur_spriteid; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
2492 |
_cur_grffile->spriteset_feature = feature; |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2493 |
_cur_grffile->spriteset_numsets = num_sets; |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2494 |
_cur_grffile->spriteset_numents = num_ents; |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2495 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2496 |
grfmsg(7, "New sprite set at %d of type %d, consisting of %d sets with %d views each (total %d)", |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2497 |
_cur_spriteid, feature, num_sets, num_ents, num_sets * num_ents |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2498 |
); |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2499 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2500 |
for (int i = 0; i < num_sets * num_ents; i++) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2501 |
_nfo_line++; |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
2502 |
LoadNextSprite(_cur_spriteid++, _file_index, _nfo_line); |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2503 |
} |
0 | 2504 |
} |
2505 |
||
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2506 |
/* Action 0x01 (SKIP) */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
2507 |
static void SkipAct1(byte *buf, size_t len) |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2508 |
{ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2509 |
if (!check_length(len, 4, "SkipAct1")) return; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2510 |
buf++; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2511 |
grf_load_byte(&buf); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2512 |
uint8 num_sets = grf_load_byte(&buf); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2513 |
uint16 num_ents = grf_load_extended(&buf); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2514 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2515 |
_skip_sprites = num_sets * num_ents; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2516 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2517 |
grfmsg(3, "SkipAct1: Skipping %d sprites", _skip_sprites); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2518 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2519 |
|
3666
975cd26c8df7
(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
|
2520 |
/* Helper function to either create a callback or link to a previously |
975cd26c8df7
(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
|
2521 |
* defined spritegroup. */ |
4893
07d158194395
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
2522 |
static const SpriteGroup* GetGroupFromGroupID(byte setid, byte type, uint16 groupid) |
3666
975cd26c8df7
(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
|
2523 |
{ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2524 |
if (HasBit(groupid, 15)) return NewCallBackResultSpriteGroup(groupid); |
3666
975cd26c8df7
(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
|
2525 |
|
975cd26c8df7
(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
|
2526 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2527 |
grfmsg(1, "GetGroupFromGroupID(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty", setid, type, groupid); |
3666
975cd26c8df7
(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
|
2528 |
return NULL; |
975cd26c8df7
(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
|
2529 |
} |
975cd26c8df7
(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
|
2530 |
|
975cd26c8df7
(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
|
2531 |
return _cur_grffile->spritegroups[groupid]; |
975cd26c8df7
(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
|
2532 |
} |
975cd26c8df7
(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
|
2533 |
|
975cd26c8df7
(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
|
2534 |
/* Helper function to either create a callback or a result sprite group. */ |
4893
07d158194395
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
2535 |
static const SpriteGroup* CreateGroupFromGroupID(byte feature, byte setid, byte type, uint16 spriteid, uint16 num_sprites) |
3666
975cd26c8df7
(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
|
2536 |
{ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2537 |
if (HasBit(spriteid, 15)) return NewCallBackResultSpriteGroup(spriteid); |
3666
975cd26c8df7
(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
|
2538 |
|
3667
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2539 |
if (spriteid >= _cur_grffile->spriteset_numsets) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2540 |
grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Sprite set %u invalid, max %u", setid, type, spriteid, _cur_grffile->spriteset_numsets); |
3667
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2541 |
return NULL; |
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2542 |
} |
f87c17c36375
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2543 |
|
3666
975cd26c8df7
(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
|
2544 |
/* Check if the sprite is within range. This can fail if the Action 0x01 |
975cd26c8df7
(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
|
2545 |
* is skipped, as TTDPatch mandates that Action 0x02s must be processed. |
975cd26c8df7
(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
|
2546 |
* We don't have that rule, but must live by the Patch... */ |
975cd26c8df7
(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
|
2547 |
if (_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites > _cur_spriteid) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2548 |
grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Real Sprite IDs 0x%04X - 0x%04X do not (all) exist (max 0x%04X), leaving empty", |
3666
975cd26c8df7
(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
|
2549 |
setid, type, |
975cd26c8df7
(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
|
2550 |
_cur_grffile->spriteset_start + spriteid * num_sprites, |
975cd26c8df7
(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
|
2551 |
_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites - 1, _cur_spriteid - 1); |
975cd26c8df7
(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
|
2552 |
return NULL; |
975cd26c8df7
(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
|
2553 |
} |
975cd26c8df7
(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
|
2554 |
|
3803
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2555 |
if (feature != _cur_grffile->spriteset_feature) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2556 |
grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Sprite set feature 0x%02X does not match action feature 0x%02X, skipping", |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
2557 |
setid, type, |
3803
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2558 |
_cur_grffile->spriteset_feature, feature); |
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2559 |
return NULL; |
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2560 |
} |
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2561 |
|
3666
975cd26c8df7
(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
|
2562 |
return NewResultSpriteGroup(_cur_grffile->spriteset_start + spriteid * num_sprites, num_sprites); |
975cd26c8df7
(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
|
2563 |
} |
975cd26c8df7
(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
|
2564 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
2565 |
/* Action 0x02 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
2566 |
static void NewSpriteGroup(byte *buf, size_t len) |
0 | 2567 |
{ |
2568 |
/* <02> <feature> <set-id> <type/num-entries> <feature-specific-data...> |
|
2569 |
* |
|
2570 |
* B feature see action 1 |
|
2571 |
* B set-id ID of this particular definition |
|
2572 |
* B type/num-entries |
|
2573 |
* if 80 or greater, this is a randomized or variational |
|
2574 |
* list definition, see below |
|
2575 |
* otherwise it specifies a number of entries, the exact |
|
2576 |
* meaning depends on the feature |
|
2577 |
* V feature-specific-data (huge mess, don't even look it up --pasky) */ |
|
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2578 |
SpriteGroup *group = NULL; |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2579 |
byte *bufend = buf + len; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
74
diff
changeset
|
2580 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
2581 |
if (!check_length(len, 5, "NewSpriteGroup")) return; |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2582 |
buf++; |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2583 |
|
6607 | 2584 |
uint8 feature = grf_load_byte(&buf); |
2585 |
uint8 setid = grf_load_byte(&buf); |
|
2586 |
uint8 type = grf_load_byte(&buf); |
|
0 | 2587 |
|
2444
e618726432a4
(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
|
2588 |
if (setid >= _cur_grffile->spritegroups_count) { |
9505 | 2589 |
/* Allocate memory for new sprite group references. */ |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
2590 |
_cur_grffile->spritegroups = ReallocT(_cur_grffile->spritegroups, setid + 1); |
9505 | 2591 |
/* Initialise new space to NULL */ |
2488
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
2592 |
for (; _cur_grffile->spritegroups_count < (setid + 1); _cur_grffile->spritegroups_count++) |
cbe3d6b60c27
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
2593 |
_cur_grffile->spritegroups[_cur_grffile->spritegroups_count] = NULL; |
2444
e618726432a4
(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
|
2594 |
} |
e618726432a4
(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
|
2595 |
|
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2596 |
switch (type) { |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2597 |
/* Deterministic Sprite Group */ |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2598 |
case 0x81: // Self scope, byte |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2599 |
case 0x82: // Parent scope, byte |
3668
d7ed0a867b49
(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
|
2600 |
case 0x85: // Self scope, word |
d7ed0a867b49
(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
|
2601 |
case 0x86: // Parent scope, word |
d7ed0a867b49
(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
|
2602 |
case 0x89: // Self scope, dword |
d7ed0a867b49
(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
|
2603 |
case 0x8A: // Parent scope, dword |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2604 |
{ |
3668
d7ed0a867b49
(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
|
2605 |
byte varadjust; |
d7ed0a867b49
(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
|
2606 |
byte varsize; |
d7ed0a867b49
(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
|
2607 |
|
d7ed0a867b49
(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
|
2608 |
/* Check we can load the var size parameter */ |
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
2609 |
if (!check_length(bufend - buf, 1, "NewSpriteGroup (Deterministic) (1)")) return; |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2610 |
|
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2611 |
group = AllocateSpriteGroup(); |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2612 |
group->type = SGT_DETERMINISTIC; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2613 |
group->g.determ.var_scope = HasBit(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
3668
d7ed0a867b49
(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
|
2614 |
|
d7ed0a867b49
(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
|
2615 |
switch (GB(type, 2, 2)) { |
3672
73caf2e829f8
(svn r4588) - NewGRF: silence a false compiler warning
peter1138
parents:
3668
diff
changeset
|
2616 |
default: NOT_REACHED(); |
3668
d7ed0a867b49
(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
|
2617 |
case 0: group->g.determ.size = DSG_SIZE_BYTE; varsize = 1; break; |
d7ed0a867b49
(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
|
2618 |
case 1: group->g.determ.size = DSG_SIZE_WORD; varsize = 2; break; |
d7ed0a867b49
(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
|
2619 |
case 2: group->g.determ.size = DSG_SIZE_DWORD; varsize = 4; break; |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2620 |
} |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2621 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
2622 |
if (!check_length(bufend - buf, 5 + varsize, "NewSpriteGroup (Deterministic) (2)")) return; |
3668
d7ed0a867b49
(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
|
2623 |
|
d7ed0a867b49
(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
|
2624 |
/* Loop through the var adjusts. Unfortunately we don't know how many we have |
d7ed0a867b49
(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
|
2625 |
* from the outset, so we shall have to keep reallocing. */ |
d7ed0a867b49
(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
|
2626 |
do { |
d7ed0a867b49
(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
|
2627 |
DeterministicSpriteGroupAdjust *adjust; |
d7ed0a867b49
(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
|
2628 |
|
d7ed0a867b49
(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
|
2629 |
if (group->g.determ.num_adjusts > 0) { |
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
2630 |
if (!check_length(bufend - buf, 2 + varsize + 3, "NewSpriteGroup (Deterministic) (3)")) return; |
3668
d7ed0a867b49
(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
|
2631 |
} |
d7ed0a867b49
(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
|
2632 |
|
d7ed0a867b49
(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
|
2633 |
group->g.determ.num_adjusts++; |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
2634 |
group->g.determ.adjusts = ReallocT(group->g.determ.adjusts, group->g.determ.num_adjusts); |
3668
d7ed0a867b49
(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
|
2635 |
|
d7ed0a867b49
(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
|
2636 |
adjust = &group->g.determ.adjusts[group->g.determ.num_adjusts - 1]; |
d7ed0a867b49
(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
|
2637 |
|
d7ed0a867b49
(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
|
2638 |
/* The first var adjust doesn't have an operation specified, so we set it to add. */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
2639 |
adjust->operation = group->g.determ.num_adjusts == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)grf_load_byte(&buf); |
3668
d7ed0a867b49
(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
|
2640 |
adjust->variable = grf_load_byte(&buf); |
5868
baa704b6dc4f
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5860
diff
changeset
|
2641 |
if (adjust->variable == 0x7E) { |
baa704b6dc4f
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5860
diff
changeset
|
2642 |
/* Link subroutine group */ |
baa704b6dc4f
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5860
diff
changeset
|
2643 |
adjust->subroutine = GetGroupFromGroupID(setid, type, grf_load_byte(&buf)); |
baa704b6dc4f
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5860
diff
changeset
|
2644 |
} else { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2645 |
adjust->parameter = IsInsideMM(adjust->variable, 0x60, 0x80) ? grf_load_byte(&buf) : 0; |
5868
baa704b6dc4f
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5860
diff
changeset
|
2646 |
} |
3668
d7ed0a867b49
(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
|
2647 |
|
d7ed0a867b49
(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
|
2648 |
varadjust = grf_load_byte(&buf); |
d7ed0a867b49
(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
|
2649 |
adjust->shift_num = GB(varadjust, 0, 5); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
2650 |
adjust->type = (DeterministicSpriteGroupAdjustType)GB(varadjust, 6, 2); |
3668
d7ed0a867b49
(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
|
2651 |
adjust->and_mask = grf_load_var(varsize, &buf); |
d7ed0a867b49
(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
|
2652 |
|
d7ed0a867b49
(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
|
2653 |
if (adjust->type != DSGA_TYPE_NONE) { |
d7ed0a867b49
(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
|
2654 |
adjust->add_val = grf_load_var(varsize, &buf); |
d7ed0a867b49
(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
|
2655 |
adjust->divmod_val = grf_load_var(varsize, &buf); |
d7ed0a867b49
(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
|
2656 |
} else { |
d7ed0a867b49
(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
|
2657 |
adjust->add_val = 0; |
d7ed0a867b49
(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
|
2658 |
adjust->divmod_val = 0; |
d7ed0a867b49
(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
|
2659 |
} |
d7ed0a867b49
(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
|
2660 |
|
d7ed0a867b49
(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
|
2661 |
/* Continue reading var adjusts while bit 5 is set. */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2662 |
} while (HasBit(varadjust, 5)); |
3668
d7ed0a867b49
(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
|
2663 |
|
d7ed0a867b49
(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
|
2664 |
group->g.determ.num_ranges = grf_load_byte(&buf); |
9624 | 2665 |
if (group->g.determ.num_ranges > 0) group->g.determ.ranges = CallocT<DeterministicSpriteGroupRange>(group->g.determ.num_ranges); |
3668
d7ed0a867b49
(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
|
2666 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
2667 |
if (!check_length(bufend - buf, 2 + (2 + 2 * varsize) * group->g.determ.num_ranges, "NewSpriteGroup (Deterministic)")) return; |
3668
d7ed0a867b49
(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
|
2668 |
|
6607 | 2669 |
for (uint i = 0; i < group->g.determ.num_ranges; i++) { |
3668
d7ed0a867b49
(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
|
2670 |
group->g.determ.ranges[i].group = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
d7ed0a867b49
(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
|
2671 |
group->g.determ.ranges[i].low = grf_load_var(varsize, &buf); |
d7ed0a867b49
(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
|
2672 |
group->g.determ.ranges[i].high = grf_load_var(varsize, &buf); |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2673 |
} |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2674 |
|
3668
d7ed0a867b49
(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
|
2675 |
group->g.determ.default_group = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2676 |
break; |
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
441
diff
changeset
|
2677 |
} |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
441
diff
changeset
|
2678 |
|
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2679 |
/* Randomized Sprite Group */ |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2680 |
case 0x80: // Self scope |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2681 |
case 0x83: // Parent scope |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
2682 |
case 0x84: // Relative scope |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2683 |
{ |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
2684 |
if (!check_length(bufend - buf, HasBit(type, 2) ? 8 : 7, "NewSpriteGroup (Randomized) (1)")) return; |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2685 |
|
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2686 |
group = AllocateSpriteGroup(); |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2687 |
group->type = SGT_RANDOMIZED; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2688 |
group->g.random.var_scope = HasBit(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
3668
d7ed0a867b49
(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
|
2689 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
2690 |
if (HasBit(type, 2)) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
2691 |
if (feature <= GSF_AIRCRAFT) group->g.random.var_scope = VSG_SCOPE_RELATIVE; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
2692 |
group->g.random.count = grf_load_byte(&buf); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
2693 |
} |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
2694 |
|
6607 | 2695 |
uint8 triggers = grf_load_byte(&buf); |
3668
d7ed0a867b49
(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
|
2696 |
group->g.random.triggers = GB(triggers, 0, 7); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2697 |
group->g.random.cmp_mode = HasBit(triggers, 7) ? RSG_CMP_ALL : RSG_CMP_ANY; |
3668
d7ed0a867b49
(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
|
2698 |
group->g.random.lowest_randbit = grf_load_byte(&buf); |
d7ed0a867b49
(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
|
2699 |
group->g.random.num_groups = grf_load_byte(&buf); |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
2700 |
group->g.random.groups = CallocT<const SpriteGroup*>(group->g.random.num_groups); |
3668
d7ed0a867b49
(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
|
2701 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
2702 |
if (!check_length(bufend - buf, 2 * group->g.random.num_groups, "NewSpriteGroup (Randomized) (2)")) return; |
3668
d7ed0a867b49
(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
|
2703 |
|
6607 | 2704 |
for (uint i = 0; i < group->g.random.num_groups; i++) { |
3668
d7ed0a867b49
(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
|
2705 |
group->g.random.groups[i] = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2706 |
} |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2707 |
|
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2708 |
break; |
2489
88827d8ae517
(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
|
2709 |
} |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2710 |
|
3668
d7ed0a867b49
(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
|
2711 |
/* Neither a variable or randomized sprite group... must be a real group */ |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2712 |
default: |
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2713 |
{ |
3803
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2714 |
|
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2715 |
|
3668
d7ed0a867b49
(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
|
2716 |
switch (feature) { |
d7ed0a867b49
(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
|
2717 |
case GSF_TRAIN: |
d7ed0a867b49
(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
|
2718 |
case GSF_ROAD: |
d7ed0a867b49
(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
|
2719 |
case GSF_SHIP: |
d7ed0a867b49
(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
|
2720 |
case GSF_AIRCRAFT: |
d7ed0a867b49
(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
|
2721 |
case GSF_STATION: |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2722 |
case GSF_CANAL: |
9517 | 2723 |
case GSF_CARGOS: |
3668
d7ed0a867b49
(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
|
2724 |
{ |
d7ed0a867b49
(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
|
2725 |
byte sprites = _cur_grffile->spriteset_numents; |
d7ed0a867b49
(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
|
2726 |
byte num_loaded = type; |
d7ed0a867b49
(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
|
2727 |
byte num_loading = grf_load_byte(&buf); |
d7ed0a867b49
(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
|
2728 |
|
d7ed0a867b49
(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
|
2729 |
if (_cur_grffile->spriteset_start == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2730 |
grfmsg(0, "NewSpriteGroup: No sprite set to work on! Skipping"); |
3668
d7ed0a867b49
(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
|
2731 |
return; |
d7ed0a867b49
(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
|
2732 |
} |
d7ed0a867b49
(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
|
2733 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
2734 |
if (!check_length(bufend - buf, 2 * num_loaded + 2 * num_loading, "NewSpriteGroup (Real) (1)")) return; |
3668
d7ed0a867b49
(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
|
2735 |
|
d7ed0a867b49
(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
|
2736 |
group = AllocateSpriteGroup(); |
d7ed0a867b49
(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
|
2737 |
group->type = SGT_REAL; |
d7ed0a867b49
(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
|
2738 |
|
d7ed0a867b49
(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
|
2739 |
group->g.real.num_loaded = num_loaded; |
d7ed0a867b49
(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
|
2740 |
group->g.real.num_loading = num_loading; |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
2741 |
if (num_loaded > 0) group->g.real.loaded = CallocT<const SpriteGroup*>(num_loaded); |
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
2742 |
if (num_loading > 0) group->g.real.loading = CallocT<const SpriteGroup*>(num_loading); |
3668
d7ed0a867b49
(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
|
2743 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2744 |
grfmsg(6, "NewSpriteGroup: New SpriteGroup 0x%02X, %u views, %u loaded, %u loading", |
3668
d7ed0a867b49
(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
|
2745 |
setid, sprites, num_loaded, num_loading); |
d7ed0a867b49
(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
|
2746 |
|
6607 | 2747 |
for (uint i = 0; i < num_loaded; i++) { |
3668
d7ed0a867b49
(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
|
2748 |
uint16 spriteid = grf_load_word(&buf); |
3803
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2749 |
group->g.real.loaded[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2750 |
grfmsg(8, "NewSpriteGroup: + rg->loaded[%i] = subset %u", i, spriteid); |
3668
d7ed0a867b49
(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
|
2751 |
} |
d7ed0a867b49
(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
|
2752 |
|
6607 | 2753 |
for (uint i = 0; i < num_loading; i++) { |
3668
d7ed0a867b49
(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
|
2754 |
uint16 spriteid = grf_load_word(&buf); |
3803
1bd124196372
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2755 |
group->g.real.loading[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2756 |
grfmsg(8, "NewSpriteGroup: + rg->loading[%i] = subset %u", i, spriteid); |
3668
d7ed0a867b49
(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
|
2757 |
} |
d7ed0a867b49
(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
|
2758 |
|
d7ed0a867b49
(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
|
2759 |
break; |
d7ed0a867b49
(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
|
2760 |
} |
d7ed0a867b49
(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
|
2761 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2762 |
case GSF_TOWNHOUSE: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2763 |
case GSF_INDUSTRYTILES: { |
9476 | 2764 |
byte sprites = _cur_grffile->spriteset_numents; |
2765 |
byte num_sprites = max((uint8)1, type); |
|
2766 |
uint i; |
|
2767 |
||
2768 |
group = AllocateSpriteGroup(); |
|
2769 |
group->type = SGT_TILELAYOUT; |
|
2770 |
group->g.layout.num_sprites = sprites; |
|
2771 |
group->g.layout.dts = CallocT<DrawTileSprites>(1); |
|
2772 |
||
2773 |
/* Groundsprite */ |
|
9732 | 2774 |
group->g.layout.dts->ground.sprite = grf_load_word(&buf); |
2775 |
group->g.layout.dts->ground.pal = grf_load_word(&buf); |
|
2776 |
||
9476 | 2777 |
/* Remap transparent/colour modifier bits */ |
9732 | 2778 |
MapSpriteMappingRecolour(&group->g.layout.dts->ground); |
2779 |
||
2780 |
if (HasBit(group->g.layout.dts->ground.pal, 15)) { |
|
9476 | 2781 |
/* Bit 31 set means this is a custom sprite, so rewrite it to the |
2782 |
* last spriteset defined. */ |
|
9732 | 2783 |
SpriteID sprite = _cur_grffile->spriteset_start + GB(group->g.layout.dts->ground.sprite, 0, 14) * sprites; |
2784 |
SB(group->g.layout.dts->ground.sprite, 0, SPRITE_WIDTH, sprite); |
|
2785 |
ClrBit(group->g.layout.dts->ground.pal, 15); |
|
9476 | 2786 |
} |
2787 |
||
2788 |
group->g.layout.dts->seq = CallocT<DrawTileSeqStruct>(num_sprites + 1); |
|
2789 |
||
2790 |
for (i = 0; i < num_sprites; i++) { |
|
2791 |
DrawTileSeqStruct *seq = (DrawTileSeqStruct*)&group->g.layout.dts->seq[i]; |
|
2792 |
||
9732 | 2793 |
seq->image.sprite = grf_load_word(&buf); |
2794 |
seq->image.pal = grf_load_word(&buf); |
|
9476 | 2795 |
seq->delta_x = grf_load_byte(&buf); |
2796 |
seq->delta_y = grf_load_byte(&buf); |
|
2797 |
||
9732 | 2798 |
MapSpriteMappingRecolour(&seq->image); |
2799 |
||
2800 |
if (HasBit(seq->image.pal, 15)) { |
|
9476 | 2801 |
/* Bit 31 set means this is a custom sprite, so rewrite it to the |
2802 |
* last spriteset defined. */ |
|
9732 | 2803 |
SpriteID sprite = _cur_grffile->spriteset_start + GB(seq->image.sprite, 0, 14) * sprites; |
2804 |
SB(seq->image.sprite, 0, SPRITE_WIDTH, sprite); |
|
2805 |
ClrBit(seq->image.pal, 15); |
|
9476 | 2806 |
} |
2807 |
||
2808 |
if (type > 0) { |
|
2809 |
seq->delta_z = grf_load_byte(&buf); |
|
2810 |
if ((byte)seq->delta_z == 0x80) continue; |
|
2811 |
} |
|
2812 |
||
2813 |
seq->size_x = grf_load_byte(&buf); |
|
2814 |
seq->size_y = grf_load_byte(&buf); |
|
2815 |
seq->size_z = grf_load_byte(&buf); |
|
2816 |
} |
|
2817 |
||
2818 |
/* Set the terminator value. */ |
|
2819 |
((DrawTileSeqStruct*)group->g.layout.dts->seq)[i].delta_x = (byte)0x80; |
|
2820 |
||
2821 |
break; |
|
2822 |
} |
|
2823 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2824 |
case GSF_INDUSTRIES: { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2825 |
if (type > 1) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2826 |
grfmsg(1, "NewSpriteGroup: Unsupported industry production version %d, skipping", type); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2827 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2828 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2829 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2830 |
group = AllocateSpriteGroup(); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2831 |
group->type = SGT_INDUSTRY_PRODUCTION; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2832 |
group->g.indprod.version = type; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2833 |
if (type == 0) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2834 |
for (uint i = 0; i < 3; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2835 |
group->g.indprod.substract_input[i] = grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2836 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2837 |
for (uint i = 0; i < 2; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2838 |
group->g.indprod.add_output[i] = grf_load_word(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2839 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2840 |
group->g.indprod.again = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2841 |
} else { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2842 |
for (uint i = 0; i < 3; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2843 |
group->g.indprod.substract_input[i] = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2844 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2845 |
for (uint i = 0; i < 2; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2846 |
group->g.indprod.add_output[i] = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2847 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2848 |
group->g.indprod.again = grf_load_byte(&buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2849 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2850 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2851 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2852 |
|
3668
d7ed0a867b49
(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
|
2853 |
/* Loading of Tile Layout and Production Callback groups would happen here */ |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
2854 |
default: grfmsg(1, "NewSpriteGroup: Unsupported feature %d, skipping", feature); |
3633
414a50db1ac3
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2855 |
} |
2489
88827d8ae517
(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
|
2856 |
} |
0 | 2857 |
} |
2444
e618726432a4
(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
|
2858 |
|
e618726432a4
(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
|
2859 |
_cur_grffile->spritegroups[setid] = group; |
0 | 2860 |
} |
2861 |
||
6469
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2862 |
static CargoID TranslateCargo(uint8 feature, uint8 ctype) |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2863 |
{ |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2864 |
/* Special cargo types for purchase list and stations */ |
6474
24e7ceeb25f5
(svn r8891) -Codechange: Remove remains of global cargo scheme. All cargo mapping is now dealt with only in NewGRF code, on load where possible.
peter1138
parents:
6473
diff
changeset
|
2865 |
if (feature == GSF_STATION && ctype == 0xFE) return CT_DEFAULT_NA; |
24e7ceeb25f5
(svn r8891) -Codechange: Remove remains of global cargo scheme. All cargo mapping is now dealt with only in NewGRF code, on load where possible.
peter1138
parents:
6473
diff
changeset
|
2866 |
if (ctype == 0xFF) return CT_PURCHASE; |
6469
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2867 |
|
9517 | 2868 |
if (_cur_grffile->cargo_max == 0) { |
2869 |
/* No cargo table, so use bitnum values */ |
|
2870 |
if (ctype >= 32) { |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2871 |
grfmsg(1, "TranslateCargo: Cargo bitnum %d out of range (max 31), skipping.", ctype); |
9517 | 2872 |
return CT_INVALID; |
2873 |
} |
|
2874 |
||
2875 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
|
2876 |
const CargoSpec *cs = GetCargo(c); |
|
2877 |
if (!cs->IsValid()) continue; |
|
2878 |
||
2879 |
if (cs->bitnum == ctype) { |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2880 |
grfmsg(6, "TranslateCargo: Cargo bitnum %d mapped to cargo type %d.", ctype, c); |
9517 | 2881 |
return c; |
2882 |
} |
|
2883 |
} |
|
2884 |
||
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2885 |
grfmsg(5, "TranslateCargo: Cargo bitnum %d not available in this climate, skipping.", ctype); |
9517 | 2886 |
return CT_INVALID; |
2887 |
} |
|
2888 |
||
6469
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2889 |
/* Check if the cargo type is out of bounds of the cargo translation table */ |
9517 | 2890 |
if (ctype >= _cur_grffile->cargo_max) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2891 |
grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, _cur_grffile->cargo_max - 1); |
6469
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2892 |
return CT_INVALID; |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2893 |
} |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2894 |
|
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2895 |
/* Look up the cargo label from the translation table */ |
9517 | 2896 |
CargoLabel cl = _cur_grffile->cargo_list[ctype]; |
6469
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2897 |
if (cl == 0) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2898 |
grfmsg(5, "TranslateCargo: Cargo type %d not available in this climate, skipping.", ctype); |
6469
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2899 |
return CT_INVALID; |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2900 |
} |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2901 |
|
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2902 |
ctype = GetCargoIDByLabel(cl); |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2903 |
if (ctype == CT_INVALID) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2904 |
grfmsg(5, "TranslateCargo: Cargo '%c%c%c%c' unsupported, skipping.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8)); |
6469
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2905 |
return CT_INVALID; |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2906 |
} |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2907 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2908 |
grfmsg(6, "TranslateCargo: Cargo '%c%c%c%c' mapped to cargo type %d.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8), ctype); |
6469
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2909 |
return ctype; |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2910 |
} |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6468
diff
changeset
|
2911 |
|
9517 | 2912 |
|
10829 | 2913 |
static bool IsValidGroupID(uint16 groupid, const char *function) |
2914 |
{ |
|
2915 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
|
2916 |
grfmsg(1, "%s: Spriteset 0x%04X out of range (maximum 0x%02X) or empty, skipping.", function, groupid, _cur_grffile->spritegroups_count - 1); |
|
2917 |
return false; |
|
2918 |
} |
|
2919 |
||
2920 |
return true; |
|
2921 |
} |
|
2922 |
||
2923 |
static void VehicleMapSpriteGroup(byte *buf, byte feature, uint8 idcount) |
|
0 | 2924 |
{ |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2925 |
static EngineID *last_engines; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2926 |
static uint last_engines_count; |
10829 | 2927 |
bool wagover = false; |
2928 |
||
2929 |
/* Test for 'wagon override' flag */ |
|
2930 |
if (HasBit(idcount, 7)) { |
|
2931 |
wagover = true; |
|
2932 |
/* Strip off the flag */ |
|
2933 |
idcount = GB(idcount, 0, 7); |
|
2934 |
||
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
2935 |
if (last_engines_count == 0) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2936 |
grfmsg(0, "VehicleMapSpriteGroup: WagonOverride: No engine to do override with"); |
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
2937 |
return; |
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
2938 |
} |
9517 | 2939 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2940 |
grfmsg(6, "VehicleMapSpriteGroup: WagonOverride: %u engines, %u wagons", |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
2941 |
last_engines_count, idcount); |
10829 | 2942 |
} else { |
2943 |
if (last_engines_count != idcount) { |
|
2944 |
last_engines = ReallocT(last_engines, idcount); |
|
2945 |
last_engines_count = idcount; |
|
2946 |
} |
|
372
1cc9354e2362
(svn r560) -newgrf: General cleanup of the code (pasky & octo)
celestar
parents:
369
diff
changeset
|
2947 |
} |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
2948 |
|
10920 | 2949 |
EngineID *engines = AllocaM(EngineID, idcount); |
6607 | 2950 |
for (uint i = 0; i < idcount; i++) { |
10829 | 2951 |
engines[i] = GetNewEngine(_cur_grffile, (VehicleType)feature, grf_load_byte(&buf))->index; |
2952 |
if (!wagover) last_engines[i] = engines[i]; |
|
2953 |
} |
|
2954 |
||
2955 |
uint8 cidcount = grf_load_byte(&buf); |
|
2956 |
for (uint c = 0; c < cidcount; c++) { |
|
2957 |
uint8 ctype = grf_load_byte(&buf); |
|
2958 |
uint16 groupid = grf_load_word(&buf); |
|
2959 |
if (!IsValidGroupID(groupid, "VehicleMapSpriteGroup")) continue; |
|
2960 |
||
2961 |
grfmsg(8, "VehicleMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid); |
|
2962 |
||
2963 |
ctype = TranslateCargo(feature, ctype); |
|
2964 |
if (ctype == CT_INVALID) continue; |
|
2965 |
||
2966 |
for (uint i = 0; i < idcount; i++) { |
|
2967 |
EngineID engine = engines[i]; |
|
2968 |
||
2969 |
grfmsg(7, "VehicleMapSpriteGroup: [%d] Engine %d...", i, engine); |
|
5338
5b48218d8bd2
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5334
diff
changeset
|
2970 |
|
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
2971 |
if (wagover) { |
4869
cded5f3a83c9
(svn r6795) - NewGRF: Add support for cargo-specific wagon overrides.
peter1138
parents:
4818
diff
changeset
|
2972 |
SetWagonOverrideSprites(engine, ctype, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2973 |
} else { |
2444
e618726432a4
(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
|
2974 |
SetCustomEngineSprites(engine, ctype, _cur_grffile->spritegroups[groupid]); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2975 |
} |
0 | 2976 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
2977 |
} |
0 | 2978 |
|
10829 | 2979 |
uint16 groupid = grf_load_word(&buf); |
2980 |
if (!IsValidGroupID(groupid, "VehicleMapSpriteGroup")) return; |
|
2981 |
||
2982 |
grfmsg(8, "-- Default group id 0x%04X", groupid); |
|
2983 |
||
2984 |
for (uint i = 0; i < idcount; i++) { |
|
2985 |
EngineID engine = engines[i]; |
|
2986 |
||
2987 |
if (wagover) { |
|
2988 |
SetWagonOverrideSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
|
2989 |
} else { |
|
2990 |
SetCustomEngineSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid]); |
|
2991 |
SetEngineGRF(engine, _cur_grffile); |
|
0 | 2992 |
} |
2993 |
} |
|
2994 |
} |
|
2995 |
||
9517 | 2996 |
|
10829 | 2997 |
static void CanalMapSpriteGroup(byte *buf, uint8 idcount) |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2998 |
{ |
10920 | 2999 |
CanalFeature *cfs = AllocaM(CanalFeature, idcount); |
10829 | 3000 |
for (uint i = 0; i < idcount; i++) { |
3001 |
cfs[i] = (CanalFeature)grf_load_byte(&buf); |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3002 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3003 |
|
10829 | 3004 |
uint8 cidcount = grf_load_byte(&buf); |
3005 |
buf += cidcount * 3; |
|
3006 |
||
3007 |
uint16 groupid = grf_load_word(&buf); |
|
3008 |
if (!IsValidGroupID(groupid, "CanalMapSpriteGroup")) return; |
|
3009 |
||
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3010 |
for (uint i = 0; i < idcount; i++) { |
10829 | 3011 |
CanalFeature cf = cfs[i]; |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3012 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3013 |
if (cf >= CF_END) { |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3014 |
grfmsg(1, "CanalMapSpriteGroup: Canal subset %d out of range, skipping", cf); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3015 |
continue; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3016 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3017 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3018 |
_water_feature[cf].group = _cur_grffile->spritegroups[groupid]; |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3019 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3020 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3021 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3022 |
|
10829 | 3023 |
static void StationMapSpriteGroup(byte *buf, uint8 idcount) |
9517 | 3024 |
{ |
10920 | 3025 |
uint8 *stations = AllocaM(uint8, idcount); |
9517 | 3026 |
for (uint i = 0; i < idcount; i++) { |
10829 | 3027 |
stations[i] = grf_load_byte(&buf); |
3028 |
} |
|
3029 |
||
3030 |
uint8 cidcount = grf_load_byte(&buf); |
|
3031 |
for (uint c = 0; c < cidcount; c++) { |
|
3032 |
uint8 ctype = grf_load_byte(&buf); |
|
3033 |
uint16 groupid = grf_load_word(&buf); |
|
3034 |
if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) continue; |
|
3035 |
||
3036 |
ctype = TranslateCargo(GSF_STATION, ctype); |
|
3037 |
if (ctype == CT_INVALID) continue; |
|
3038 |
||
3039 |
for (uint i = 0; i < idcount; i++) { |
|
3040 |
StationSpec *statspec = _cur_grffile->stations[stations[i]]; |
|
3041 |
||
3042 |
if (statspec == NULL) { |
|
3043 |
grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stations[i]); |
|
3044 |
return; |
|
9517 | 3045 |
} |
3046 |
||
3047 |
statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid]; |
|
3048 |
} |
|
3049 |
} |
|
3050 |
||
10829 | 3051 |
uint16 groupid = grf_load_word(&buf); |
3052 |
if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) return; |
|
3053 |
||
3054 |
for (uint i = 0; i < idcount; i++) { |
|
3055 |
StationSpec *statspec = _cur_grffile->stations[stations[i]]; |
|
3056 |
||
3057 |
if (statspec == NULL) { |
|
3058 |
grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stations[i]); |
|
3059 |
continue; |
|
9517 | 3060 |
} |
3061 |
||
10829 | 3062 |
statspec->spritegroup[CT_DEFAULT] = _cur_grffile->spritegroups[groupid]; |
3063 |
statspec->grffile = _cur_grffile; |
|
3064 |
statspec->localidx = stations[i]; |
|
3065 |
SetCustomStationSpec(statspec); |
|
9517 | 3066 |
} |
3067 |
} |
|
3068 |
||
3069 |
||
10829 | 3070 |
static void TownHouseMapSpriteGroup(byte *buf, uint8 idcount) |
9517 | 3071 |
{ |
10920 | 3072 |
uint8 *houses = AllocaM(uint8, idcount); |
10829 | 3073 |
for (uint i = 0; i < idcount; i++) { |
3074 |
houses[i] = grf_load_byte(&buf); |
|
9517 | 3075 |
} |
3076 |
||
10829 | 3077 |
/* Skip the cargo type section, we only care about the default group */ |
3078 |
uint8 cidcount = grf_load_byte(&buf); |
|
3079 |
buf += cidcount * 3; |
|
3080 |
||
3081 |
uint16 groupid = grf_load_word(&buf); |
|
3082 |
if (!IsValidGroupID(groupid, "TownHouseMapSpriteGroup")) return; |
|
3083 |
||
9517 | 3084 |
for (uint i = 0; i < idcount; i++) { |
10829 | 3085 |
HouseSpec *hs = _cur_grffile->housespec[houses[i]]; |
9517 | 3086 |
|
3087 |
if (hs == NULL) { |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
3088 |
grfmsg(1, "TownHouseMapSpriteGroup: Too many houses defined, skipping"); |
9517 | 3089 |
return; |
3090 |
} |
|
3091 |
||
3092 |
hs->spritegroup = _cur_grffile->spritegroups[groupid]; |
|
3093 |
} |
|
3094 |
} |
|
3095 |
||
10829 | 3096 |
static void IndustryMapSpriteGroup(byte *buf, uint8 idcount) |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3097 |
{ |
10920 | 3098 |
uint8 *industries = AllocaM(uint8, idcount); |
10829 | 3099 |
for (uint i = 0; i < idcount; i++) { |
3100 |
industries[i] = grf_load_byte(&buf); |
|
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3101 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3102 |
|
10829 | 3103 |
/* Skip the cargo type section, we only care about the default group */ |
3104 |
uint8 cidcount = grf_load_byte(&buf); |
|
3105 |
buf += cidcount * 3; |
|
3106 |
||
3107 |
uint16 groupid = grf_load_word(&buf); |
|
3108 |
if (!IsValidGroupID(groupid, "IndustryMapSpriteGroup")) return; |
|
3109 |
||
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3110 |
for (uint i = 0; i < idcount; i++) { |
10829 | 3111 |
IndustrySpec *indsp = _cur_grffile->industryspec[industries[i]]; |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3112 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3113 |
if (indsp == NULL) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3114 |
grfmsg(1, "IndustryMapSpriteGroup: Too many industries defined, skipping"); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3115 |
return; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3116 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3117 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3118 |
indsp->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid]; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3119 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3120 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3121 |
|
10829 | 3122 |
static void IndustrytileMapSpriteGroup(byte *buf, uint8 idcount) |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3123 |
{ |
10920 | 3124 |
uint8 *indtiles = AllocaM(uint8, idcount); |
10829 | 3125 |
for (uint i = 0; i < idcount; i++) { |
3126 |
indtiles[i] = grf_load_byte(&buf); |
|
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3127 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3128 |
|
10829 | 3129 |
/* Skip the cargo type section, we only care about the default group */ |
3130 |
uint8 cidcount = grf_load_byte(&buf); |
|
3131 |
buf += cidcount * 3; |
|
3132 |
||
3133 |
uint16 groupid = grf_load_word(&buf); |
|
3134 |
if (!IsValidGroupID(groupid, "IndustrytileMapSpriteGroup")) return; |
|
3135 |
||
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3136 |
for (uint i = 0; i < idcount; i++) { |
10829 | 3137 |
IndustryTileSpec *indtsp = _cur_grffile->indtspec[indtiles[i]]; |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3138 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3139 |
if (indtsp == NULL) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3140 |
grfmsg(1, "IndustrytileMapSpriteGroup: Too many industry tiles defined, skipping"); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3141 |
return; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3142 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3143 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3144 |
indtsp->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid]; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3145 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3146 |
} |
9517 | 3147 |
|
10829 | 3148 |
static void CargoMapSpriteGroup(byte *buf, uint8 idcount) |
9517 | 3149 |
{ |
10920 | 3150 |
CargoID *cargos = AllocaM(CargoID, idcount); |
10829 | 3151 |
for (uint i = 0; i < idcount; i++) { |
3152 |
cargos[i] = grf_load_byte(&buf); |
|
9517 | 3153 |
} |
3154 |
||
10829 | 3155 |
/* Skip the cargo type section, we only care about the default group */ |
3156 |
uint8 cidcount = grf_load_byte(&buf); |
|
3157 |
buf += cidcount * 3; |
|
3158 |
||
3159 |
uint16 groupid = grf_load_word(&buf); |
|
3160 |
if (!IsValidGroupID(groupid, "CargoMapSpriteGroup")) return; |
|
3161 |
||
9517 | 3162 |
for (uint i = 0; i < idcount; i++) { |
10829 | 3163 |
CargoID cid = cargos[i]; |
9517 | 3164 |
|
3165 |
if (cid >= NUM_CARGO) { |
|
10829 | 3166 |
grfmsg(1, "CargoMapSpriteGroup: Cargo ID %d out of range, skipping", cid); |
9517 | 3167 |
continue; |
3168 |
} |
|
3169 |
||
3170 |
CargoSpec *cs = &_cargo[cid]; |
|
3171 |
cs->grfid = _cur_grffile->grfid; |
|
3172 |
cs->group = _cur_grffile->spritegroups[groupid]; |
|
3173 |
} |
|
3174 |
} |
|
3175 |
||
3176 |
||
3177 |
/* Action 0x03 */ |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
3178 |
static void FeatureMapSpriteGroup(byte *buf, size_t len) |
9517 | 3179 |
{ |
3180 |
/* <03> <feature> <n-id> <ids>... <num-cid> [<cargo-type> <cid>]... <def-cid> |
|
3181 |
* id-list := [<id>] [id-list] |
|
3182 |
* cargo-list := <cargo-type> <cid> [cargo-list] |
|
3183 |
* |
|
3184 |
* B feature see action 0 |
|
3185 |
* B n-id bits 0-6: how many IDs this definition applies to |
|
3186 |
* bit 7: if set, this is a wagon override definition (see below) |
|
3187 |
* B ids the IDs for which this definition applies |
|
3188 |
* B num-cid number of cargo IDs (sprite group IDs) in this definition |
|
3189 |
* can be zero, in that case the def-cid is used always |
|
3190 |
* B cargo-type type of this cargo type (e.g. mail=2, wood=7, see below) |
|
3191 |
* W cid cargo ID (sprite group ID) for this type of cargo |
|
3192 |
* W def-cid default cargo ID (sprite group ID) */ |
|
3193 |
||
9732 | 3194 |
if (_cur_grffile->spritegroups == 0) { |
3195 |
grfmsg(1, "FeatureMapSpriteGroup: No sprite groups to work on! Skipping"); |
|
3196 |
return; |
|
3197 |
} |
|
3198 |
||
9517 | 3199 |
if (!check_length(len, 6, "FeatureMapSpriteGroup")) return; |
3200 |
||
10829 | 3201 |
buf++; |
3202 |
uint8 feature = grf_load_byte(&buf); |
|
3203 |
uint8 idcount = grf_load_byte(&buf); |
|
9517 | 3204 |
|
3205 |
/* If idcount is zero, this is a feature callback */ |
|
3206 |
if (idcount == 0) { |
|
10829 | 3207 |
/* Skip number of cargo ids? */ |
3208 |
grf_load_byte(&buf); |
|
3209 |
uint16 groupid = grf_load_word(&buf); |
|
9732 | 3210 |
|
3211 |
grfmsg(6, "FeatureMapSpriteGroup: Adding generic feature callback for feature %d", feature); |
|
3212 |
||
3213 |
AddGenericCallback(feature, _cur_grffile, _cur_grffile->spritegroups[groupid]); |
|
9517 | 3214 |
return; |
3215 |
} |
|
3216 |
||
10829 | 3217 |
grfmsg(6, "FeatureMapSpriteGroup: Feature %d, %d ids", feature, idcount); |
9517 | 3218 |
|
3219 |
switch (feature) { |
|
3220 |
case GSF_TRAIN: |
|
3221 |
case GSF_ROAD: |
|
3222 |
case GSF_SHIP: |
|
3223 |
case GSF_AIRCRAFT: |
|
10829 | 3224 |
VehicleMapSpriteGroup(buf, feature, idcount); |
9517 | 3225 |
return; |
3226 |
||
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3227 |
case GSF_CANAL: |
10829 | 3228 |
CanalMapSpriteGroup(buf, idcount); |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3229 |
return; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3230 |
|
9517 | 3231 |
case GSF_STATION: |
10829 | 3232 |
StationMapSpriteGroup(buf, idcount); |
9517 | 3233 |
return; |
3234 |
||
3235 |
case GSF_TOWNHOUSE: |
|
10829 | 3236 |
TownHouseMapSpriteGroup(buf, idcount); |
9517 | 3237 |
return; |
3238 |
||
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3239 |
case GSF_INDUSTRIES: |
10829 | 3240 |
IndustryMapSpriteGroup(buf, idcount); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3241 |
return; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3242 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3243 |
case GSF_INDUSTRYTILES: |
10829 | 3244 |
IndustrytileMapSpriteGroup(buf, idcount); |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3245 |
return; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
3246 |
|
9517 | 3247 |
case GSF_CARGOS: |
10829 | 3248 |
CargoMapSpriteGroup(buf, idcount); |
9517 | 3249 |
return; |
3250 |
||
3251 |
default: |
|
3252 |
grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature %d, skipping", feature); |
|
3253 |
return; |
|
3254 |
} |
|
3255 |
} |
|
3256 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
3257 |
/* Action 0x04 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
3258 |
static void FeatureNewName(byte *buf, size_t len) |
0 | 3259 |
{ |
3260 |
/* <04> <veh-type> <language-id> <num-veh> <offset> <data...> |
|
3261 |
* |
|
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3262 |
* B veh-type see action 0 (as 00..07, + 0A |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3263 |
* But IF veh-type = 48, then generic text |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3264 |
* B language-id If bit 6 is set, This is the extended language scheme, |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3265 |
with up to 64 language. |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3266 |
Otherwise, it is a mapping where set bits have meaning |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3267 |
0 = american, 1 = english, 2 = german, 3 = french, 4 = spanish |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3268 |
Bit 7 set means this is a generic text, not a vehicle one (or else) |
0 | 3269 |
* B num-veh number of vehicles which are getting a new name |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
3270 |
* B/W offset number of the first vehicle that gets a new name |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3271 |
* Byte : ID of vehicle to change |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3272 |
* Word : ID of string to change/add |
0 | 3273 |
* S data new texts, each of them zero-terminated, after |
3274 |
* which the next name begins. */ |
|
6607 | 3275 |
|
3643
5d1f3fe61036
(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
|
3276 |
bool new_scheme = _cur_grffile->grf_version >= 7; |
0 | 3277 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
3278 |
if (!check_length(len, 6, "FeatureNewName")) return; |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
3279 |
buf++; |
6607 | 3280 |
uint8 feature = grf_load_byte(&buf); |
3281 |
uint8 lang = grf_load_byte(&buf); |
|
3282 |
uint8 num = grf_load_byte(&buf); |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3283 |
bool generic = HasBit(lang, 7); |
6607 | 3284 |
uint16 id = generic ? grf_load_word(&buf) : grf_load_byte(&buf); |
4992
6d0a80c5c654
(svn r6995) - Codechange: NewGRF; strip bit 7 of the language ID earlier and handle handle a language ID of 0x7F as the preferred default language.
peter1138
parents:
4964
diff
changeset
|
3285 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3286 |
ClrBit(lang, 7); |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
3287 |
|
6607 | 3288 |
uint16 endid = id + num; |
0 | 3289 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3290 |
grfmsg(6, "FeatureNewName: About to rename engines %d..%d (feature %d) in language 0x%02X", |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
3291 |
id, endid, feature, lang); |
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
3292 |
|
4992
6d0a80c5c654
(svn r6995) - Codechange: NewGRF; strip bit 7 of the language ID earlier and handle handle a language ID of 0x7F as the preferred default language.
peter1138
parents:
4964
diff
changeset
|
3293 |
len -= generic ? 6 : 5; |
6d0a80c5c654
(svn r6995) - Codechange: NewGRF; strip bit 7 of the language ID earlier and handle handle a language ID of 0x7F as the preferred default language.
peter1138
parents:
4964
diff
changeset
|
3294 |
|
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
3295 |
for (; id < endid && len > 0; id++) { |
6416
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
3296 |
const char *name = grf_load_string(&buf, len); |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
3297 |
size_t name_length = strlen(name) + 1; |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
3298 |
|
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
3299 |
len -= (int)name_length; |
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
3300 |
|
9624 | 3301 |
grfmsg(8, "FeatureNewName: 0x%04X <- %s", id, name); |
3302 |
||
3303 |
switch (feature) { |
|
3304 |
case GSF_TRAIN: |
|
3305 |
case GSF_ROAD: |
|
3306 |
case GSF_SHIP: |
|
3307 |
case GSF_AIRCRAFT: |
|
10829 | 3308 |
if (!generic) { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
3309 |
Engine *e = GetNewEngine(_cur_grffile, (VehicleType)feature, id); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
3310 |
StringID string = AddGRFString(_cur_grffile->grfid, e->index, lang, new_scheme, name, e->info.string_id); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
3311 |
e->info.string_id = string; |
9624 | 3312 |
} else { |
3313 |
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, id); |
|
3614 | 3314 |
} |
9624 | 3315 |
break; |
3316 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
3317 |
case GSF_INDUSTRIES: { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
3318 |
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
3319 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
3320 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
3321 |
|
9624 | 3322 |
case GSF_TOWNHOUSE: |
3323 |
default: |
|
3324 |
switch (GB(id, 8, 8)) { |
|
3325 |
case 0xC4: // Station class name |
|
3326 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
|
3327 |
grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
|
3328 |
} else { |
|
3329 |
StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass; |
|
3330 |
SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED)); |
|
9476 | 3331 |
} |
9624 | 3332 |
break; |
3333 |
||
3334 |
case 0xC5: // Station name |
|
3335 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
|
3336 |
grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
|
3337 |
} else { |
|
3338 |
_cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
|
3339 |
} |
|
3340 |
break; |
|
3341 |
||
3342 |
case 0xC9: // House name |
|
3343 |
if (_cur_grffile->housespec == NULL || _cur_grffile->housespec[GB(id, 0, 8)] == NULL) { |
|
3344 |
grfmsg(1, "FeatureNewName: Attempt to name undefined house 0x%X, ignoring.", GB(id, 0, 8)); |
|
3345 |
} else { |
|
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
3346 |
_cur_grffile->housespec[GB(id, 0, 8)]->building_name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
9624 | 3347 |
} |
3348 |
break; |
|
3349 |
||
3350 |
case 0xD0: |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
3351 |
case 0xD1: |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
3352 |
case 0xD2: |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
3353 |
case 0xD3: |
9624 | 3354 |
case 0xDC: |
3355 |
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
|
3356 |
break; |
|
3357 |
||
3358 |
default: |
|
3359 |
grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); |
|
3360 |
break; |
|
3361 |
} |
|
3362 |
break; |
|
3642
a247e07fafdf
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
3363 |
|
a247e07fafdf
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
3364 |
#if 0 |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3365 |
case GSF_CANAL : |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3366 |
case GSF_BRIDGE : |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3367 |
AddGRFString(_cur_spriteid, id, lang, name); |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
3368 |
switch (GB(id, 8, 8)) { |
9505 | 3369 |
case 0xC9: // House name |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3370 |
default: |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3371 |
grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3372 |
} |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3373 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3374 |
|
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3375 |
default : |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3376 |
grfmsg(7, "FeatureNewName: Unsupported feature (0x%02X)", feature); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3377 |
break; |
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3378 |
#endif |
379
4605aa187b18
(svn r568) -newgrf: Make @wagover bool, simplifying stuff. (pasky)
celestar
parents:
378
diff
changeset
|
3379 |
} |
0 | 3380 |
} |
3381 |
} |
|
3382 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3383 |
/** |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3384 |
* Sanitize incoming sprite offsets for Action 5 graphics replacements. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3385 |
* @param num the number of sprites to load. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3386 |
* @param offset offset from the base. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3387 |
* @param max_sprites the maximum number of sprites that can be loaded in this action 5. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3388 |
* @param name used for error warnings. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3389 |
* @return the number of sprites that is going to be skipped |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3390 |
*/ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3391 |
static uint16 SanitizeSpriteOffset(uint16& num, uint16 offset, int max_sprites, const char *name) |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3392 |
{ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3393 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3394 |
if (offset >= max_sprites) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3395 |
grfmsg(1, "GraphicsNew: %s sprite offset must be less than %i, skipping", name, max_sprites); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3396 |
uint orig_num = num; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3397 |
num = 0; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3398 |
return orig_num; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3399 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3400 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3401 |
if (offset + num > max_sprites) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3402 |
grfmsg(4, "GraphicsNew: %s sprite overflow, truncating...", name); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3403 |
uint orig_num = num; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3404 |
num = max(max_sprites - offset, 0); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3405 |
return orig_num - num; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3406 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3407 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3408 |
return 0; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3409 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3410 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
3411 |
/* Action 0x05 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
3412 |
static void GraphicsNew(byte *buf, size_t len) |
0 | 3413 |
{ |
3414 |
/* <05> <graphics-type> <num-sprites> <other data...> |
|
3415 |
* |
|
3416 |
* B graphics-type What set of graphics the sprites define. |
|
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
3417 |
* E num-sprites How many sprites are in this set? |
0 | 3418 |
* V other data Graphics type specific data. Currently unused. */ |
3419 |
/* TODO */ |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
3420 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3421 |
enum Action5BlockType { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3422 |
A5BLOCK_FIXED, ///< Only allow replacing a whole block of sprites. (TTDP compatible) |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3423 |
A5BLOCK_ALLOW_OFFSET, ///< Allow replacing any subset by specifiing an offset. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3424 |
A5BLOCK_INVALID, ///< unknown/not-implemented type |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3425 |
}; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3426 |
struct Action5Type { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3427 |
Action5BlockType block_type; ///< How is this Action5 type processed? |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3428 |
SpriteID sprite_base; ///< Load the sprites starting from this sprite. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3429 |
uint16 min_sprites; ///< If the Action5 contains less sprites, the whole block will be ignored. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3430 |
uint16 max_sprites; ///< If the Action5 contains more sprites, only the first max_sprites sprites will be used. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3431 |
const char *name; ///< Name for error messages. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3432 |
}; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3433 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3434 |
static const Action5Type action5_types[] = { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3435 |
/* Note: min_sprites should not be changed. Therefore these constants are directly here and not in sprites.h */ |
10920 | 3436 |
/* 0x00 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x00" }, |
3437 |
/* 0x01 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x01" }, |
|
3438 |
/* 0x02 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x02" }, |
|
3439 |
/* 0x03 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x03" }, |
|
3440 |
/* 0x04 */ { A5BLOCK_FIXED, SPR_SIGNALS_BASE, 48, PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT, "Signal graphics" }, |
|
3441 |
/* 0x05 */ { A5BLOCK_FIXED, SPR_ELRAIL_BASE, 48, ELRAIL_SPRITE_COUNT, "Catenary graphics" }, |
|
3442 |
/* 0x06 */ { A5BLOCK_FIXED, SPR_SLOPES_BASE, 74, NORMAL_AND_HALFTILE_FOUNDATION_SPRITE_COUNT, "Foundation graphics" }, |
|
3443 |
/* 0x07 */ { A5BLOCK_INVALID, 0, 75, 0, "TTDP GUI graphics" }, // Not used by OTTD. |
|
3444 |
/* 0x08 */ { A5BLOCK_FIXED, SPR_CANALS_BASE, 65, CANALS_SPRITE_COUNT, "Canal graphics" }, |
|
3445 |
/* 0x09 */ { A5BLOCK_FIXED, SPR_ONEWAY_BASE, 6, ONEWAY_SPRITE_COUNT, "One way road graphics" }, |
|
3446 |
/* 0x0A */ { A5BLOCK_FIXED, SPR_2CCMAP_BASE, 256, TWOCCMAP_SPRITE_COUNT, "2CC colour maps" }, |
|
3447 |
/* 0x0B */ { A5BLOCK_FIXED, SPR_TRAMWAY_BASE, 113, TRAMWAY_SPRITE_COUNT, "Tramway graphics" }, |
|
3448 |
/* 0x0C */ { A5BLOCK_INVALID, 0, 133, 0, "Snowy temperate tree" }, // Not yet used by OTTD. |
|
3449 |
/* 0x0D */ { A5BLOCK_FIXED, SPR_SHORE_BASE, 16, SPR_SHORE_SPRITE_COUNT, "Shore graphics" }, |
|
3450 |
/* 0x0E */ { A5BLOCK_INVALID, 0, 0, 0, "New Signals graphics" }, // Not yet used by OTTD. |
|
3451 |
/* 0x0F */ { A5BLOCK_FIXED, SPR_TRACKS_FOR_SLOPES_BASE, 12, TRACKS_FOR_SLOPES_SPRITE_COUNT, "Sloped rail track" }, |
|
3452 |
/* 0x10 */ { A5BLOCK_FIXED, SPR_AIRPORTX_BASE, 15, AIRPORTX_SPRITE_COUNT, "Airport graphics" }, |
|
3453 |
/* 0x11 */ { A5BLOCK_FIXED, SPR_ROADSTOP_BASE, 8, ROADSTOP_SPRITE_COUNT, "Road stop graphics" }, |
|
3454 |
/* 0x12 */ { A5BLOCK_FIXED, SPR_AQUEDUCT_BASE, 8, AQUEDUCT_SPRITE_COUNT, "Aqueduct graphics" }, |
|
3455 |
/* 0x13 */ { A5BLOCK_FIXED, SPR_AUTORAIL_BASE, 55, AUTORAIL_SPRITE_COUNT, "Autorail graphics" }, |
|
3456 |
/* 0x14 */ { A5BLOCK_ALLOW_OFFSET, SPR_FLAGS_BASE, 1, FLAGS_SPRITE_COUNT, "Flag graphics" }, |
|
3457 |
/* 0x15 */ { A5BLOCK_ALLOW_OFFSET, SPR_OPENTTD_BASE, 1, OPENTTD_SPRITE_COUNT, "OpenTTD GUI graphics" }, |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3458 |
}; |
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
3459 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
3460 |
if (!check_length(len, 2, "GraphicsNew")) return; |
2346
7e88b66abdbd
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
3461 |
buf++; |
6607 | 3462 |
uint8 type = grf_load_byte(&buf); |
3463 |
uint16 num = grf_load_extended(&buf); |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3464 |
uint16 offset = HasBit(type, 7) ? grf_load_extended(&buf) : 0; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3465 |
ClrBit(type, 7); // Clear the high bit as that only indicates whether there is an offset. |
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
3466 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3467 |
if ((type == 0x0D) && (num == 10) && _cur_grffile->is_ottdfile) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3468 |
/* Special not-TTDP-compatible case used in openttd(d/w).grf |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3469 |
* Missing shore sprites and initialisation of SPR_SHORE_BASE */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3470 |
grfmsg(2, "GraphicsNew: Loading 10 missing shore sprites from openttd(d/w).grf."); |
10829 | 3471 |
LoadNextSprite(SPR_SHORE_BASE + 0, _file_index, _nfo_line++); // SLOPE_STEEP_S |
3472 |
LoadNextSprite(SPR_SHORE_BASE + 5, _file_index, _nfo_line++); // SLOPE_STEEP_W |
|
3473 |
LoadNextSprite(SPR_SHORE_BASE + 7, _file_index, _nfo_line++); // SLOPE_WSE |
|
3474 |
LoadNextSprite(SPR_SHORE_BASE + 10, _file_index, _nfo_line++); // SLOPE_STEEP_N |
|
3475 |
LoadNextSprite(SPR_SHORE_BASE + 11, _file_index, _nfo_line++); // SLOPE_NWS |
|
3476 |
LoadNextSprite(SPR_SHORE_BASE + 13, _file_index, _nfo_line++); // SLOPE_ENW |
|
3477 |
LoadNextSprite(SPR_SHORE_BASE + 14, _file_index, _nfo_line++); // SLOPE_SEN |
|
3478 |
LoadNextSprite(SPR_SHORE_BASE + 15, _file_index, _nfo_line++); // SLOPE_STEEP_E |
|
3479 |
LoadNextSprite(SPR_SHORE_BASE + 16, _file_index, _nfo_line++); // SLOPE_EW |
|
3480 |
LoadNextSprite(SPR_SHORE_BASE + 17, _file_index, _nfo_line++); // SLOPE_NS |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3481 |
if (_loaded_newgrf_features.shore == SHORE_REPLACE_NONE) _loaded_newgrf_features.shore = SHORE_REPLACE_ONLY_NEW; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3482 |
return; |
3638
6e0b43d905d4
(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
|
3483 |
} |
6e0b43d905d4
(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
|
3484 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3485 |
/* Supported type? */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3486 |
if ((type >= lengthof(action5_types)) || (action5_types[type].block_type == A5BLOCK_INVALID)) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3487 |
grfmsg(2, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring)", type, num); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3488 |
_skip_sprites = num; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3489 |
return; |
3708
1c548218151c
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
3490 |
} |
3638
6e0b43d905d4
(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
|
3491 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3492 |
const Action5Type *action5_type = &action5_types[type]; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3493 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3494 |
/* Ignore offset if not allowed */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3495 |
if ((action5_type->block_type != A5BLOCK_ALLOW_OFFSET) && (offset != 0)) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3496 |
grfmsg(1, "GraphicsNew: %s (type 0x%02X) do not allow an <offset> field. Ignoring offset.", action5_type->name, type); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3497 |
offset = 0; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3498 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3499 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3500 |
/* Ignore action5 if too few sprites are specified. (for TTDP compatibility) |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3501 |
* This does not make sense, if <offset> is allowed */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3502 |
if ((action5_type->block_type == A5BLOCK_FIXED) && (num < action5_type->min_sprites)) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3503 |
grfmsg(1, "GraphicsNew: %s (type 0x%02X) count must be at least %d. Only %d were specified. Skipping.", action5_type->name, type, action5_type->min_sprites, num); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3504 |
_skip_sprites = num; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3505 |
return; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3506 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3507 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3508 |
/* Load at most max_sprites sprites. Skip remaining sprites. (for compatibility with TTDP and future extentions) */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3509 |
uint16 skip_num = SanitizeSpriteOffset(num, offset, action5_type->max_sprites, action5_type->name); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3510 |
SpriteID replace = action5_type->sprite_base + offset; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3511 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3512 |
/* Load <num> sprites starting from <replace>, then skip <skip_num> sprites. */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3513 |
grfmsg(2, "GraphicsNew: Replacing sprites %d to %d of %s (type 0x%02X) at SpriteID 0x%04X", offset, offset + num - 1, action5_type->name, type, replace); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3514 |
|
3638
6e0b43d905d4
(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
|
3515 |
for (; num > 0; num--) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
3516 |
_nfo_line++; |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
3517 |
LoadNextSprite(replace == 0 ? _cur_spriteid++ : replace++, _file_index, _nfo_line); |
3638
6e0b43d905d4
(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
|
3518 |
} |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3519 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3520 |
if (type == 0x0D) _loaded_newgrf_features.shore = SHORE_REPLACE_ACTION_5; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
3521 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3522 |
_skip_sprites = skip_num; |
0 | 3523 |
} |
3524 |
||
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3525 |
/* Action 0x05 (SKIP) */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
3526 |
static void SkipAct5(byte *buf, size_t len) |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3527 |
{ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3528 |
if (!check_length(len, 2, "SkipAct5")) return; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3529 |
buf++; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3530 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3531 |
/* Ignore type byte */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3532 |
grf_load_byte(&buf); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3533 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3534 |
/* Skip the sprites of this action */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3535 |
_skip_sprites = grf_load_extended(&buf); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3536 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3537 |
grfmsg(3, "SkipAct5: Skipping %d sprites", _skip_sprites); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3538 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
3539 |
|
9732 | 3540 |
/** |
3541 |
* Reads a variable common to VarAction2 and Action7/9/D. |
|
3542 |
* |
|
3543 |
* Returns VarAction2 variable 'param' resp. Action7/9/D variable '0x80 + param'. |
|
3544 |
* If a variable is not accessible from all four actions, it is handled in the action specific functions. |
|
3545 |
* |
|
3546 |
* @param param variable number (as for VarAction2, for Action7/9/D you have to subtract 0x80 first). |
|
3547 |
* @param value returns the value of the variable. |
|
3548 |
* @return true iff the variable is known and the value is returned in 'value'. |
|
3549 |
*/ |
|
3550 |
bool GetGlobalVariable(byte param, uint32 *value) |
|
3806 | 3551 |
{ |
3552 |
switch (param) { |
|
9732 | 3553 |
case 0x00: // current date |
3554 |
*value = max(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0); |
|
3555 |
return true; |
|
3556 |
||
3557 |
case 0x01: // current year |
|
3558 |
*value = Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; |
|
3559 |
return true; |
|
3560 |
||
3561 |
case 0x02: // current month |
|
3562 |
*value = _cur_month; |
|
3563 |
return true; |
|
3564 |
||
3565 |
case 0x03: // current climate, 0=temp, 1=arctic, 2=trop, 3=toyland |
|
10776 | 3566 |
*value = _settings_game.game_creation.landscape; |
9732 | 3567 |
return true; |
3568 |
||
3569 |
case 0x06: // road traffic side, bit 4 clear=left, set=right |
|
10776 | 3570 |
*value = _settings_game.vehicle.road_side << 4; |
9732 | 3571 |
return true; |
3572 |
||
3573 |
case 0x09: // date fraction |
|
3574 |
*value = _date_fract; |
|
3575 |
return true; |
|
3576 |
||
3577 |
case 0x0A: // animation counter |
|
3578 |
*value = _tick_counter; |
|
3579 |
return true; |
|
3580 |
||
3581 |
case 0x0B: { // TTDPatch version |
|
3582 |
uint major = 2; |
|
3583 |
uint minor = 6; |
|
3584 |
uint revision = 1; // special case: 2.0.1 is 2.0.10 |
|
3585 |
uint build = 1382; |
|
3586 |
*value = (major << 24) | (minor << 20) | (revision << 16) | build; |
|
3587 |
return true; |
|
3588 |
} |
|
3589 |
||
3590 |
case 0x0D: // TTD Version, 00=DOS, 01=Windows |
|
3591 |
*value = !_use_dos_palette; |
|
3592 |
return true; |
|
3593 |
||
3594 |
case 0x0E: // Y-offset for train sprites |
|
3595 |
*value = _traininfo_vehicle_pitch; |
|
3596 |
return true; |
|
3597 |
||
3598 |
case 0x0F: // Rail track type cost factors |
|
3599 |
*value = 0; |
|
3600 |
SB(*value, 0, 8, _railtype_cost_multiplier[0]); // normal rail |
|
10776 | 3601 |
if (_settings_game.vehicle.disable_elrails) { |
9732 | 3602 |
/* skip elrail multiplier - disabled */ |
3603 |
SB(*value, 8, 8, _railtype_cost_multiplier[2]); // monorail |
|
3604 |
} else { |
|
3605 |
SB(*value, 8, 8, _railtype_cost_multiplier[1]); // electified railway |
|
3606 |
/* Skip monorail multiplier - no space in result */ |
|
3607 |
} |
|
3608 |
SB(*value, 16, 8, _railtype_cost_multiplier[3]); // maglev |
|
3609 |
return true; |
|
3610 |
||
3611 |
case 0x11: // current rail tool type |
|
3612 |
*value = 0; |
|
3613 |
return true; |
|
3614 |
||
3615 |
case 0x12: // Game mode |
|
3616 |
*value = _game_mode; |
|
3617 |
return true; |
|
3618 |
||
3619 |
/* case 0x13: // Tile refresh offset to left not implemented */ |
|
3620 |
/* case 0x14: // Tile refresh offset to right not implemented */ |
|
3621 |
/* case 0x15: // Tile refresh offset upwards not implemented */ |
|
3622 |
/* case 0x16: // Tile refresh offset downwards not implemented */ |
|
3623 |
/* case 0x17: // temperate snow line not implemented */ |
|
3624 |
||
3625 |
case 0x1A: // Always -1 |
|
3626 |
*value = UINT_MAX; |
|
3627 |
return true; |
|
3628 |
||
3629 |
case 0x1B: // Display options |
|
3630 |
*value = GB(_display_opt, 0, 6); |
|
3631 |
return true; |
|
3632 |
||
3633 |
case 0x1D: // TTD Platform, 00=TTDPatch, 01=OpenTTD |
|
3634 |
*value = 1; |
|
3635 |
return true; |
|
3636 |
||
3637 |
case 0x1E: // Miscellaneous GRF features |
|
3638 |
*value = _misc_grf_features; |
|
3639 |
return true; |
|
3640 |
||
3641 |
/* case 0x1F: // locale dependent settings not implemented */ |
|
3642 |
||
3643 |
case 0x20: // snow line height |
|
10776 | 3644 |
*value = _settings_game.game_creation.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF; |
9732 | 3645 |
return true; |
3646 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
3647 |
case 0x21: // OpenTTD version |
9732 | 3648 |
*value = _openttd_newgrf_version; |
3649 |
return true; |
|
3650 |
||
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
3651 |
case 0x22: // difficulty level |
10776 | 3652 |
*value = _settings_game.difficulty.diff_level; |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
3653 |
return true; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
3654 |
|
10829 | 3655 |
case 0x23: // long format date |
3656 |
*value = _date; |
|
3657 |
return true; |
|
3658 |
||
3659 |
case 0x24: // long format year |
|
3660 |
*value = _cur_year; |
|
3661 |
return true; |
|
3662 |
||
9732 | 3663 |
default: return false; |
3664 |
} |
|
3665 |
} |
|
3666 |
||
3667 |
static uint32 GetParamVal(byte param, uint32 *cond_val) |
|
3668 |
{ |
|
3669 |
/* First handle variable common with VarAction2 */ |
|
3670 |
uint32 value; |
|
3671 |
if (GetGlobalVariable(param - 0x80, &value)) return value; |
|
3672 |
||
3673 |
/* Non-common variable */ |
|
3674 |
switch (param) { |
|
9626 | 3675 |
case 0x84: { // GRF loading stage |
3676 |
uint32 res = 0; |
|
3677 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3678 |
if (_cur_stage > GLS_INIT) SetBit(res, 0); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3679 |
if (_cur_stage == GLS_RESERVE) SetBit(res, 8); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3680 |
if (_cur_stage == GLS_ACTIVATION) SetBit(res, 9); |
9626 | 3681 |
return res; |
3682 |
} |
|
3806 | 3683 |
|
9505 | 3684 |
case 0x85: // TTDPatch flags, only for bit tests |
3811
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3685 |
if (cond_val == NULL) { |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3686 |
/* Supported in Action 0x07 and 0x09, not 0x0D */ |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3687 |
return 0; |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3688 |
} else { |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3689 |
uint32 param_val = _ttdpatch_flags[*cond_val / 0x20]; |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3690 |
*cond_val %= 0x20; |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3691 |
return param_val; |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3692 |
} |
3806 | 3693 |
|
9505 | 3694 |
case 0x88: // GRF ID check |
3806 | 3695 |
return 0; |
3696 |
||
9732 | 3697 |
/* case 0x99: Global ID offest not implemented */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3698 |
|
3806 | 3699 |
default: |
3700 |
/* GRF Parameter */ |
|
3701 |
if (param < 0x80) return _cur_grffile->param[param]; |
|
3702 |
||
3703 |
/* In-game variable. */ |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3704 |
grfmsg(1, "Unsupported in-game variable 0x%02X", param); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
3705 |
return UINT_MAX; |
3806 | 3706 |
} |
3707 |
} |
|
3708 |
||
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3709 |
/* Action 0x06 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
3710 |
static void CfgApply(byte *buf, size_t len) |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3711 |
{ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3712 |
/* <06> <param-num> <param-size> <offset> ... <FF> |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3713 |
* |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3714 |
* B param-num Number of parameter to substitute (First = "zero") |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3715 |
* Ignored if that parameter was not specified in newgrf.cfg |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3716 |
* B param-size How many bytes to replace. If larger than 4, the |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3717 |
* bytes of the following parameter are used. In that |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3718 |
* case, nothing is applied unless *all* parameters |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3719 |
* were specified. |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3720 |
* B offset Offset into data from beginning of next sprite |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3721 |
* to place where parameter is to be stored. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3722 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3723 |
/* Preload the next sprite */ |
10776 | 3724 |
size_t pos = FioGetPos(); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3725 |
uint16 num = FioReadWord(); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3726 |
uint8 type = FioReadByte(); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3727 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3728 |
/* Check if the sprite is a pseudo sprite. We can't operate on real sprites. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3729 |
if (type == 0xFF) { |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
3730 |
_preload_sprite = MallocT<byte>(num); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3731 |
FioReadBlock(_preload_sprite, num); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3732 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3733 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3734 |
/* Reset the file position to the start of the next sprite */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3735 |
FioSeekTo(pos, SEEK_SET); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3736 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3737 |
if (type != 0xFF) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3738 |
grfmsg(2, "CfgApply: Ignoring (next sprite is real, unsupported)"); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3739 |
return; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3740 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3741 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3742 |
/* Now perform the Action 0x06 on our data. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3743 |
buf++; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3744 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3745 |
for (;;) { |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3746 |
uint i; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3747 |
uint param_num; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3748 |
uint param_size; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3749 |
uint offset; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3750 |
bool add_value; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3751 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3752 |
/* Read the parameter to apply. 0xFF indicates no more data to change. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3753 |
param_num = grf_load_byte(&buf); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3754 |
if (param_num == 0xFF) break; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3755 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3756 |
/* Get the size of the parameter to use. If the size covers multiple |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3757 |
* double words, sequential parameter values are used. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3758 |
param_size = grf_load_byte(&buf); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3759 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3760 |
/* Bit 7 of param_size indicates we should add to the original value |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3761 |
* instead of replacing it. */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3762 |
add_value = HasBit(param_size, 7); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3763 |
param_size = GB(param_size, 0, 7); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3764 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3765 |
/* Where to apply the data to within the pseudo sprite data. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3766 |
offset = grf_load_extended(&buf); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3767 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3768 |
/* If the parameter is a GRF parameter (not an internal variable) check |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3769 |
* if it (and all further sequential parameters) has been defined. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3770 |
if (param_num < 0x80 && (param_num + (param_size - 1) / 4) >= _cur_grffile->param_end) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3771 |
grfmsg(2, "CfgApply: Ignoring (param %d not set)", (param_num + (param_size - 1) / 4)); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3772 |
break; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3773 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3774 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
3775 |
grfmsg(8, "CfgApply: Applying %u bytes from parameter 0x%02X at offset 0x%04X", param_size, param_num, offset); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3776 |
|
9624 | 3777 |
bool carry = false; |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3778 |
for (i = 0; i < param_size; i++) { |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3779 |
uint32 value = GetParamVal(param_num + i / 4, NULL); |
9624 | 3780 |
/* Reset carry flag for each iteration of the variable (only really |
3781 |
* matters if param_size is greater than 4) */ |
|
3782 |
if (i == 0) carry = false; |
|
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3783 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3784 |
if (add_value) { |
9624 | 3785 |
uint new_value = _preload_sprite[offset + i] + GB(value, (i % 4) * 8, 8) + (carry ? 1 : 0); |
3786 |
_preload_sprite[offset + i] = GB(new_value, 0, 8); |
|
3787 |
/* Check if the addition overflowed */ |
|
3788 |
carry = new_value >= 256; |
|
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3789 |
} else { |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3790 |
_preload_sprite[offset + i] = GB(value, (i % 4) * 8, 8); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3791 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3792 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3793 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3794 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3795 |
|
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
3796 |
/* Action 0x07 */ |
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
3797 |
/* Action 0x09 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
3798 |
static void SkipIf(byte *buf, size_t len) |
0 | 3799 |
{ |
3800 |
/* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites> |
|
3801 |
* |
|
3802 |
* B param-num |
|
3803 |
* B param-size |
|
3804 |
* B condition-type |
|
3805 |
* V value |
|
3806 |
* B num-sprites */ |
|
3807 |
/* TODO: More params. More condition types. */ |
|
2336
48ace1344af0
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
3808 |
uint32 cond_val = 0; |
3806 | 3809 |
uint32 mask = 0; |
360
ff657281ae48
(svn r548) -newgrf: minor style changes, and application of boolean type
darkvater
parents:
359
diff
changeset
|
3810 |
bool result; |
0 | 3811 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
3812 |
if (!check_length(len, 6, "SkipIf")) return; |
3714
402f02b01241
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
3813 |
buf++; |
6607 | 3814 |
uint8 param = grf_load_byte(&buf); |
3815 |
uint8 paramsize = grf_load_byte(&buf); |
|
3816 |
uint8 condtype = grf_load_byte(&buf); |
|
0 | 3817 |
|
359
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
3818 |
if (condtype < 2) { |
1611 | 3819 |
/* Always 1 for bit tests, the given value should be ignored. */ |
359
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
3820 |
paramsize = 1; |
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
3821 |
} |
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
3822 |
|
1611 | 3823 |
switch (paramsize) { |
3806 | 3824 |
case 4: cond_val = grf_load_dword(&buf); mask = 0xFFFFFFFF; break; |
3825 |
case 2: cond_val = grf_load_word(&buf); mask = 0x0000FFFF; break; |
|
3826 |
case 1: cond_val = grf_load_byte(&buf); mask = 0x000000FF; break; |
|
1611 | 3827 |
default: break; |
3828 |
} |
|
359
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
3829 |
|
3806 | 3830 |
if (param < 0x80 && _cur_grffile->param_end <= param) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
3831 |
grfmsg(7, "SkipIf: Param %d undefined, skipping test", param); |
3806 | 3832 |
return; |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
3833 |
} |
0 | 3834 |
|
6607 | 3835 |
uint32 param_val = GetParamVal(param, &cond_val); |
3806 | 3836 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
3837 |
grfmsg(7, "SkipIf: Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val); |
5703
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3838 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3839 |
/* |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3840 |
* Parameter (variable in specs) 0x88 can only have GRF ID checking |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3841 |
* conditions, except conditions 0x0B and 0x0C (cargo availability) |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3842 |
* as those ignore the parameter. So, when the condition type is |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3843 |
* either of those, the specific variable 0x88 code is skipped, so |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3844 |
* the "general" code for the cargo availability conditions kicks in. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3845 |
*/ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3846 |
if (param == 0x88 && condtype != 0x0B && condtype != 0x0C) { |
5703
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3847 |
/* GRF ID checks */ |
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3848 |
|
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3849 |
const GRFConfig *c = GetGRFConfig(cond_val); |
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3850 |
|
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3851 |
if (condtype != 10 && c == NULL) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
3852 |
grfmsg(7, "SkipIf: GRFID 0x%08X unknown, skipping test", BSWAP32(cond_val)); |
5703
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3853 |
return; |
5234
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5228
diff
changeset
|
3854 |
} |
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5228
diff
changeset
|
3855 |
|
5703
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3856 |
switch (condtype) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3857 |
/* Tests 0x06 to 0x0A are only for param 0x88, GRFID checks */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3858 |
case 0x06: // Is GRFID active? |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6519
diff
changeset
|
3859 |
result = c->status == GCS_ACTIVATED; |
5703
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3860 |
break; |
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3861 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3862 |
case 0x07: // Is GRFID non-active? |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6519
diff
changeset
|
3863 |
result = c->status != GCS_ACTIVATED; |
5703
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3864 |
break; |
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3865 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3866 |
case 0x08: // GRFID is not but will be active? |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6519
diff
changeset
|
3867 |
result = c->status == GCS_INITIALISED; |
5703
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3868 |
break; |
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3869 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3870 |
case 0x09: // GRFID is or will be active? |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6519
diff
changeset
|
3871 |
result = c->status == GCS_ACTIVATED || c->status == GCS_INITIALISED; |
5703
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3872 |
break; |
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3873 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3874 |
case 0x0A: // GRFID is not nor will be active |
5703
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3875 |
/* This is the only condtype that doesn't get ignored if the GRFID is not found */ |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6519
diff
changeset
|
3876 |
result = c == NULL || c->flags == GCS_DISABLED || c->status == GCS_NOT_FOUND; |
5703
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3877 |
break; |
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3878 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3879 |
default: grfmsg(1, "SkipIf: Unsupported GRF condition type %02X. Ignoring", condtype); return; |
5234
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5228
diff
changeset
|
3880 |
} |
5703
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3881 |
} else { |
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3882 |
/* Parameter or variable tests */ |
3f848403a814
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5681
diff
changeset
|
3883 |
switch (condtype) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3884 |
case 0x00: result = !!(param_val & (1 << cond_val)); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3885 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3886 |
case 0x01: result = !(param_val & (1 << cond_val)); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3887 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3888 |
case 0x02: result = (param_val & mask) == cond_val; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3889 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3890 |
case 0x03: result = (param_val & mask) != cond_val; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3891 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3892 |
case 0x04: result = (param_val & mask) < cond_val; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3893 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3894 |
case 0x05: result = (param_val & mask) > cond_val; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3895 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3896 |
case 0x0B: result = GetCargoIDByLabel(BSWAP32(cond_val)) == CT_INVALID; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3897 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3898 |
case 0x0C: result = GetCargoIDByLabel(BSWAP32(cond_val)) != CT_INVALID; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3899 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3900 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3901 |
default: grfmsg(1, "SkipIf: Unsupported condition type %02X. Ignoring", condtype); return; |
5234
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5228
diff
changeset
|
3902 |
} |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
3903 |
} |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
3904 |
|
1607
320079c7ac28
(svn r2111) So, result is bool therefore no need for this horrible == 0 thing.
pasky
parents:
1606
diff
changeset
|
3905 |
if (!result) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
3906 |
grfmsg(2, "SkipIf: Not skipping sprites, test was false"); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
3907 |
return; |
359
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
3908 |
} |
f0ee94d705ed
(svn r547) -newgrf: Enhanced support for action 0x7 and 0x9 (skips). Killer mixture mixed from octo's patch and pasky's old patch (pasky & octo).
darkvater
parents:
357
diff
changeset
|
3909 |
|
6607 | 3910 |
uint8 numsprites = grf_load_byte(&buf); |
3561
29c95ab685c0
(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
|
3911 |
|
29c95ab685c0
(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
|
3912 |
/* numsprites can be a GOTO label if it has been defined in the GRF |
29c95ab685c0
(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
|
3913 |
* file. The jump will always be the first matching label that follows |
29c95ab685c0
(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
|
3914 |
* the current nfo_line. If no matching label is found, the first matching |
29c95ab685c0
(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
|
3915 |
* label in the file is used. */ |
6607 | 3916 |
GRFLabel *choice = NULL; |
3917 |
for (GRFLabel *label = _cur_grffile->label; label != NULL; label = label->next) { |
|
3561
29c95ab685c0
(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
|
3918 |
if (label->label != numsprites) continue; |
29c95ab685c0
(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
|
3919 |
|
29c95ab685c0
(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
|
3920 |
/* Remember a goto before the current line */ |
29c95ab685c0
(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
|
3921 |
if (choice == NULL) choice = label; |
29c95ab685c0
(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
|
3922 |
/* If we find a label here, this is definitely good */ |
29c95ab685c0
(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
|
3923 |
if (label->nfo_line > _nfo_line) { |
29c95ab685c0
(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
|
3924 |
choice = label; |
29c95ab685c0
(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
|
3925 |
break; |
29c95ab685c0
(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
|
3926 |
} |
29c95ab685c0
(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
|
3927 |
} |
29c95ab685c0
(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
|
3928 |
|
29c95ab685c0
(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
|
3929 |
if (choice != NULL) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
3930 |
grfmsg(2, "SkipIf: Jumping to label 0x%0X at line %d, test was true", choice->label, choice->nfo_line); |
3561
29c95ab685c0
(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
|
3931 |
FioSeekTo(choice->pos, SEEK_SET); |
29c95ab685c0
(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
|
3932 |
_nfo_line = choice->nfo_line; |
29c95ab685c0
(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
|
3933 |
return; |
29c95ab685c0
(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
|
3934 |
} |
29c95ab685c0
(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
|
3935 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
3936 |
grfmsg(2, "SkipIf: Skipping %d sprites, test was true", numsprites); |
357
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
3937 |
_skip_sprites = numsprites; |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
3938 |
if (_skip_sprites == 0) { |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
3939 |
/* Zero means there are no sprites to skip, so |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
3940 |
* we use -1 to indicate that all further |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
3941 |
* sprites should be skipped. */ |
912b71f33867
(svn r545) -newgrf: repaired indendation (pasky & octo)
celestar
parents:
356
diff
changeset
|
3942 |
_skip_sprites = -1; |
6422
14794ebde68e
(svn r8831) -Feature: If an action 7/9 leads to skipping the rest of the file, disable the
maedhros
parents:
6421
diff
changeset
|
3943 |
|
14794ebde68e
(svn r8831) -Feature: If an action 7/9 leads to skipping the rest of the file, disable the
maedhros
parents:
6421
diff
changeset
|
3944 |
/* If an action 8 hasn't been encountered yet, disable the grf. */ |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
3945 |
if (_cur_grfconfig->status != GCS_ACTIVATED) { |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
3946 |
_cur_grfconfig->status = GCS_DISABLED; |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
3947 |
} |
0 | 3948 |
} |
3949 |
} |
|
3950 |
||
5317
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
3951 |
|
5753
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
3952 |
/* Action 0x08 (GLS_FILESCAN) */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
3953 |
static void ScanInfo(byte *buf, size_t len) |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3954 |
{ |
6607 | 3955 |
if (!check_length(len, 8, "Info")) return; |
3956 |
buf++; |
|
3957 |
grf_load_byte(&buf); |
|
3958 |
uint32 grfid = grf_load_dword(&buf); |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3959 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3960 |
_cur_grfconfig->grfid = grfid; |
5317
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
3961 |
|
5329
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
3962 |
/* GRF IDs starting with 0xFF are reserved for internal TTDPatch use */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
3963 |
if (GB(grfid, 24, 8) == 0xFF) SetBit(_cur_grfconfig->flags, GCF_SYSTEM); |
5329
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
3964 |
|
5317
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
3965 |
len -= 6; |
6607 | 3966 |
const char *name = grf_load_string(&buf, len); |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
3967 |
_cur_grfconfig->name = TranslateTTDPatchCodes(grfid, name); |
6512
8625c30bd63d
(svn r8964) -Codechange: use grf_load_string to read action 8 strings instead of trying to do the same manually.
rubidium
parents:
6474
diff
changeset
|
3968 |
|
8625c30bd63d
(svn r8964) -Codechange: use grf_load_string to read action 8 strings instead of trying to do the same manually.
rubidium
parents:
6474
diff
changeset
|
3969 |
len -= strlen(name) + 1; |
8625c30bd63d
(svn r8964) -Codechange: use grf_load_string to read action 8 strings instead of trying to do the same manually.
rubidium
parents:
6474
diff
changeset
|
3970 |
if (len > 0) { |
6607 | 3971 |
const char *info = grf_load_string(&buf, len); |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
3972 |
_cur_grfconfig->info = TranslateTTDPatchCodes(grfid, info); |
5317
e235a3a573e3
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
3973 |
} |
5329
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
3974 |
|
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
3975 |
/* GLS_INFOSCAN only looks for the action 8, so we can skip the rest of the file */ |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3976 |
_skip_sprites = -1; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3977 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
3978 |
|
3640
b73687dd2b62
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
3979 |
/* Action 0x08 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
3980 |
static void GRFInfo(byte *buf, size_t len) |
0 | 3981 |
{ |
3982 |
/* <08> <version> <grf-id> <name> <info> |
|
3983 |
* |
|
3984 |
* B version newgrf version, currently 06 |
|
3985 |
* 4*B grf-id globally unique ID of this .grf file |
|
3986 |
* S name name of this .grf set |
|
3987 |
* S info string describing the set, and e.g. author and copyright */ |
|
6607 | 3988 |
|
3989 |
if (!check_length(len, 8, "GRFInfo")) return; |
|
3990 |
buf++; |
|
3991 |
uint8 version = grf_load_byte(&buf); |
|
3992 |
uint32 grfid = grf_load_dword(&buf); |
|
3993 |
const char *name = grf_load_string(&buf, len - 6); |
|
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3994 |
|
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3995 |
_cur_grffile->grfid = grfid; |
3640
b73687dd2b62
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
3996 |
_cur_grffile->grf_version = version; |
9626 | 3997 |
_cur_grfconfig->status = _cur_stage < GLS_RESERVE ? GCS_INITIALISED : GCS_ACTIVATED; |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
3998 |
|
3711
4a0d1c635b56
(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
|
3999 |
/* Do swap the GRFID for displaying purposes since people expect that */ |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4000 |
DEBUG(grf, 1, "GRFInfo: Loaded GRFv%d set %08lX - %s", version, BSWAP32(grfid), name); |
0 | 4001 |
} |
4002 |
||
3640
b73687dd2b62
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
4003 |
/* Action 0x0A */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4004 |
static void SpriteReplace(byte *buf, size_t len) |
0 | 4005 |
{ |
4006 |
/* <0A> <num-sets> <set1> [<set2> ...] |
|
4007 |
* <set>: <num-sprites> <first-sprite> |
|
4008 |
* |
|
4009 |
* B num-sets How many sets of sprites to replace. |
|
4010 |
* Each set: |
|
4011 |
* B num-sprites How many sprites are in this set |
|
4012 |
* W first-sprite First sprite number to replace */ |
|
361
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
4013 |
|
9505 | 4014 |
buf++; // skip action byte |
6607 | 4015 |
uint8 num_sets = grf_load_byte(&buf); |
4016 |
||
4017 |
for (uint i = 0; i < num_sets; i++) { |
|
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4018 |
uint8 num_sprites = grf_load_byte(&buf); |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4019 |
uint16 first_sprite = grf_load_word(&buf); |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
4020 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4021 |
grfmsg(2, "SpriteReplace: [Set %d] Changing %d sprites, beginning with %d", |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4022 |
i, num_sprites, first_sprite |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4023 |
); |
361
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
4024 |
|
6607 | 4025 |
for (uint j = 0; j < num_sprites; j++) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
4026 |
int load_index = first_sprite + j; |
3557
5d12a78ce141
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
4027 |
_nfo_line++; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
4028 |
LoadNextSprite(load_index, _file_index, _nfo_line); // XXX |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
4029 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4030 |
/* Shore sprites now located at different addresses. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4031 |
* So detect when the old ones get replaced. */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4032 |
if (IsInsideMM(load_index, SPR_ORIGINALSHORE_START, SPR_ORIGINALSHORE_END + 1)) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4033 |
if (_loaded_newgrf_features.shore != SHORE_REPLACE_ACTION_5) _loaded_newgrf_features.shore = SHORE_REPLACE_ACTION_A; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4034 |
} |
361
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
4035 |
} |
ad7a042ee0eb
(svn r549) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
360
diff
changeset
|
4036 |
} |
0 | 4037 |
} |
4038 |
||
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4039 |
/* Action 0x0A (SKIP) */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4040 |
static void SkipActA(byte *buf, size_t len) |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4041 |
{ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4042 |
buf++; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4043 |
uint8 num_sets = grf_load_byte(&buf); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4044 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4045 |
for (uint i = 0; i < num_sets; i++) { |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4046 |
/* Skip the sprites this replaces */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4047 |
_skip_sprites += grf_load_byte(&buf); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4048 |
/* But ignore where they go */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4049 |
grf_load_word(&buf); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4050 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4051 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4052 |
grfmsg(3, "SkipActA: Skipping %d sprites", _skip_sprites); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4053 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4054 |
|
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
4055 |
/* Action 0x0B */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4056 |
static void GRFLoadError(byte *buf, size_t len) |
0 | 4057 |
{ |
4058 |
/* <0B> <severity> <language-id> <message-id> [<message...> 00] [<data...>] 00 [<parnum>] |
|
4059 |
* |
|
4060 |
* B severity 00: notice, contine loading grf file |
|
4061 |
* 01: warning, continue loading grf file |
|
4062 |
* 02: error, but continue loading grf file, and attempt |
|
4063 |
* loading grf again when loading or starting next game |
|
4064 |
* 03: error, abort loading and prevent loading again in |
|
4065 |
* the future (only when restarting the patch) |
|
4066 |
* B language-id see action 4, use 1F for built-in error messages |
|
4067 |
* B message-id message to show, see below |
|
4068 |
* S message for custom messages (message-id FF), text of the message |
|
4069 |
* not present for built-in messages. |
|
4070 |
* V data additional data for built-in (or custom) messages |
|
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4071 |
* B parnum parameter numbers to be shown in the message (maximum of 2) */ |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4072 |
|
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4073 |
static const StringID msgstr[] = { |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4074 |
STR_NEWGRF_ERROR_VERSION_NUMBER, |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4075 |
STR_NEWGRF_ERROR_DOS_OR_WINDOWS, |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4076 |
STR_NEWGRF_ERROR_UNSET_SWITCH, |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4077 |
STR_NEWGRF_ERROR_INVALID_PARAMETER, |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4078 |
STR_NEWGRF_ERROR_LOAD_BEFORE, |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
4079 |
STR_NEWGRF_ERROR_LOAD_AFTER, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
4080 |
STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER, |
0 | 4081 |
}; |
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
4082 |
|
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4083 |
static const StringID sevstr[] = { |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4084 |
STR_NEWGRF_ERROR_MSG_INFO, |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4085 |
STR_NEWGRF_ERROR_MSG_WARNING, |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4086 |
STR_NEWGRF_ERROR_MSG_ERROR, |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4087 |
STR_NEWGRF_ERROR_MSG_FATAL |
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
4088 |
}; |
0 | 4089 |
|
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4090 |
if (!check_length(len, 6, "GRFLoadError")) return; |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4091 |
|
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4092 |
/* For now we can only show one message per newgrf file. */ |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4093 |
if (_cur_grfconfig->error != NULL) return; |
6416
be4399248c60
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6388
diff
changeset
|
4094 |
|
9505 | 4095 |
buf++; // Skip the action byte. |
6421
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4096 |
byte severity = grf_load_byte(&buf); |
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4097 |
byte lang = grf_load_byte(&buf); |
6421
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4098 |
byte message_id = grf_load_byte(&buf); |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4099 |
len -= 4; |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4100 |
|
9627 | 4101 |
/* Skip the error if it isn't valid for the current language. */ |
4102 |
if (!CheckGrfLangID(lang, _cur_grffile->grf_version)) return; |
|
4103 |
||
6421
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4104 |
/* Skip the error until the activation stage unless bit 7 of the severity |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4105 |
* is set. */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
4106 |
if (!HasBit(severity, 7) && _cur_stage == GLS_INIT) { |
9626 | 4107 |
grfmsg(7, "GRFLoadError: Skipping non-fatal GRFLoadError in stage %d", _cur_stage); |
441
892cb9999501
(svn r650) Pasky fix #4. (Misc fixes to get USSet going)
miham
parents:
440
diff
changeset
|
4108 |
return; |
3588
a1adf8a40756
(svn r4474) - NewGRF: Skip non-fatal errors when not in stage 2.
peter1138
parents:
3577
diff
changeset
|
4109 |
} |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
4110 |
ClrBit(severity, 7); |
6421
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4111 |
|
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4112 |
if (severity >= lengthof(sevstr)) { |
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4113 |
grfmsg(7, "GRFLoadError: Invalid severity id %d. Setting to 2 (non-fatal error).", severity); |
6421
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4114 |
severity = 2; |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4115 |
} else if (severity == 3) { |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4116 |
/* This is a fatal error, so make sure the GRF is deactivated and no |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4117 |
* more of it gets loaded. */ |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6519
diff
changeset
|
4118 |
_cur_grfconfig->status = GCS_DISABLED; |
6421
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4119 |
|
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4120 |
_skip_sprites = -1; |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4121 |
} |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4122 |
|
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4123 |
if (message_id >= lengthof(msgstr) && message_id != 0xFF) { |
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4124 |
grfmsg(7, "GRFLoadError: Invalid message id."); |
6421
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4125 |
return; |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4126 |
} |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4127 |
|
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4128 |
if (len <= 1) { |
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4129 |
grfmsg(7, "GRFLoadError: No message data supplied."); |
6421
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4130 |
return; |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4131 |
} |
48a6f5c43920
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6417
diff
changeset
|
4132 |
|
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4133 |
GRFError *error = CallocT<GRFError>(1); |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4134 |
|
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4135 |
error->severity = sevstr[severity]; |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4136 |
|
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4137 |
if (message_id == 0xFF) { |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4138 |
/* This is a custom error message. */ |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4139 |
const char *message = grf_load_string(&buf, len); |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4140 |
len -= (strlen(message) + 1); |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4141 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
4142 |
error->custom_message = TranslateTTDPatchCodes(_cur_grffile->grfid, message); |
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4143 |
} else { |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4144 |
error->message = msgstr[message_id]; |
6429
02c062eb2c74
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6422
diff
changeset
|
4145 |
} |
02c062eb2c74
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6422
diff
changeset
|
4146 |
|
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4147 |
if (len > 0) { |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4148 |
const char *data = grf_load_string(&buf, len); |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4149 |
len -= (strlen(data) + 1); |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4150 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
4151 |
error->data = TranslateTTDPatchCodes(_cur_grffile->grfid, data); |
6465
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4152 |
} |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4153 |
|
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4154 |
/* Only two parameter numbers can be used in the string. */ |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4155 |
uint i = 0; |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4156 |
for (; i < 2 && len > 0; i++) { |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4157 |
error->param_number[i] = grf_load_byte(&buf); |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4158 |
len--; |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4159 |
} |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4160 |
error->num_params = i; |
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4161 |
|
dddb39b41ee0
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6454
diff
changeset
|
4162 |
_cur_grfconfig->error = error; |
0 | 4163 |
} |
4164 |
||
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
4165 |
/* Action 0x0C */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4166 |
static void GRFComment(byte *buf, size_t len) |
0 | 4167 |
{ |
4168 |
/* <0C> [<ignored...>] |
|
4169 |
* |
|
4170 |
* V ignored Anything following the 0C is ignored */ |
|
3561
29c95ab685c0
(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
|
4171 |
|
29c95ab685c0
(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
|
4172 |
if (len == 1) return; |
29c95ab685c0
(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
|
4173 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4174 |
size_t text_len = len - 1; |
6433 | 4175 |
const char *text = (const char*)(buf + 1); |
4176 |
grfmsg(2, "GRFComment: %.*s", text_len, text); |
|
0 | 4177 |
} |
4178 |
||
5776
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4179 |
/* Action 0x0D (GLS_SAFETYSCAN) */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4180 |
static void SafeParamSet(byte *buf, size_t len) |
5776
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4181 |
{ |
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
4182 |
if (!check_length(len, 5, "SafeParamSet")) return; |
5776
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4183 |
buf++; |
6607 | 4184 |
uint8 target = grf_load_byte(&buf); |
5776
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4185 |
|
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4186 |
/* Only writing GRF parameters is considered safe */ |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4187 |
if (target < 0x80) return; |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4188 |
|
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4189 |
/* GRM could be unsafe, but as here it can only happen after other GRFs |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4190 |
* are loaded, it should be okay. If the GRF tried to use the slots it |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4191 |
* reserved, it would be marked unsafe anyway. GRM for (e.g. bridge) |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4192 |
* sprites is considered safe. */ |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4193 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
4194 |
SetBit(_cur_grfconfig->flags, GCF_UNSAFE); |
5776
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4195 |
|
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4196 |
/* Skip remainder of GRF */ |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4197 |
_skip_sprites = -1; |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4198 |
} |
d80e79a2e71b
(svn r7831) -Codechange: [NewGRF] Do not mark as unsafe those NewGRFs that set their own parameters (via action D) and/or change only bridge sprite table layouts (action 0, property D).
peter1138
parents:
5753
diff
changeset
|
4199 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4200 |
|
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4201 |
static uint32 GetPatchVariable(uint8 param) |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4202 |
{ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4203 |
switch (param) { |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4204 |
/* start year - 1920 */ |
10776 | 4205 |
case 0x0B: return max(_settings_game.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR; |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4206 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4207 |
/* freight trains weight factor */ |
10776 | 4208 |
case 0x0E: return _settings_game.vehicle.freight_trains; |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4209 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4210 |
/* empty wagon speed increase */ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4211 |
case 0x0F: return 0; |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4212 |
|
9800 | 4213 |
/* plane speed factor; our patch option is reversed from TTDPatch's, |
4214 |
* the following is good for 1x, 2x and 4x (most common?) and... |
|
4215 |
* well not really for 3x. */ |
|
4216 |
case 0x10: |
|
10776 | 4217 |
switch (_settings_game.vehicle.plane_speed) { |
9800 | 4218 |
default: |
4219 |
case 4: return 1; |
|
4220 |
case 3: return 2; |
|
4221 |
case 2: return 2; |
|
4222 |
case 1: return 4; |
|
4223 |
} |
|
4224 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4225 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4226 |
/* 2CC colormap base sprite */ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4227 |
case 0x11: return SPR_2CCMAP_BASE; |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4228 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4229 |
/* map size: format = -MABXYSS |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4230 |
* M : the type of map |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4231 |
* bit 0 : set : squared map. Bit 1 is now not relevant |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4232 |
* clear : rectangle map. Bit 1 will indicate the bigger edge of the map |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4233 |
* bit 1 : set : Y is the bigger edge. Bit 0 is clear |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4234 |
* clear : X is the bigger edge. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4235 |
* A : minimum edge(log2) of the map |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4236 |
* B : maximum edge(log2) of the map |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4237 |
* XY : edges(log2) of each side of the map. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4238 |
* SS : combination of both X and Y, thus giving the size(log2) of the map |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4239 |
*/ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4240 |
case 0x13: { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4241 |
byte map_bits = 0; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4242 |
byte log_X = MapLogX() - 6; // substraction is required to make the minimal size (64) zero based |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4243 |
byte log_Y = MapLogY() - 6; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4244 |
byte max_edge = max(log_X, log_Y); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4245 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4246 |
if (log_X == log_Y) { // we have a squared map, since both edges are identical |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4247 |
SetBit(map_bits ,0); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4248 |
} else { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4249 |
if (max_edge == log_Y) SetBit(map_bits, 1); // edge Y been the biggest, mark it |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4250 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4251 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4252 |
return (map_bits << 24) | (min(log_X, log_Y) << 20) | (max_edge << 16) | |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4253 |
(log_X << 12) | (log_Y << 8) | (log_X + log_Y); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4254 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4255 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4256 |
default: |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4257 |
grfmsg(2, "ParamSet: Unknown Patch variable 0x%02X.", param); |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4258 |
return 0; |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4259 |
} |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4260 |
} |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4261 |
|
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4262 |
|
9626 | 4263 |
static uint32 PerformGRM(uint32 *grm, uint16 num_ids, uint16 count, uint8 op, uint8 target, const char *type) |
4264 |
{ |
|
4265 |
uint start = 0; |
|
4266 |
uint size = 0; |
|
4267 |
||
4268 |
if (op == 6) { |
|
4269 |
/* Return GRFID of set that reserved ID */ |
|
4270 |
return grm[_cur_grffile->param[target]]; |
|
4271 |
} |
|
4272 |
||
4273 |
/* With an operation of 2 or 3, we want to reserve a specific block of IDs */ |
|
4274 |
if (op == 2 || op == 3) start = _cur_grffile->param[target]; |
|
4275 |
||
4276 |
for (uint i = start; i < num_ids; i++) { |
|
4277 |
if (grm[i] == 0) { |
|
4278 |
size++; |
|
4279 |
} else { |
|
4280 |
if (op == 2 || op == 3) break; |
|
4281 |
start = i + 1; |
|
4282 |
size = 0; |
|
4283 |
} |
|
4284 |
||
4285 |
if (size == count) break; |
|
4286 |
} |
|
4287 |
||
4288 |
if (size == count) { |
|
4289 |
/* Got the slot... */ |
|
4290 |
if (op == 0 || op == 3) { |
|
4291 |
grfmsg(2, "ParamSet: GRM: Reserving %d %s at %d", count, type, start); |
|
4292 |
for (uint i = 0; i < count; i++) grm[start + i] = _cur_grffile->grfid; |
|
4293 |
} |
|
4294 |
return start; |
|
4295 |
} |
|
4296 |
||
4297 |
/* Unable to allocate */ |
|
4298 |
if (op != 4 && op != 5) { |
|
4299 |
/* Deactivate GRF */ |
|
4300 |
grfmsg(0, "ParamSet: GRM: Unable to allocate %d %s, deactivating", count, type); |
|
4301 |
_cur_grfconfig->status = GCS_DISABLED; |
|
4302 |
_skip_sprites = -1; |
|
4303 |
return UINT_MAX; |
|
4304 |
} |
|
4305 |
||
4306 |
grfmsg(1, "ParamSet: GRM: Unable to allocate %d %s", count, type); |
|
4307 |
return UINT_MAX; |
|
4308 |
} |
|
4309 |
||
4310 |
||
356
e3721e481b38
(svn r544) -newgrf: codechange for better handling (pasky and octo__)
celestar
parents:
193
diff
changeset
|
4311 |
/* Action 0x0D */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4312 |
static void ParamSet(byte *buf, size_t len) |
0 | 4313 |
{ |
4314 |
/* <0D> <target> <operation> <source1> <source2> [<data>] |
|
4315 |
* |
|
4316 |
* B target parameter number where result is stored |
|
4317 |
* B operation operation to perform, see below |
|
4318 |
* B source1 first source operand |
|
4319 |
* B source2 second source operand |
|
4320 |
* D data data to use in the calculation, not necessary |
|
4321 |
* if both source1 and source2 refer to actual parameters |
|
4322 |
* |
|
4323 |
* Operations |
|
4324 |
* 00 Set parameter equal to source1 |
|
4325 |
* 01 Addition, source1 + source2 |
|
4326 |
* 02 Subtraction, source1 - source2 |
|
4327 |
* 03 Unsigned multiplication, source1 * source2 (both unsigned) |
|
4328 |
* 04 Signed multiplication, source1 * source2 (both signed) |
|
4329 |
* 05 Unsigned bit shift, source1 by source2 (source2 taken to be a |
|
4330 |
* signed quantity; left shift if positive and right shift if |
|
4331 |
* negative, source1 is unsigned) |
|
4332 |
* 06 Signed bit shift, source1 by source2 |
|
4333 |
* (source2 like in 05, and source1 as well) |
|
4334 |
*/ |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4335 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
4336 |
if (!check_length(len, 5, "ParamSet")) return; |
418
67457dd7e5bc
(svn r615) Fix the same bug in ParamSet action loading, pointer out by Bjarni too. (pasky)
bjarni
parents:
416
diff
changeset
|
4337 |
buf++; |
6607 | 4338 |
uint8 target = grf_load_byte(&buf); |
4339 |
uint8 oper = grf_load_byte(&buf); |
|
4340 |
uint32 src1 = grf_load_byte(&buf); |
|
4341 |
uint32 src2 = grf_load_byte(&buf); |
|
4342 |
||
4343 |
uint32 data = 0; |
|
2345 | 4344 |
if (len >= 8) data = grf_load_dword(&buf); |
398
20f8a2faf809
(svn r590) -newgrf: Instead of a bunch of statinfo arrays, use station-array of struct StationSpec-s (pasky).
darkvater
parents:
397
diff
changeset
|
4345 |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4346 |
/* You can add 80 to the operation to make it apply only if the target |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4347 |
* is not defined yet. In this respect, a parameter is taken to be |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4348 |
* defined if any of the following applies: |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4349 |
* - it has been set to any value in the newgrf(w).cfg parameter list |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4350 |
* - it OR A PARAMETER WITH HIGHER NUMBER has been set to any value by |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4351 |
* an earlier action D */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
4352 |
if (HasBit(oper, 7)) { |
3807
927ac7827a28
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
4353 |
if (target < 0x80 && target < _cur_grffile->param_end) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4354 |
grfmsg(7, "ParamSet: Param %u already defined, skipping", target); |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4355 |
return; |
3807
927ac7827a28
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
4356 |
} |
927ac7827a28
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
4357 |
|
6607 | 4358 |
oper = GB(oper, 0, 7); |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4359 |
} |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4360 |
|
3808
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4361 |
if (src2 == 0xFE) { |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4362 |
if (GB(data, 0, 8) == 0xFF) { |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4363 |
if (data == 0x0000FFFF) { |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4364 |
/* Patch variables */ |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4365 |
src1 = GetPatchVariable(src1); |
3808
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4366 |
} else { |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4367 |
/* GRF Resource Management */ |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4368 |
uint8 op = src1; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4369 |
uint8 feature = GB(data, 8, 8); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4370 |
uint16 count = GB(data, 16, 16); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4371 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4372 |
if (_cur_stage == GLS_RESERVE) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4373 |
if (feature == 0x08) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4374 |
/* General sprites */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4375 |
if (op == 0) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4376 |
/* Check if the allocated sprites will fit below the original sprite limit */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4377 |
if (_cur_spriteid + count >= 16384) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4378 |
grfmsg(0, "ParamSet: GRM: Unable to allocate %d sprites; try changing NewGRF order", count); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4379 |
_cur_grfconfig->status = GCS_DISABLED; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4380 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4381 |
_skip_sprites = -1; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4382 |
return; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4383 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4384 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4385 |
/* Reserve space at the current sprite ID */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4386 |
grfmsg(4, "ParamSet: GRM: Allocated %d sprites at %d", count, _cur_spriteid); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4387 |
_grm_sprites[GRFLocation(_cur_grffile->grfid, _nfo_line)] = _cur_spriteid; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4388 |
_cur_spriteid += count; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4389 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4390 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4391 |
/* Ignore GRM result during reservation */ |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4392 |
src1 = 0; |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4393 |
} else if (_cur_stage == GLS_ACTIVATION) { |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4394 |
switch (feature) { |
9505 | 4395 |
case 0x00: // Trains |
4396 |
case 0x01: // Road Vehicles |
|
4397 |
case 0x02: // Ships |
|
4398 |
case 0x03: // Aircraft |
|
10776 | 4399 |
if (!_settings_game.vehicle.dynamic_engines) { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4400 |
src1 = PerformGRM(&_grm_engines[_engine_offsets[feature]], _engine_counts[feature], count, op, target, "vehicles"); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4401 |
if (_skip_sprites == -1) return; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4402 |
} else { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4403 |
// GRM does not apply for dynamic engine allocation. |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4404 |
switch (op) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4405 |
case 2: |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4406 |
case 3: |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4407 |
src1 = _cur_grffile->param[target]; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4408 |
break; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4409 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4410 |
default: |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4411 |
src1 = 0; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4412 |
break; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4413 |
} |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4414 |
} |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4415 |
break; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4416 |
|
9505 | 4417 |
case 0x08: // General sprites |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4418 |
switch (op) { |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4419 |
case 0: |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4420 |
/* Return space reserved during reservation stage */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4421 |
src1 = _grm_sprites[GRFLocation(_cur_grffile->grfid, _nfo_line)]; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4422 |
grfmsg(4, "ParamSet: GRM: Using pre-allocated sprites at %d", src1); |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4423 |
break; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4424 |
|
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4425 |
case 1: |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4426 |
src1 = _cur_spriteid; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4427 |
break; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4428 |
|
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4429 |
default: |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4430 |
grfmsg(1, "ParamSet: GRM: Unsupported operation %d for general sprites", op); |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4431 |
return; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4432 |
} |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4433 |
break; |
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4434 |
|
9626 | 4435 |
case 0x0B: // Cargo |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4436 |
/* There are two ranges: one for cargo IDs and one for cargo bitmasks */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4437 |
src1 = PerformGRM(_grm_cargos, NUM_CARGO * 2, count, op, target, "cargos"); |
9626 | 4438 |
if (_skip_sprites == -1) return; |
4439 |
break; |
|
4440 |
||
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
4441 |
default: grfmsg(1, "ParamSet: GRM: Unsupported feature 0x%X", feature); return; |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4442 |
} |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4443 |
} else { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4444 |
/* Ignore GRM during initialization */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
4445 |
src1 = 0; |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4446 |
} |
3808
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4447 |
} |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4448 |
} else { |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4449 |
/* Read another GRF File's parameter */ |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4450 |
const GRFFile *file = GetFileByGRFID(data); |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4451 |
if (file == NULL || src1 >= file->param_end) { |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4452 |
src1 = 0; |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4453 |
} else { |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4454 |
src1 = file->param[src1]; |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4455 |
} |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4456 |
} |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4457 |
} else { |
3808
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4458 |
/* The source1 and source2 operands refer to the grf parameter number |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4459 |
* like in action 6 and 7. In addition, they can refer to the special |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4460 |
* variables available in action 7, or they can be FF to use the value |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4461 |
* of <data>. If referring to parameters that are undefined, a value |
332b9b202afb
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
peter1138
parents:
3807
diff
changeset
|
4462 |
* of 0 is used instead. */ |
3811
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
4463 |
src1 = (src1 == 0xFF) ? data : GetParamVal(src1, NULL); |
7324eb563ae0
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
4464 |
src2 = (src2 == 0xFF) ? data : GetParamVal(src2, NULL); |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4465 |
} |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4466 |
|
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4467 |
/* TODO: You can access the parameters of another GRF file by using |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4468 |
* source2=FE, source1=the other GRF's parameter number and data=GRF |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4469 |
* ID. This is only valid with operation 00 (set). If the GRF ID |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4470 |
* cannot be found, a value of 0 is used for the parameter value |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4471 |
* instead. */ |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4472 |
|
6607 | 4473 |
uint32 res; |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4474 |
switch (oper) { |
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4475 |
case 0x00: |
2345 | 4476 |
res = src1; |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4477 |
break; |
2345 | 4478 |
|
4479 |
case 0x01: |
|
4480 |
res = src1 + src2; |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4481 |
break; |
2345 | 4482 |
|
4483 |
case 0x02: |
|
4484 |
res = src1 - src2; |
|
4485 |
break; |
|
4486 |
||
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4487 |
case 0x03: |
2345 | 4488 |
res = src1 * src2; |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4489 |
break; |
2345 | 4490 |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4491 |
case 0x04: |
2345 | 4492 |
res = (int32)src1 * (int32)src2; |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4493 |
break; |
2345 | 4494 |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4495 |
case 0x05: |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4496 |
if ((int32)src2 < 0) { |
2345 | 4497 |
res = src1 >> -(int32)src2; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4498 |
} else { |
2345 | 4499 |
res = src1 << src2; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4500 |
} |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4501 |
break; |
2345 | 4502 |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4503 |
case 0x06: |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4504 |
if ((int32)src2 < 0) { |
2345 | 4505 |
res = (int32)src1 >> -(int32)src2; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4506 |
} else { |
2345 | 4507 |
res = (int32)src1 << src2; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4508 |
} |
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4509 |
break; |
2345 | 4510 |
|
9505 | 4511 |
case 0x07: // Bitwise AND |
2442
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4512 |
res = src1 & src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4513 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4514 |
|
9505 | 4515 |
case 0x08: // Bitwise OR |
2442
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4516 |
res = src1 | src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4517 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4518 |
|
9505 | 4519 |
case 0x09: // Unsigned division |
2442
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4520 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4521 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4522 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4523 |
res = src1 / src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4524 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4525 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4526 |
|
9505 | 4527 |
case 0x0A: // Signed divison |
2442
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4528 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4529 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4530 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4531 |
res = (int32)src1 / (int32)src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4532 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4533 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4534 |
|
9505 | 4535 |
case 0x0B: // Unsigned modulo |
2442
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4536 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4537 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4538 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4539 |
res = src1 % src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4540 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4541 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4542 |
|
9505 | 4543 |
case 0x0C: // Signed modulo |
2442
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4544 |
if (src2 == 0) { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4545 |
res = src1; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4546 |
} else { |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4547 |
res = (int32)src1 % (int32)src2; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4548 |
} |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4549 |
break; |
da9a2075c747
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4550 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4551 |
default: grfmsg(0, "ParamSet: Unknown operation %d, skipping", oper); return; |
2345 | 4552 |
} |
4553 |
||
4554 |
switch (target) { |
|
4555 |
case 0x8E: // Y-Offset for train sprites |
|
4556 |
_traininfo_vehicle_pitch = res; |
|
4557 |
break; |
|
4558 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4559 |
case 0x8F: // Rail track type cost factors |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4560 |
_railtype_cost_multiplier[0] = GB(res, 0, 8); |
10776 | 4561 |
if (_settings_game.vehicle.disable_elrails) { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4562 |
_railtype_cost_multiplier[1] = GB(res, 0, 8); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4563 |
_railtype_cost_multiplier[2] = GB(res, 8, 8); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4564 |
} else { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4565 |
_railtype_cost_multiplier[1] = GB(res, 8, 8); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4566 |
_railtype_cost_multiplier[2] = GB(res, 16, 8); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4567 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4568 |
_railtype_cost_multiplier[3] = GB(res, 16, 8); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4569 |
break; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
4570 |
|
9505 | 4571 |
/* @todo implement */ |
2345 | 4572 |
case 0x93: // Tile refresh offset to left |
4573 |
case 0x94: // Tile refresh offset to right |
|
4574 |
case 0x95: // Tile refresh offset upwards |
|
4575 |
case 0x96: // Tile refresh offset downwards |
|
4576 |
case 0x97: // Snow line height |
|
4577 |
case 0x99: // Global ID offset |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4578 |
grfmsg(7, "ParamSet: Skipping unimplemented target 0x%02X", target); |
2345 | 4579 |
break; |
4580 |
||
9505 | 4581 |
case 0x9E: // Miscellaneous GRF features |
3814
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
4582 |
_misc_grf_features = res; |
3845
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
4583 |
/* Set train list engine width */ |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
4584 |
_traininfo_vehicle_width = HasGrfMiscBit(GMB_TRAIN_WIDTH_32_PIXELS) ? 32 : 29; |
3814
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
4585 |
break; |
d0b901dfc313
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
4586 |
|
9732 | 4587 |
case 0x9F: // locale-dependent settings |
4588 |
grfmsg(7, "ParamSet: Skipping unimplemented target 0x%02X", target); |
|
4589 |
break; |
|
4590 |
||
2345 | 4591 |
default: |
4592 |
if (target < 0x80) { |
|
4593 |
_cur_grffile->param[target] = res; |
|
4594 |
if (target + 1U > _cur_grffile->param_end) _cur_grffile->param_end = target + 1; |
|
4595 |
} else { |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4596 |
grfmsg(7, "ParamSet: Skipping unknown target 0x%02X", target); |
2345 | 4597 |
} |
4598 |
break; |
|
362
bd9bc9c072ba
(svn r550) -newgrf: Support for action 0xd (change a parameter (sorta variable for the GRF scripts)). Based on patch by octo, heavy changes by pasky.
darkvater
parents:
361
diff
changeset
|
4599 |
} |
0 | 4600 |
} |
4601 |
||
5753
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4602 |
/* Action 0x0E (GLS_SAFETYSCAN) */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4603 |
static void SafeGRFInhibit(byte *buf, size_t len) |
5753
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4604 |
{ |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4605 |
/* <0E> <num> <grfids...> |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4606 |
* |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4607 |
* B num Number of GRFIDs that follow |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4608 |
* D grfids GRFIDs of the files to deactivate */ |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4609 |
|
6607 | 4610 |
if (!check_length(len, 2, "GRFInhibit")) return; |
4611 |
buf++; |
|
4612 |
uint8 num = grf_load_byte(&buf); |
|
4613 |
if (!check_length(len, 2 + 4 * num, "GRFInhibit")) return; |
|
4614 |
||
4615 |
for (uint i = 0; i < num; i++) { |
|
5753
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4616 |
uint32 grfid = grf_load_dword(&buf); |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4617 |
|
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4618 |
/* GRF is unsafe it if tries to deactivate other GRFs */ |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4619 |
if (grfid != _cur_grfconfig->grfid) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
4620 |
SetBit(_cur_grfconfig->flags, GCF_UNSAFE); |
5753
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4621 |
|
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4622 |
/* Skip remainder of GRF */ |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4623 |
_skip_sprites = -1; |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4624 |
|
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4625 |
return; |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4626 |
} |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4627 |
} |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4628 |
} |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
4629 |
|
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
4630 |
/* Action 0x0E */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4631 |
static void GRFInhibit(byte *buf, size_t len) |
0 | 4632 |
{ |
4633 |
/* <0E> <num> <grfids...> |
|
4634 |
* |
|
4635 |
* B num Number of GRFIDs that follow |
|
4636 |
* D grfids GRFIDs of the files to deactivate */ |
|
367
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
4637 |
|
6607 | 4638 |
if (!check_length(len, 2, "GRFInhibit")) return; |
4639 |
buf++; |
|
4640 |
uint8 num = grf_load_byte(&buf); |
|
4641 |
if (!check_length(len, 2 + 4 * num, "GRFInhibit")) return; |
|
4642 |
||
4643 |
for (uint i = 0; i < num; i++) { |
|
367
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
4644 |
uint32 grfid = grf_load_dword(&buf); |
5333
8e7d68b06399
(svn r7495) -Fix (r7354): [NewGRF] Deactivate the target GRF, not the current GRF.
peter1138
parents:
5329
diff
changeset
|
4645 |
GRFConfig *file = GetGRFConfig(grfid); |
367
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
4646 |
|
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
4647 |
/* Unset activation flag */ |
5557
dc2402eb851b
(svn r7554) -Fix (r7496): In Action 0xE, don't deactivate the current GRF (to be ported to 0.5)
peter1138
parents:
5340
diff
changeset
|
4648 |
if (file != NULL && file != _cur_grfconfig) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4649 |
grfmsg(2, "GRFInhibit: Deactivating file '%s'", file->filename); |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6519
diff
changeset
|
4650 |
file->status = GCS_DISABLED; |
367
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
4651 |
} |
d0d895bd4972
(svn r555) -newgrf: Preliminary support for action 0xE. Inhibit another GRF file by ID. It won't really work until we get stages support (pasky & octo).
darkvater
parents:
366
diff
changeset
|
4652 |
} |
0 | 4653 |
} |
4654 |
||
9629 | 4655 |
/* Action 0x0F */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4656 |
static void FeatureTownName(byte *buf, size_t len) |
9629 | 4657 |
{ |
4658 |
/* <0F> <id> <style-name> <num-parts> <parts> |
|
4659 |
* |
|
4660 |
* B id ID of this definition in bottom 7 bits (final definition if bit 7 set) |
|
4661 |
* V style-name Name of the style (only for final definition) |
|
4662 |
* B num-parts Number of parts in this definition |
|
4663 |
* V parts The parts */ |
|
4664 |
||
4665 |
if (!check_length(len, 1, "FeatureTownName: definition ID")) return; |
|
4666 |
buf++; len--; |
|
4667 |
||
4668 |
uint32 grfid = _cur_grffile->grfid; |
|
4669 |
||
4670 |
GRFTownName *townname = AddGRFTownName(grfid); |
|
4671 |
||
4672 |
byte id = grf_load_byte(&buf); |
|
4673 |
len--; |
|
4674 |
grfmsg(6, "FeatureTownName: definition 0x%02X", id & 0x7F); |
|
4675 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
4676 |
if (HasBit(id, 7)) { |
9629 | 4677 |
/* Final definition */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
4678 |
ClrBit(id, 7); |
9629 | 4679 |
bool new_scheme = _cur_grffile->grf_version >= 7; |
4680 |
||
4681 |
if (!check_length(len, 1, "FeatureTownName: lang_id")) return; |
|
4682 |
byte lang = grf_load_byte(&buf); |
|
4683 |
len--; |
|
4684 |
||
4685 |
byte nb_gen = townname->nb_gen; |
|
4686 |
do { |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
4687 |
ClrBit(lang, 7); |
9629 | 4688 |
|
4689 |
if (!check_length(len, 1, "FeatureTownName: style name")) return; |
|
4690 |
const char *name = grf_load_string(&buf, len); |
|
4691 |
len -= strlen(name) + 1; |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
4692 |
grfmsg(6, "FeatureTownName: lang 0x%X -> '%s'", lang, TranslateTTDPatchCodes(grfid, name)); |
9629 | 4693 |
|
4694 |
townname->name[nb_gen] = AddGRFString(grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
|
4695 |
||
4696 |
if (!check_length(len, 1, "FeatureTownName: lang_id")) return; |
|
4697 |
lang = grf_load_byte(&buf); |
|
4698 |
len--; |
|
4699 |
} while (lang != 0); |
|
4700 |
townname->id[nb_gen] = id; |
|
4701 |
townname->nb_gen++; |
|
4702 |
} |
|
4703 |
||
4704 |
if (!check_length(len, 1, "FeatureTownName: number of parts")) return; |
|
4705 |
byte nb = grf_load_byte(&buf); |
|
4706 |
len--; |
|
4707 |
grfmsg(6, "FeatureTownName: %d parts", nb, nb); |
|
4708 |
||
4709 |
townname->nbparts[id] = nb; |
|
4710 |
townname->partlist[id] = CallocT<NamePartList>(nb); |
|
4711 |
||
4712 |
for (int i = 0; i < nb; i++) { |
|
4713 |
if (!check_length(len, 3, "FeatureTownName: parts header")) return; |
|
4714 |
byte nbtext = grf_load_byte(&buf); |
|
4715 |
townname->partlist[id][i].bitstart = grf_load_byte(&buf); |
|
4716 |
townname->partlist[id][i].bitcount = grf_load_byte(&buf); |
|
4717 |
townname->partlist[id][i].maxprob = 0; |
|
4718 |
townname->partlist[id][i].partcount = nbtext; |
|
4719 |
townname->partlist[id][i].parts = CallocT<NamePart>(nbtext); |
|
4720 |
len -= 3; |
|
4721 |
grfmsg(6, "FeatureTownName: part %d contains %d texts and will use GB(seed, %d, %d)", i, nbtext, townname->partlist[id][i].bitstart, townname->partlist[id][i].bitcount); |
|
4722 |
||
4723 |
for (int j = 0; j < nbtext; j++) { |
|
4724 |
if (!check_length(len, 2, "FeatureTownName: part")) return; |
|
4725 |
byte prob = grf_load_byte(&buf); |
|
4726 |
len--; |
|
4727 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
4728 |
if (HasBit(prob, 7)) { |
9629 | 4729 |
byte ref_id = grf_load_byte(&buf); |
4730 |
len--; |
|
4731 |
||
4732 |
if (townname->nbparts[ref_id] == 0) { |
|
4733 |
grfmsg(0, "FeatureTownName: definition 0x%02X doesn't exist, deactivating", ref_id); |
|
4734 |
DelGRFTownName(grfid); |
|
4735 |
_cur_grfconfig->status = GCS_DISABLED; |
|
4736 |
_skip_sprites = -1; |
|
4737 |
return; |
|
4738 |
} |
|
4739 |
||
4740 |
grfmsg(6, "FeatureTownName: part %d, text %d, uses intermediate definition 0x%02X (with probability %d)", i, j, ref_id, prob & 0x7F); |
|
4741 |
townname->partlist[id][i].parts[j].data.id = ref_id; |
|
4742 |
} else { |
|
4743 |
const char *text = grf_load_string(&buf, len); |
|
4744 |
len -= strlen(text) + 1; |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
4745 |
townname->partlist[id][i].parts[j].data.text = TranslateTTDPatchCodes(grfid, text); |
9629 | 4746 |
grfmsg(6, "FeatureTownName: part %d, text %d, '%s' (with probability %d)", i, j, townname->partlist[id][i].parts[j].data.text, prob); |
4747 |
} |
|
4748 |
townname->partlist[id][i].parts[j].prob = prob; |
|
4749 |
townname->partlist[id][i].maxprob += GB(prob, 0, 7); |
|
4750 |
} |
|
4751 |
grfmsg(6, "FeatureTownName: part %d, total probability %d", i, townname->partlist[id][i].maxprob); |
|
4752 |
} |
|
4753 |
} |
|
4754 |
||
3715
dd9807bf5927
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
4755 |
/* Action 0x10 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4756 |
static void DefineGotoLabel(byte *buf, size_t len) |
3561
29c95ab685c0
(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
|
4757 |
{ |
29c95ab685c0
(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
|
4758 |
/* <10> <label> [<comment>] |
29c95ab685c0
(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
|
4759 |
* |
29c95ab685c0
(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
|
4760 |
* B label The label to define |
29c95ab685c0
(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
|
4761 |
* V comment Optional comment - ignored */ |
29c95ab685c0
(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
|
4762 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
4763 |
if (!check_length(len, 1, "DefineGotoLabel")) return; |
3561
29c95ab685c0
(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
|
4764 |
buf++; len--; |
29c95ab685c0
(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
|
4765 |
|
6607 | 4766 |
GRFLabel *label = MallocT<GRFLabel>(1); |
3561
29c95ab685c0
(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
|
4767 |
label->label = grf_load_byte(&buf); |
29c95ab685c0
(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
|
4768 |
label->nfo_line = _nfo_line; |
29c95ab685c0
(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
|
4769 |
label->pos = FioGetPos(); |
29c95ab685c0
(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
|
4770 |
label->next = NULL; |
29c95ab685c0
(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
|
4771 |
|
29c95ab685c0
(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
|
4772 |
/* Set up a linked list of goto targets which we will search in an Action 0x7/0x9 */ |
29c95ab685c0
(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
|
4773 |
if (_cur_grffile->label == NULL) { |
29c95ab685c0
(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
|
4774 |
_cur_grffile->label = label; |
29c95ab685c0
(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
|
4775 |
} else { |
29c95ab685c0
(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
|
4776 |
/* Attach the label to the end of the list */ |
29c95ab685c0
(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
|
4777 |
GRFLabel *l; |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
4778 |
for (l = _cur_grffile->label; l->next != NULL; l = l->next) {} |
3561
29c95ab685c0
(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
|
4779 |
l->next = label; |
29c95ab685c0
(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
|
4780 |
} |
29c95ab685c0
(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
|
4781 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4782 |
grfmsg(2, "DefineGotoLabel: GOTO target with label 0x%02X", label->label); |
3561
29c95ab685c0
(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
|
4783 |
} |
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
4784 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4785 |
/* Action 0x11 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4786 |
static void GRFSound(byte *buf, size_t len) |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4787 |
{ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4788 |
/* <11> <num> |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4789 |
* |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4790 |
* W num Number of sound files that follow */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4791 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
4792 |
if (!check_length(len, 1, "GRFSound")) return; |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4793 |
buf++; |
6607 | 4794 |
uint16 num = grf_load_word(&buf); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4795 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4796 |
_grf_data_blocks = num; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4797 |
_grf_data_type = GDT_SOUND; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4798 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4799 |
if (_cur_grffile->sound_offset == 0) _cur_grffile->sound_offset = GetNumSounds(); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4800 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4801 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4802 |
/* Action 0x11 (SKIP) */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4803 |
static void SkipAct11(byte *buf, size_t len) |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4804 |
{ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4805 |
/* <11> <num> |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4806 |
* |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4807 |
* W num Number of sound files that follow */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4808 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4809 |
if (!check_length(len, 1, "SkipAct11")) return; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4810 |
buf++; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4811 |
_skip_sprites = grf_load_word(&buf); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4812 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4813 |
grfmsg(3, "SkipAct11: Skipping %d sprites", _skip_sprites); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4814 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4815 |
|
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4816 |
static void ImportGRFSound(byte *buf, int len) |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4817 |
{ |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4818 |
const GRFFile *file; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4819 |
FileEntry *se = AllocateFileEntry(); |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4820 |
uint32 grfid = grf_load_dword(&buf); |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4821 |
uint16 sound = grf_load_word(&buf); |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4822 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4823 |
file = GetFileByGRFID(grfid); |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4824 |
if (file == NULL || file->sound_offset == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4825 |
grfmsg(1, "ImportGRFSound: Source file not available"); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4826 |
return; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4827 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4828 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4829 |
if (file->sound_offset + sound >= GetNumSounds()) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4830 |
grfmsg(1, "ImportGRFSound: Sound effect %d is invalid", sound); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4831 |
return; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4832 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4833 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4834 |
grfmsg(2, "ImportGRFSound: Copying sound %d (%d) from file %X", sound, file->sound_offset + sound, grfid); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4835 |
|
5024
f13f2f2d43f9
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5011
diff
changeset
|
4836 |
*se = *GetSound(file->sound_offset + sound); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4837 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4838 |
/* Reset volume and priority, which TTDPatch doesn't copy */ |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4839 |
se->volume = 128; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4840 |
se->priority = 0; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4841 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4842 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4843 |
/* 'Action 0xFE' */ |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4844 |
static void GRFImportBlock(byte *buf, int len) |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4845 |
{ |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4846 |
if (_grf_data_blocks == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4847 |
grfmsg(2, "GRFImportBlock: Unexpected import block, skipping"); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4848 |
return; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4849 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4850 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4851 |
buf++; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4852 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4853 |
_grf_data_blocks--; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4854 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4855 |
/* XXX 'Action 0xFE' isn't really specified. It is only mentioned for |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4856 |
* importing sounds, so this is probably all wrong... */ |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4857 |
if (grf_load_byte(&buf) != _grf_data_type) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4858 |
grfmsg(1, "GRFImportBlock: Import type mismatch"); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4859 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4860 |
|
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4861 |
switch (_grf_data_type) { |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4862 |
case GDT_SOUND: ImportGRFSound(buf, len - 1); break; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4863 |
default: NOT_REACHED(); break; |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4864 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4865 |
} |
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4866 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4867 |
static void LoadGRFSound(byte *buf, int len) |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4868 |
{ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4869 |
byte *buf_start = buf; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4870 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4871 |
/* Allocate a sound entry. This is done even if the data is not loaded |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4872 |
* so that the indices used elsewhere are still correct. */ |
6607 | 4873 |
FileEntry *se = AllocateFileEntry(); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4874 |
|
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
4875 |
if (grf_load_dword(&buf) != BSWAP32('RIFF')) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4876 |
grfmsg(1, "LoadGRFSound: Missing RIFF header"); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4877 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4878 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4879 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4880 |
/* Size of file -- we ignore this */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4881 |
grf_load_dword(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4882 |
|
5567
2af6b4aa2833
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5557
diff
changeset
|
4883 |
if (grf_load_dword(&buf) != BSWAP32('WAVE')) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4884 |
grfmsg(1, "LoadGRFSound: Invalid RIFF type"); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4885 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4886 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4887 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4888 |
for (;;) { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4889 |
uint32 tag = grf_load_dword(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4890 |
uint32 size = grf_load_dword(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4891 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4892 |
switch (tag) { |
9505 | 4893 |
case ' tmf': // 'fmt ' |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4894 |
/* Audio format, must be 1 (PCM) */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4895 |
if (grf_load_word(&buf) != 1) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4896 |
grfmsg(1, "LoadGRFSound: Invalid audio format"); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4897 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4898 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4899 |
se->channels = grf_load_word(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4900 |
se->rate = grf_load_dword(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4901 |
grf_load_dword(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4902 |
grf_load_word(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4903 |
se->bits_per_sample = grf_load_word(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4904 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4905 |
/* Consume any extra bytes */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4906 |
for (; size > 16; size--) grf_load_byte(&buf); |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4907 |
break; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4908 |
|
9505 | 4909 |
case 'atad': // 'data' |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
4910 |
se->file_size = size; |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
4911 |
se->file_offset = FioGetPos() - (len - (buf - buf_start)) + 1; |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
4912 |
se->file_slot = _file_index; |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4913 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4914 |
/* Set default volume and priority */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4915 |
se->volume = 0x80; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4916 |
se->priority = 0; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4917 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4918 |
grfmsg(2, "LoadGRFSound: channels %u, sample rate %u, bits per sample %u, length %u", se->channels, se->rate, se->bits_per_sample, size); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4919 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4920 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4921 |
default: |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4922 |
se->file_size = 0; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4923 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4924 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4925 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4926 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4927 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4928 |
/* Action 0x12 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4929 |
static void LoadFontGlyph(byte *buf, size_t len) |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4930 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4931 |
/* <12> <num_def> <font_size> <num_char> <base_char> |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4932 |
* |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4933 |
* B num_def Number of definitions |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4934 |
* B font_size Size of font (0 = normal, 1 = small, 2 = large) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4935 |
* B num_char Number of consecutive glyphs |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4936 |
* W base_char First character index */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4937 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4938 |
buf++; len--; |
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
4939 |
if (!check_length(len, 1, "LoadFontGlyph")) return; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4940 |
|
6607 | 4941 |
uint8 num_def = grf_load_byte(&buf); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4942 |
|
5841
b36d6b560aaa
(svn r8041) -Regression (r7564): [NewGRF] check_length should skip further processing if a length is too short, so give the function a return value
peter1138
parents:
5838
diff
changeset
|
4943 |
if (!check_length(len, 1 + num_def * 4, "LoadFontGlyph")) return; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4944 |
|
6607 | 4945 |
for (uint i = 0; i < num_def; i++) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
4946 |
FontSize size = (FontSize)grf_load_byte(&buf); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4947 |
uint8 num_char = grf_load_byte(&buf); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4948 |
uint16 base_char = grf_load_word(&buf); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4949 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
4950 |
grfmsg(7, "LoadFontGlyph: Loading %u glyph(s) at 0x%04X for size %u", num_char, base_char, size); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4951 |
|
6607 | 4952 |
for (uint c = 0; c < num_char; c++) { |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4953 |
SetUnicodeGlyph(size, base_char + c, _cur_spriteid); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
4954 |
_nfo_line++; |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
4955 |
LoadNextSprite(_cur_spriteid++, _file_index, _nfo_line); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4956 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4957 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4958 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5061
diff
changeset
|
4959 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4960 |
/* Action 0x12 (SKIP) */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4961 |
static void SkipAct12(byte *buf, size_t len) |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4962 |
{ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4963 |
/* <12> <num_def> <font_size> <num_char> <base_char> |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4964 |
* |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4965 |
* B num_def Number of definitions |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4966 |
* B font_size Size of font (0 = normal, 1 = small, 2 = large) |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4967 |
* B num_char Number of consecutive glyphs |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4968 |
* W base_char First character index */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4969 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4970 |
buf++; len--; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4971 |
if (!check_length(len, 1, "SkipAct12")) return; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4972 |
uint8 num_def = grf_load_byte(&buf); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4973 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4974 |
if (!check_length(len, 1 + num_def * 4, "SkipAct12")) return; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4975 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4976 |
for (uint i = 0; i < num_def; i++) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4977 |
/* Ignore 'size' byte */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4978 |
grf_load_byte(&buf); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4979 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4980 |
/* Sum up number of characters */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4981 |
_skip_sprites += grf_load_byte(&buf); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4982 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4983 |
/* Ignore 'base_char' word */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4984 |
grf_load_word(&buf); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4985 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4986 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4987 |
grfmsg(3, "SkipAct12: Skipping %d sprites", _skip_sprites); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4988 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
4989 |
|
6560
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
4990 |
/* Action 0x13 */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
4991 |
static void TranslateGRFStrings(byte *buf, size_t len) |
6560
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
4992 |
{ |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
4993 |
/* <13> <grfid> <num-ent> <offset> <text...> |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
4994 |
* |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
4995 |
* 4*B grfid The GRFID of the file whose texts are to be translated |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
4996 |
* B num-ent Number of strings |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
4997 |
* W offset First text ID |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
4998 |
* S text... Zero-terminated strings */ |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
4999 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5000 |
buf++; len--; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5001 |
if (!check_length(len, 7, "TranslateGRFString")) return; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5002 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5003 |
uint32 grfid = grf_load_dword(&buf); |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5004 |
const GRFConfig *c = GetGRFConfig(grfid); |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5005 |
if (c == NULL || (c->status != GCS_INITIALISED && c->status != GCS_ACTIVATED)) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
5006 |
grfmsg(7, "TranslateGRFStrings: GRFID 0x%08x unknown, skipping action 13", BSWAP32(grfid)); |
6560
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5007 |
return; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5008 |
} |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5009 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5010 |
if (c->status == GCS_INITIALISED) { |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5011 |
/* If the file is not active but will be activated later, give an error |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5012 |
* and disable this file. */ |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5013 |
GRFError *error = CallocT<GRFError>(1); |
9627 | 5014 |
|
5015 |
char tmp[256]; |
|
5016 |
GetString(tmp, STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE, lastof(tmp)); |
|
5017 |
error->data = strdup(tmp); |
|
5018 |
||
6560
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5019 |
error->message = STR_NEWGRF_ERROR_LOAD_AFTER; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5020 |
error->severity = STR_NEWGRF_ERROR_MSG_FATAL; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5021 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5022 |
if (_cur_grfconfig->error != NULL) free(_cur_grfconfig->error); |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5023 |
_cur_grfconfig->error = error; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5024 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5025 |
_cur_grfconfig->status = GCS_DISABLED; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5026 |
_skip_sprites = -1; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5027 |
return; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5028 |
} |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5029 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5030 |
byte num_strings = grf_load_byte(&buf); |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5031 |
uint16 first_id = grf_load_word(&buf); |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5032 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5033 |
if (!((first_id >= 0xD000 && first_id + num_strings <= 0xD3FF) || (first_id >= 0xDC00 && first_id + num_strings <= 0xDCFF))) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
5034 |
grfmsg(7, "TranslateGRFStrings: Attempting to set out-of-range string IDs in action 13 (first: 0x%4X, number: 0x%2X)", first_id, num_strings); |
6560
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5035 |
return; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5036 |
} |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5037 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5038 |
len -= 7; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5039 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5040 |
for (uint i = 0; i < num_strings && len > 0; i++) { |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5041 |
const char *string = grf_load_string(&buf, len); |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5042 |
size_t string_length = strlen(string) + 1; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5043 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5044 |
len -= (int)string_length; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5045 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5046 |
if (string_length == 1) { |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5047 |
grfmsg(7, "TranslateGRFString: Ignoring empty string."); |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5048 |
continue; |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5049 |
} |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5050 |
|
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5051 |
/* Since no language id is supplied this string has to be added as a |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5052 |
* generic string, thus the language id of 0x7F. For this to work |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5053 |
* new_scheme has to be true as well. A language id of 0x7F will be |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5054 |
* overridden by a non-generic id, so this will not change anything if |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5055 |
* a string has been provided specifically for this language. */ |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5056 |
AddGRFString(grfid, first_id + i, 0x7F, true, string, STR_UNDEFINED); |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5057 |
} |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5058 |
} |
ff59c862deae
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6555
diff
changeset
|
5059 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5060 |
/* 'Action 0xFF' */ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5061 |
static void GRFDataBlock(byte *buf, int len) |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5062 |
{ |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5063 |
if (_grf_data_blocks == 0) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
5064 |
grfmsg(2, "GRFDataBlock: unexpected data block, skipping"); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5065 |
return; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5066 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5067 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5068 |
buf++; |
6607 | 5069 |
uint8 name_len = grf_load_byte(&buf); |
5070 |
const char *name = (const char *)buf; |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5071 |
buf += name_len + 1; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5072 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
5073 |
grfmsg(2, "GRFDataBlock: block name '%s'...", name); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5074 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5075 |
_grf_data_blocks--; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5076 |
|
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5077 |
switch (_grf_data_type) { |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5078 |
case GDT_SOUND: LoadGRFSound(buf, len - name_len - 2); break; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5079 |
default: NOT_REACHED(); break; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5080 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5081 |
} |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5082 |
|
5329
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
5083 |
|
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
5084 |
/* Used during safety scan on unsafe actions */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
5085 |
static void GRFUnsafe(byte *buf, size_t len) |
5329
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
5086 |
{ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5087 |
SetBit(_cur_grfconfig->flags, GCF_UNSAFE); |
5329
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
5088 |
|
5753
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
5089 |
/* Skip remainder of GRF */ |
788f8d55eb54
(svn r7795) -Codechange: [NewGRF] When safety checking, allow an Action E that force activates the GRF. Unfortunately this requires knowing the GRF ID in advance (before the Action 8) so the static GRFs are now scanned twice on start up, once for the GRF ID, and then for the safety check. (This fix allows unifont.grf to be used.)
peter1138
parents:
5727
diff
changeset
|
5090 |
_skip_sprites = -1; |
5329
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
5091 |
} |
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
5092 |
|
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
5093 |
|
6573 | 5094 |
static void InitializeGRFSpecial() |
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
5095 |
{ |
10776 | 5096 |
_ttdpatch_flags[0] = ((_settings_game.station.always_small_airport ? 1 : 0) << 0x0C) // keepsmallairport |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5097 |
| (1 << 0x0D) // newairports |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5098 |
| (1 << 0x0E) // largestations |
10776 | 5099 |
| ((_settings_game.construction.longbridges ? 1 : 0) << 0x0F) // longbridges |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5100 |
| (0 << 0x10) // loadtime |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5101 |
| (1 << 0x12) // presignals |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5102 |
| (1 << 0x13) // extpresignals |
10776 | 5103 |
| ((_settings_game.vehicle.never_expire_vehicles ? 1 : 0) << 0x16) // enginespersist |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5104 |
| (1 << 0x1B) // multihead |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5105 |
| (1 << 0x1D) // lowmemory |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5106 |
| (1 << 0x1E); // generalfixes |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5107 |
|
10776 | 5108 |
_ttdpatch_flags[1] = ((_settings_game.economy.station_noise_level ? 1 : 0) << 0x07) // moreairports - based on units of noise |
5109 |
| ((_settings_game.vehicle.mammoth_trains ? 1 : 0) << 0x08) // mammothtrains |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5110 |
| (1 << 0x09) // trainrefit |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5111 |
| (0 << 0x0B) // subsidiaries |
10776 | 5112 |
| ((_settings_game.order.gradual_loading ? 1 : 0) << 0x0C) // gradualloading |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5113 |
| (1 << 0x12) // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5114 |
| (1 << 0x13) // unifiedmaglevmode - set bit 1 mode |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5115 |
| (1 << 0x14) // bridgespeedlimits |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5116 |
| (1 << 0x16) // eternalgame |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5117 |
| (1 << 0x17) // newtrains |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5118 |
| (1 << 0x18) // newrvs |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5119 |
| (1 << 0x19) // newships |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5120 |
| (1 << 0x1A) // newplanes |
10776 | 5121 |
| ((_settings_game.construction.signal_side ? 1 : 0) << 0x1B) // signalsontrafficside |
5122 |
| ((_settings_game.vehicle.disable_elrails ? 0 : 1) << 0x1C); // electrifiedrailway |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5123 |
|
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5124 |
_ttdpatch_flags[2] = (1 << 0x01) // loadallgraphics - obsolote |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5125 |
| (1 << 0x03) // semaphores |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5126 |
| (0 << 0x0B) // enhancedgui |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5127 |
| (0 << 0x0C) // newagerating |
10776 | 5128 |
| ((_settings_game.construction.build_on_slopes ? 1 : 0) << 0x0D) // buildonslopes |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5129 |
| (1 << 0x0E) // fullloadany |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5130 |
| (1 << 0x0F) // planespeed |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5131 |
| (0 << 0x10) // moreindustriesperclimate - obsolete |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5132 |
| (0 << 0x11) // moretoylandfeatures |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5133 |
| (1 << 0x12) // newstations |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5134 |
| (1 << 0x13) // tracktypecostdiff |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5135 |
| (1 << 0x14) // manualconvert |
10776 | 5136 |
| ((_settings_game.construction.build_on_slopes ? 1 : 0) << 0x15) // buildoncoasts |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5137 |
| (1 << 0x16) // canals |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5138 |
| (1 << 0x17) // newstartyear |
10776 | 5139 |
| ((_settings_game.vehicle.freight_trains > 1 ? 1 : 0) << 0x18) // freighttrains |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5140 |
| (1 << 0x19) // newhouses |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5141 |
| (1 << 0x1A) // newbridges |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5142 |
| (1 << 0x1B) // newtownnames |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5143 |
| (1 << 0x1C) // moreanimation |
10776 | 5144 |
| ((_settings_game.vehicle.wagon_speed_limits ? 1 : 0) << 0x1D) // wagonspeedlimits |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5145 |
| (1 << 0x1E) // newshistory |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5146 |
| (0 << 0x1F); // custombridgeheads |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5147 |
|
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5148 |
_ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5149 |
| (1 << 0x01) // windowsnap |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5150 |
| (0 << 0x02) // townbuildnoroad |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5151 |
| (0 << 0x03) // pathbasedsignalling. To enable if ever pbs is back |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5152 |
| (0 << 0x04) // aichoosechance |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5153 |
| (1 << 0x05) // resolutionwidth |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5154 |
| (1 << 0x06) // resolutionheight |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5155 |
| (1 << 0x07) // newindustries |
10776 | 5156 |
| ((_settings_game.order.improved_load ? 1 : 0) << 0x08) // fifoloading |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5157 |
| (0 << 0x09) // townroadbranchprob |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5158 |
| (0 << 0x0A) // tempsnowline |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5159 |
| (1 << 0x0B) // newcargo |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5160 |
| (1 << 0x0C) // enhancemultiplayer |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5161 |
| (1 << 0x0D) // onewayroads |
10776 | 5162 |
| ((_settings_game.station.nonuniform_stations ? 1 : 0) << 0x0E) // irregularstations |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5163 |
| (1 << 0x0F) // statistics |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5164 |
| (1 << 0x10) // newsounds |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5165 |
| (1 << 0x11) // autoreplace |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5166 |
| (1 << 0x12) // autoslope |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5167 |
| (0 << 0x13) // followvehicle |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5168 |
| (1 << 0x14) // trams |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5169 |
| (0 << 0x15) // enhancetunnels |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5170 |
| (1 << 0x16) // shortrvs |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5171 |
| (1 << 0x17) // articulatedrvs |
10776 | 5172 |
| ((_settings_game.vehicle.dynamic_engines ? 1 : 0) << 0x18) // dynamic engines |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
5173 |
| (1 << 0x1E); // variablerunningcosts |
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
5174 |
} |
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
5175 |
|
6573 | 5176 |
static void ResetCustomStations() |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5177 |
{ |
6607 | 5178 |
for (GRFFile *file = _first_grffile; file != NULL; file = file->next) { |
3768
46d328178509
(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
|
5179 |
if (file->stations == NULL) continue; |
6607 | 5180 |
for (uint i = 0; i < MAX_STATIONS; i++) { |
3768
46d328178509
(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
|
5181 |
if (file->stations[i] == NULL) continue; |
6607 | 5182 |
StationSpec *statspec = file->stations[i]; |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5183 |
|
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5184 |
/* Release renderdata, if it wasn't copied from another custom station spec */ |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5185 |
if (!statspec->copied_renderdata) { |
6607 | 5186 |
for (uint t = 0; t < statspec->tiles; t++) { |
3740
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5187 |
free((void*)statspec->renderdata[t].seq); |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5188 |
} |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5189 |
free(statspec->renderdata); |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5190 |
} |
00a9594628b1
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5191 |
|
5061
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5192 |
/* Release platforms and layouts */ |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5193 |
if (!statspec->copied_layouts) { |
6607 | 5194 |
for (uint l = 0; l < statspec->lengths; l++) { |
5195 |
for (uint p = 0; p < statspec->platforms[l]; p++) { |
|
5061
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5196 |
free(statspec->layouts[l][p]); |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5197 |
} |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5198 |
free(statspec->layouts[l]); |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5199 |
} |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5200 |
free(statspec->layouts); |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5201 |
free(statspec->platforms); |
cb097749d18f
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5202 |
} |
3768
46d328178509
(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
|
5203 |
|
46d328178509
(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
|
5204 |
/* Release this station */ |
46d328178509
(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
|
5205 |
free(statspec); |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5206 |
} |
3501
cf7d2c33e7fc
(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
|
5207 |
|
cf7d2c33e7fc
(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
|
5208 |
/* Free and reset the station data */ |
cf7d2c33e7fc
(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
|
5209 |
free(file->stations); |
cf7d2c33e7fc
(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
|
5210 |
file->stations = NULL; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5211 |
} |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5212 |
} |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5213 |
|
9476 | 5214 |
static void ResetCustomHouses() |
5215 |
{ |
|
5216 |
GRFFile *file; |
|
5217 |
uint i; |
|
5218 |
||
5219 |
for (file = _first_grffile; file != NULL; file = file->next) { |
|
5220 |
if (file->housespec == NULL) continue; |
|
9626 | 5221 |
for (i = 0; i < HOUSE_MAX; i++) { |
5222 |
free(file->housespec[i]); |
|
5223 |
} |
|
9476 | 5224 |
|
5225 |
free(file->housespec); |
|
5226 |
file->housespec = NULL; |
|
5227 |
} |
|
5228 |
} |
|
5229 |
||
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5230 |
static void ResetCustomIndustries() |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5231 |
{ |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5232 |
GRFFile *file; |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5233 |
|
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5234 |
for (file = _first_grffile; file != NULL; file = file->next) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5235 |
uint i; |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5236 |
/* We are verifiying both tiles and industries specs loaded from the grf file |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5237 |
* First, let's deal with industryspec */ |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5238 |
if (file->industryspec != NULL) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5239 |
|
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5240 |
for (i = 0; i < NUM_INDUSTRYTYPES; i++) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5241 |
IndustrySpec *ind = file->industryspec[i]; |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5242 |
|
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5243 |
if (ind != NULL) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5244 |
/* We need to remove the sounds array */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5245 |
if (HasBit(ind->cleanup_flag, CLEAN_RANDOMSOUNDS)) { |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5246 |
free((void*)ind->random_sounds); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5247 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5248 |
|
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5249 |
/* We need to remove the tiles layouts */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5250 |
if (HasBit(ind->cleanup_flag, CLEAN_TILELSAYOUT) && ind->table != NULL) { |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5251 |
for (int j = 0; j < ind->num_table; j++) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5252 |
/* remove the individual layouts */ |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5253 |
if (ind->table[j] != NULL) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5254 |
free((IndustryTileTable*)ind->table[j]); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5255 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5256 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5257 |
/* remove the layouts pointers */ |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5258 |
free((IndustryTileTable**)ind->table); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5259 |
ind->table = NULL; |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5260 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5261 |
|
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5262 |
free(ind); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5263 |
ind = NULL; |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5264 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5265 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5266 |
|
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5267 |
free(file->industryspec); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5268 |
file->industryspec = NULL; |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5269 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5270 |
|
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5271 |
if (file->indtspec != NULL) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5272 |
for (i = 0; i < NUM_INDUSTRYTILES; i++) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5273 |
if (file->indtspec[i] != NULL) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5274 |
free(file->indtspec[i]); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5275 |
file->indtspec[i] = NULL; |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5276 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5277 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5278 |
|
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5279 |
free(file->indtspec); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5280 |
file->indtspec = NULL; |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5281 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5282 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5283 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5284 |
|
6573 | 5285 |
static void ResetNewGRF() |
4953
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5286 |
{ |
6607 | 5287 |
GRFFile *next; |
5288 |
||
5289 |
for (GRFFile *f = _first_grffile; f != NULL; f = next) { |
|
4953
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5290 |
next = f->next; |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5291 |
|
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5292 |
free(f->filename); |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5293 |
free(f->cargo_list); |
4953
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5294 |
free(f); |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5295 |
} |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5296 |
|
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5297 |
_first_grffile = NULL; |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5298 |
_cur_grffile = NULL; |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5299 |
} |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5300 |
|
9627 | 5301 |
static void ResetNewGRFErrors() |
5302 |
{ |
|
5303 |
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5304 |
if (!HasBit(c->flags, GCF_COPY) && c->error != NULL) { |
9627 | 5305 |
free(c->error->custom_message); |
5306 |
free(c->error->data); |
|
5307 |
free(c->error); |
|
5308 |
c->error = NULL; |
|
5309 |
} |
|
5310 |
} |
|
5311 |
} |
|
5312 |
||
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
5313 |
/** |
2463
de2605ed3758
(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
|
5314 |
* Reset all NewGRF loaded data |
de2605ed3758
(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
|
5315 |
* TODO |
de2605ed3758
(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
|
5316 |
*/ |
6573 | 5317 |
static void ResetNewGRFData() |
2463
de2605ed3758
(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
|
5318 |
{ |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
5319 |
CleanUpStrings(); |
9629 | 5320 |
CleanUpGRFTownNames(); |
3601
ac6df06db648
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
5321 |
|
9505 | 5322 |
/* Copy/reset original engine info data */ |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5323 |
SetupEngines(); |
2478
16b05f1de6bb
(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
|
5324 |
|
9732 | 5325 |
/* Copy/reset original bridge info data */ |
5326 |
ResetBridges(); |
|
2491
dfe9542f783e
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
5327 |
|
10355
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
5328 |
/* Allocate temporary refit/cargo class data */ |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5329 |
_gted = CallocT<GRFTempEngineData>(GetEnginePoolSize()); |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5330 |
|
9505 | 5331 |
/* Reset GRM reservations */ |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
5332 |
memset(&_grm_engines, 0, sizeof(_grm_engines)); |
9626 | 5333 |
memset(&_grm_cargos, 0, sizeof(_grm_cargos)); |
4961
0ba3cfeaff61
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
5334 |
|
9732 | 5335 |
/* Reset generic feature callback lists */ |
5336 |
ResetGenericCallbacks(); |
|
5337 |
||
9505 | 5338 |
/* Reset price base data */ |
2506
777ac2d9a98a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
5339 |
ResetPriceBaseMultipliers(); |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5340 |
|
4377
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
5341 |
/* Reset the curencies array */ |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
5342 |
ResetCurrencies(); |
0fb9077b8173
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
5343 |
|
9476 | 5344 |
/* Reset the house array */ |
5345 |
ResetCustomHouses(); |
|
5346 |
ResetHouses(); |
|
5347 |
||
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5348 |
/* Reset the industries structures*/ |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5349 |
ResetCustomIndustries(); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5350 |
ResetIndustries(); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5351 |
|
9505 | 5352 |
/* Reset station classes */ |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5353 |
ResetStationClasses(); |
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5354 |
ResetCustomStations(); |
2812
f250489941f9
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
5355 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5356 |
/* Reset canal sprite groups and flags */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5357 |
memset(_water_feature, 0, sizeof(_water_feature)); |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
5358 |
|
9505 | 5359 |
/* Reset the snowline table. */ |
5360 |
ClearSnowLine(); |
|
5361 |
||
4953
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5362 |
/* Reset NewGRF files */ |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5363 |
ResetNewGRF(); |
6c40b2b16164
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5364 |
|
9627 | 5365 |
/* Reset NewGRF errors. */ |
5366 |
ResetNewGRFErrors(); |
|
5367 |
||
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6416
diff
changeset
|
5368 |
/* Set up the default cargo types */ |
10776 | 5369 |
SetupCargoForClimate(_settings_game.game_creation.landscape); |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6416
diff
changeset
|
5370 |
|
3845
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
5371 |
/* Reset misc GRF features and train list display variables */ |
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
5372 |
_misc_grf_features = 0; |
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
5373 |
_traininfo_vehicle_pitch = 0; |
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
5374 |
_traininfo_vehicle_width = 29; |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5375 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
5376 |
/* Reset track cost multipliers. */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
5377 |
memcpy(&_railtype_cost_multiplier, &_default_railtype_cost_multiplier, sizeof(_default_railtype_cost_multiplier)); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
5378 |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
5379 |
_loaded_newgrf_features.has_2CC = false; |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
5380 |
_loaded_newgrf_features.has_newhouses = false; |
9704 | 5381 |
_loaded_newgrf_features.has_newindustries = false; |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5382 |
_loaded_newgrf_features.shore = SHORE_REPLACE_NONE; |
3845
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3825
diff
changeset
|
5383 |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5384 |
/* Clear all GRF overrides */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5385 |
_grf_id_overrides.clear(); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5386 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5387 |
InitializeSoundPool(); |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
5388 |
InitializeSpriteGroupPool(); |
2463
de2605ed3758
(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
|
5389 |
} |
de2605ed3758
(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
|
5390 |
|
3561
29c95ab685c0
(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
|
5391 |
/** Reset all NewGRFData that was used only while processing data */ |
6573 | 5392 |
static void ClearTemporaryNewGRFData() |
3561
29c95ab685c0
(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
|
5393 |
{ |
29c95ab685c0
(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
|
5394 |
/* Clear the GOTO labels used for GRF processing */ |
6607 | 5395 |
for (GRFLabel *l = _cur_grffile->label; l != NULL;) { |
3561
29c95ab685c0
(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
|
5396 |
GRFLabel *l2 = l->next; |
29c95ab685c0
(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
|
5397 |
free(l); |
29c95ab685c0
(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
|
5398 |
l = l2; |
29c95ab685c0
(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
|
5399 |
} |
29c95ab685c0
(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
|
5400 |
_cur_grffile->label = NULL; |
3595
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
5401 |
|
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
5402 |
/* Clear the list of spritegroups */ |
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
5403 |
free(_cur_grffile->spritegroups); |
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
5404 |
_cur_grffile->spritegroups = NULL; |
20621831cd46
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
5405 |
_cur_grffile->spritegroups_count = 0; |
3561
29c95ab685c0
(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
|
5406 |
} |
29c95ab685c0
(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
|
5407 |
|
6473
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5408 |
static void BuildCargoTranslationMap() |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5409 |
{ |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5410 |
memset(_cur_grffile->cargo_map, 0xFF, sizeof(_cur_grffile->cargo_map)); |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5411 |
|
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5412 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5413 |
const CargoSpec *cs = GetCargo(c); |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5414 |
if (!cs->IsValid()) continue; |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5415 |
|
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5416 |
if (_cur_grffile->cargo_max == 0) { |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5417 |
/* Default translation table, so just a straight mapping to bitnum */ |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5418 |
_cur_grffile->cargo_map[c] = cs->bitnum; |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5419 |
} else { |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5420 |
/* Check the translation table for this cargo's label */ |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5421 |
for (uint i = 0; i < _cur_grffile->cargo_max; i++) { |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5422 |
if (cs->label == _cur_grffile->cargo_list[i]) { |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5423 |
_cur_grffile->cargo_map[c] = i; |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5424 |
break; |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5425 |
} |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5426 |
} |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5427 |
} |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5428 |
} |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5429 |
} |
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
5430 |
|
3628
bd4a6601e5a2
(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
|
5431 |
static void InitNewGRFFile(const GRFConfig *config, int sprite_offset) |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
5432 |
{ |
6607 | 5433 |
GRFFile *newfile = GetFileByFilename(config->filename); |
490
83455cd1cc55
(svn r772) Whoops, I know. Do not consider pointer to be a boolean value. Sorry 'bout that, sirs.
pasky
parents:
489
diff
changeset
|
5434 |
if (newfile != NULL) { |
489
9c8e1806935e
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5435 |
/* We already loaded it once. */ |
9c8e1806935e
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5436 |
newfile->sprite_offset = sprite_offset; |
9c8e1806935e
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5437 |
_cur_grffile = newfile; |
9c8e1806935e
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5438 |
return; |
9c8e1806935e
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5439 |
} |
9c8e1806935e
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5440 |
|
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
5441 |
newfile = CallocT<GRFFile>(1); |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5442 |
|
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
5443 |
if (newfile == NULL) error ("Out of memory"); |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5444 |
|
9629 | 5445 |
newfile->filename = strdup(config->filename); |
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5446 |
newfile->sprite_offset = sprite_offset; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5447 |
|
3628
bd4a6601e5a2
(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
|
5448 |
/* Copy the initial parameter list */ |
bd4a6601e5a2
(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
|
5449 |
assert(lengthof(newfile->param) == lengthof(config->param) && lengthof(config->param) == 0x80); |
bd4a6601e5a2
(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
|
5450 |
newfile->param_end = config->num_params; |
5681
7b237b4958d6
(svn r7636) -Cleanup: Remove unused window classes (sorry WC-mess) and use sizeof(array) instead
Darkvater
parents:
5664
diff
changeset
|
5451 |
memcpy(newfile->param, config->param, sizeof(newfile->param)); |
3628
bd4a6601e5a2
(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
|
5452 |
|
366
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5453 |
if (_first_grffile == NULL) { |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5454 |
_cur_grffile = newfile; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5455 |
_first_grffile = newfile; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5456 |
} else { |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5457 |
_cur_grffile->next = newfile; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5458 |
_cur_grffile = newfile; |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5459 |
} |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5460 |
} |
9d2630b8b4de
(svn r554) -newgrf: Keep track of GRF files. Remember them all in a linked list, this already enables tests for an already loaded GRF file in SkipIf(). Patch by octo, heavily re-hammered by pasky
darkvater
parents:
363
diff
changeset
|
5461 |
|
5037
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
5462 |
|
6471
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5463 |
/** List of what cargo labels are refittable for the given the vehicle-type. |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5464 |
* Only currently active labels are applied. */ |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5465 |
static const CargoLabel _default_refitmasks_rail[] = { |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5466 |
'PASS', 'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5467 |
'IORE', 'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5468 |
'WATR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5469 |
'PLST', 'FZDR', |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5470 |
0 }; |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5471 |
|
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5472 |
static const CargoLabel _default_refitmasks_road[] = { |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5473 |
0 }; |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5474 |
|
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5475 |
static const CargoLabel _default_refitmasks_ships[] = { |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5476 |
'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', 'IORE', |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5477 |
'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', 'WATR', |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5478 |
'RUBR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5479 |
'PLST', 'FZDR', |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5480 |
0 }; |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5481 |
|
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5482 |
static const CargoLabel _default_refitmasks_aircraft[] = { |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5483 |
'PASS', 'MAIL', 'GOOD', 'VALU', 'GOLD', 'DIAM', 'FOOD', 'FRUT', 'SUGR', |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5484 |
'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', 'PLST', 'FZDR', |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5485 |
0 }; |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5486 |
|
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5487 |
static const CargoLabel *_default_refitmasks[] = { |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5488 |
_default_refitmasks_rail, |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5489 |
_default_refitmasks_road, |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5490 |
_default_refitmasks_ships, |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5491 |
_default_refitmasks_aircraft, |
5037
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
5492 |
}; |
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
5493 |
|
7d956200ee71
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
5494 |
|
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5495 |
/** |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5496 |
* Precalculate refit masks from cargo classes for all vehicles. |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5497 |
*/ |
6573 | 5498 |
static void CalculateRefitMasks() |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5499 |
{ |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5500 |
Engine *e; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5501 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5502 |
FOR_ALL_ENGINES(e) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5503 |
EngineID engine = e->index; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5504 |
EngineInfo *ei = &e->info; |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5505 |
uint32 mask = 0; |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5506 |
uint32 not_mask = 0; |
6610
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5507 |
uint32 xor_mask = 0; |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5508 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
5509 |
if (ei->refit_mask != 0) { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5510 |
const GRFFile *file = e->grffile; |
6610
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5511 |
if (file != NULL && file->cargo_max != 0) { |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5512 |
/* Apply cargo translation table to the refit mask */ |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5513 |
uint num_cargo = min(32, file->cargo_max); |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5514 |
for (uint i = 0; i < num_cargo; i++) { |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
5515 |
if (!HasBit(ei->refit_mask, i)) continue; |
6610
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5516 |
|
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5517 |
CargoID c = GetCargoIDByLabel(file->cargo_list[i]); |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5518 |
if (c == CT_INVALID) continue; |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5519 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5520 |
SetBit(xor_mask, c); |
6610
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5521 |
} |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5522 |
} else { |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5523 |
/* No cargo table, so use the cargo bitnum values */ |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5524 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5525 |
const CargoSpec *cs = GetCargo(c); |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5526 |
if (!cs->IsValid()) continue; |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5527 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
5528 |
if (HasBit(ei->refit_mask, cs->bitnum)) SetBit(xor_mask, c); |
6610
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5529 |
} |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5530 |
} |
ecaea43b2238
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6608
diff
changeset
|
5531 |
} |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5532 |
|
10355
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
5533 |
if (_gted[engine].cargo_allowed != 0) { |
9505 | 5534 |
/* Build up the list of cargo types from the set cargo classes. */ |
6607 | 5535 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
6439
99a5807852b1
(svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents:
6433
diff
changeset
|
5536 |
const CargoSpec *cs = GetCargo(i); |
10355
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
5537 |
if (_gted[engine].cargo_allowed & cs->classes) SetBit(mask, i); |
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
5538 |
if (_gted[engine].cargo_disallowed & cs->classes) SetBit(not_mask, i); |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5539 |
} |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5540 |
} else if (xor_mask == 0) { |
9505 | 5541 |
/* Don't apply default refit mask to wagons or engines with no capacity */ |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5542 |
if (e->type != VEH_TRAIN || (e->u.rail.capacity != 0 && e->u.rail.railveh_type != RAILVEH_WAGON)) { |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5543 |
const CargoLabel *cl = _default_refitmasks[e->type]; |
6471
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5544 |
for (uint i = 0;; i++) { |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5545 |
if (cl[i] == 0) break; |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5546 |
|
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5547 |
CargoID cargo = GetCargoIDByLabel(cl[i]); |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5548 |
if (cargo == CT_INVALID) continue; |
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5549 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5550 |
SetBit(xor_mask, cargo); |
6471
d0e79064c324
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6469
diff
changeset
|
5551 |
} |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
5552 |
} |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5553 |
} |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
5554 |
|
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
5555 |
ei->refit_mask = ((mask & ~not_mask) ^ xor_mask) & _cargo_mask; |
6468
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5556 |
|
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5557 |
/* Check if this engine's cargo type is valid. If not, set to the first refittable |
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5558 |
* cargo type. Apparently cargo_type isn't a common property... */ |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5559 |
switch (e->type) { |
9624 | 5560 |
default: NOT_REACHED(); |
5561 |
case VEH_AIRCRAFT: break; |
|
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
5562 |
case VEH_TRAIN: { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5563 |
RailVehicleInfo *rvi = &e->u.rail; |
6468
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5564 |
if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine); |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5565 |
if (rvi->cargo_type == CT_INVALID) ei->climates = 0x80; |
6468
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5566 |
break; |
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5567 |
} |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
5568 |
case VEH_ROAD: { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5569 |
RoadVehicleInfo *rvi = &e->u.road; |
6468
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5570 |
if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine); |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5571 |
if (rvi->cargo_type == CT_INVALID) ei->climates = 0x80; |
6468
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5572 |
break; |
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5573 |
} |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
5574 |
case VEH_SHIP: { |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5575 |
ShipVehicleInfo *svi = &e->u.ship; |
6468
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5576 |
if (svi->cargo_type == CT_INVALID) svi->cargo_type = FindFirstRefittableCargo(engine); |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5577 |
if (svi->cargo_type == CT_INVALID) ei->climates = 0x80; |
6468
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5578 |
break; |
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5579 |
} |
29a9bd549d0b
(svn r8885) -Codechange: (NewGRF) If a default cargo type property is out of range then choose the cargo type from its refit list.
peter1138
parents:
6465
diff
changeset
|
5580 |
} |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5581 |
} |
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5582 |
} |
363
cf3cee5f33b4
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
darkvater
parents:
362
diff
changeset
|
5583 |
|
9476 | 5584 |
/** Add all new houses to the house array. House properties can be set at any |
5585 |
* time in the GRF file, so we can only add a house spec to the house array |
|
5586 |
* after the file has finished loading. We also need to check the dates, due to |
|
5587 |
* the TTDPatch behaviour described below that we need to emulate. */ |
|
5588 |
static void FinaliseHouseArray() |
|
5589 |
{ |
|
5590 |
/* If there are no houses with start dates before 1930, then all houses |
|
5591 |
* with start dates of 1930 have them reset to 0. This is in order to be |
|
5592 |
* compatible with TTDPatch, where if no houses have start dates before |
|
5593 |
* 1930 and the date is before 1930, the game pretends that this is 1930. |
|
5594 |
* If there have been any houses defined with start dates before 1930 then |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5595 |
* the dates are left alone. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5596 |
* On the other hand, why 1930? Just 'fix' the houses with the lowest |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5597 |
* minimum introduction date to 0. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5598 |
*/ |
10829 | 5599 |
Year min_year = MAX_YEAR; |
9476 | 5600 |
|
5601 |
for (GRFFile *file = _first_grffile; file != NULL; file = file->next) { |
|
5602 |
if (file->housespec == NULL) continue; |
|
5603 |
||
5604 |
for (int i = 0; i < HOUSE_MAX; i++) { |
|
5605 |
HouseSpec *hs = file->housespec[i]; |
|
5606 |
if (hs != NULL) { |
|
9624 | 5607 |
_house_mngr.SetEntitySpec(hs); |
10829 | 5608 |
if (hs->min_year < min_year) min_year = hs->min_year; |
9476 | 5609 |
} |
5610 |
} |
|
5611 |
} |
|
5612 |
||
10829 | 5613 |
if (min_year != 0) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5614 |
for (int i = 0; i < HOUSE_MAX; i++) { |
9476 | 5615 |
HouseSpec *hs = GetHouseSpecs(i); |
5616 |
||
10829 | 5617 |
if (hs->enabled && hs->min_year == min_year) hs->min_year = 0; |
9476 | 5618 |
} |
5619 |
} |
|
5620 |
} |
|
5621 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5622 |
/** Add all new industries to the industry array. Industry properties can be set at any |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5623 |
* time in the GRF file, so we can only add a industry spec to the industry array |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5624 |
* after the file has finished loading. */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5625 |
static void FinaliseIndustriesArray() |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5626 |
{ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5627 |
for (GRFFile *file = _first_grffile; file != NULL; file = file->next) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5628 |
if (file->industryspec != NULL) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5629 |
for (int i = 0; i < NUM_INDUSTRYTYPES; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5630 |
IndustrySpec *indsp = file->industryspec[i]; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5631 |
|
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5632 |
if (indsp != NULL && indsp->enabled) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5633 |
StringID strid; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5634 |
/* process the conversion of text at the end, so to be sure everything will be fine |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5635 |
* and available. Check if it does not return undefind marker, which is a very good sign of a |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5636 |
* substitute industry who has not changed the string been examined, thus using it as such */ |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5637 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->name); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5638 |
if (strid != STR_UNDEFINED) indsp->name = strid; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5639 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5640 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->closure_text); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5641 |
if (strid != STR_UNDEFINED) indsp->closure_text = strid; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5642 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5643 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->production_up_text); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5644 |
if (strid != STR_UNDEFINED) indsp->production_up_text = strid; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5645 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5646 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->production_down_text); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5647 |
if (strid != STR_UNDEFINED) indsp->production_down_text = strid; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5648 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5649 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->new_industry_text); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5650 |
if (strid != STR_UNDEFINED) indsp->new_industry_text = strid; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5651 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5652 |
if (indsp->station_name != STR_NULL) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5653 |
/* STR_NULL (0) can be set by grf. It has a meaning regarding assignation of the |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5654 |
* station's name. Don't wont to loose the value, therefor, do not process. */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5655 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->station_name); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5656 |
if (strid != STR_UNDEFINED) indsp->station_name = strid; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5657 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5658 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5659 |
_industry_mngr.SetEntitySpec(indsp); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5660 |
_loaded_newgrf_features.has_newindustries = true; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5661 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5662 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5663 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5664 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5665 |
if (file->indtspec != NULL) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5666 |
for (int i = 0; i < NUM_INDUSTRYTILES; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5667 |
IndustryTileSpec *indtsp = file->indtspec[i]; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5668 |
if (indtsp != NULL) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5669 |
_industile_mngr.SetEntitySpec(indtsp); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5670 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5671 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5672 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5673 |
} |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5674 |
|
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5675 |
for (uint j = 0; j < NUM_INDUSTRYTYPES; j++) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5676 |
IndustrySpec *indsp = &_industry_specs[j]; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5677 |
if (indsp->enabled && indsp->grf_prop.grffile != NULL) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5678 |
for (uint i = 0; i < 3; i++) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5679 |
indsp->conflicting[i] = MapNewGRFIndustryType(indsp->conflicting[i], indsp->grf_prop.grffile->grfid); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5680 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5681 |
} |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
5682 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5683 |
} |
9517 | 5684 |
|
5685 |
/** Each cargo string needs to be mapped from TTDPatch to OpenTTD string IDs. |
|
5686 |
* This is done after loading so that strings from Action 4 will be mapped |
|
5687 |
* properly. */ |
|
5688 |
static void MapNewCargoStrings() |
|
5689 |
{ |
|
5690 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
|
5691 |
CargoSpec *cs = &_cargo[c]; |
|
5692 |
/* Don't map if the cargo is unavailable or not from NewGRF */ |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
5693 |
if (cs->grfid == 0) continue; |
9517 | 5694 |
} |
5695 |
} |
|
5696 |
||
5697 |
||
0 | 5698 |
/* Here we perform initial decoding of some special sprites (as are they |
5699 |
* described at http://www.ttdpatch.net/src/newgrf.txt, but this is only a very |
|
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
5700 |
* partial implementation yet). */ |
0 | 5701 |
/* XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by |
5702 |
* a crafted invalid GRF file. We should tell that to the user somehow, or |
|
5703 |
* better make this more robust in the future. */ |
|
5008
f95f0bd55c34
(svn r7027) - Codechange: Replace NewGRF loading stage masks with separate function lists. This will allow us to call different handlers depending on the current stage. Also enum-ize the stage.
peter1138
parents:
4993
diff
changeset
|
5704 |
static void DecodeSpecialSprite(uint num, GrfLoadingStage stage) |
0 | 5705 |
{ |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
5706 |
/* XXX: There is a difference between staged loading in TTDPatch and |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
5707 |
* here. In TTDPatch, for some reason actions 1 and 2 are carried out |
3561
29c95ab685c0
(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
|
5708 |
* during stage 1, whilst action 3 is carried out during stage 2 (to |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
5709 |
* "resolve" cargo IDs... wtf). This is a little problem, because cargo |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
5710 |
* IDs are valid only within a given set (action 1) block, and may be |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
5711 |
* overwritten after action 3 associates them. But overwriting happens |
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
5712 |
* in an earlier stage than associating, so... We just process actions |
3561
29c95ab685c0
(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
|
5713 |
* 1 and 2 in stage 2 now, let's hope that won't get us into problems. |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
381
diff
changeset
|
5714 |
* --pasky */ |
3561
29c95ab685c0
(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
|
5715 |
/* We need a pre-stage to set up GOTO labels of Action 0x10 because the grf |
29c95ab685c0
(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
|
5716 |
* is not in memory and scanning the file every time would be too expensive. |
29c95ab685c0
(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
|
5717 |
* In other stages we skip action 0x10 since it's already dealt with. */ |
5008
f95f0bd55c34
(svn r7027) - Codechange: Replace NewGRF loading stage masks with separate function lists. This will allow us to call different handlers depending on the current stage. Also enum-ize the stage.
peter1138
parents:
4993
diff
changeset
|
5718 |
static const SpecialSpriteHandler handlers[][GLS_END] = { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5719 |
/* 0x00 */ { NULL, SafeChangeInfo, NULL, NULL, ReserveChangeInfo, FeatureChangeInfo, }, |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
5720 |
/* 0x01 */ { SkipAct1, SkipAct1, SkipAct1, SkipAct1, SkipAct1, NewSpriteSet, }, |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
5721 |
/* 0x02 */ { NULL, NULL, NULL, NULL, NULL, NewSpriteGroup, }, |
9517 | 5722 |
/* 0x03 */ { NULL, GRFUnsafe, NULL, NULL, NULL, FeatureMapSpriteGroup, }, |
5723 |
/* 0x04 */ { NULL, NULL, NULL, NULL, NULL, FeatureNewName, }, |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
5724 |
/* 0x05 */ { SkipAct5, SkipAct5, SkipAct5, SkipAct5, SkipAct5, GraphicsNew, }, |
9545 | 5725 |
/* 0x06 */ { NULL, NULL, NULL, CfgApply, CfgApply, CfgApply, }, |
9517 | 5726 |
/* 0x07 */ { NULL, NULL, NULL, NULL, SkipIf, SkipIf, }, |
9626 | 5727 |
/* 0x08 */ { ScanInfo, NULL, NULL, GRFInfo, GRFInfo, GRFInfo, }, |
9517 | 5728 |
/* 0x09 */ { NULL, NULL, NULL, SkipIf, SkipIf, SkipIf, }, |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
5729 |
/* 0x0A */ { SkipActA, SkipActA, SkipActA, SkipActA, SkipActA, SpriteReplace, }, |
9517 | 5730 |
/* 0x0B */ { NULL, NULL, NULL, GRFLoadError, GRFLoadError, GRFLoadError, }, |
5731 |
/* 0x0C */ { NULL, NULL, NULL, GRFComment, NULL, GRFComment, }, |
|
5732 |
/* 0x0D */ { NULL, SafeParamSet, NULL, ParamSet, ParamSet, ParamSet, }, |
|
5733 |
/* 0x0E */ { NULL, SafeGRFInhibit, NULL, GRFInhibit, GRFInhibit, GRFInhibit, }, |
|
9629 | 5734 |
/* 0x0F */ { NULL, GRFUnsafe, NULL, FeatureTownName, NULL, NULL, }, |
9517 | 5735 |
/* 0x10 */ { NULL, NULL, DefineGotoLabel, NULL, NULL, NULL, }, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5736 |
/* 0x11 */ { SkipAct11,GRFUnsafe, SkipAct11, SkipAct11, SkipAct11, GRFSound, }, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5737 |
/* 0x12 */ { SkipAct12, SkipAct12, SkipAct12, SkipAct12, SkipAct12, LoadFontGlyph, }, |
9517 | 5738 |
/* 0x13 */ { NULL, NULL, NULL, NULL, NULL, TranslateGRFStrings, }, |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5739 |
}; |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
5740 |
|
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5741 |
byte* buf; |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
5742 |
|
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5743 |
if (_preload_sprite == NULL) { |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5744 |
/* No preloaded sprite to work with; allocate and read the |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5745 |
* pseudo sprite content. */ |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5844
diff
changeset
|
5746 |
buf = MallocT<byte>(num); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5747 |
FioReadBlock(buf, num); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5748 |
} else { |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5749 |
/* Use the preloaded sprite data. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5750 |
buf = _preload_sprite; |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5751 |
_preload_sprite = NULL; |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5567
diff
changeset
|
5752 |
grfmsg(7, "DecodeSpecialSprite: Using preloaded pseudo sprite data"); |
3895
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5753 |
|
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5754 |
/* Skip the real (original) content of this action. */ |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5755 |
FioSeekTo(num, SEEK_CUR); |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5756 |
} |
a67d4451a1df
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5757 |
|
6607 | 5758 |
byte action = buf[0]; |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5759 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5760 |
if (action == 0xFF) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
5761 |
grfmsg(7, "DecodeSpecialSprite: Handling data block in stage %d", stage); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5762 |
GRFDataBlock(buf, num); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
5763 |
} else if (action == 0xFE) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5764 |
grfmsg(7, "DecodeSpecialSprite: Handling import block in stage %d", stage); |
4818
1625f49f708d
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
5765 |
GRFImportBlock(buf, num); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5766 |
} else if (action >= lengthof(handlers)) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
5767 |
grfmsg(7, "DecodeSpecialSprite: Skipping unknown action 0x%02X", action); |
5008
f95f0bd55c34
(svn r7027) - Codechange: Replace NewGRF loading stage masks with separate function lists. This will allow us to call different handlers depending on the current stage. Also enum-ize the stage.
peter1138
parents:
4993
diff
changeset
|
5768 |
} else if (handlers[action][stage] == NULL) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
5769 |
grfmsg(7, "DecodeSpecialSprite: Skipping action 0x%02X in stage %d", action, stage); |
2645
964bd8fe3ce2
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
5770 |
} else { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
5771 |
grfmsg(7, "DecodeSpecialSprite: Handling action 0x%02X in stage %d", action, stage); |
5008
f95f0bd55c34
(svn r7027) - Codechange: Replace NewGRF loading stage masks with separate function lists. This will allow us to call different handlers depending on the current stage. Also enum-ize the stage.
peter1138
parents:
4993
diff
changeset
|
5772 |
handlers[action][stage](buf, num); |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5773 |
} |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5774 |
free(buf); |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5775 |
} |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5776 |
|
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5777 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
5778 |
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage) |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5779 |
{ |
9629 | 5780 |
const char *filename = config->filename; |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5781 |
uint16 num; |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5782 |
|
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5783 |
/* A .grf file is activated only if it was active when the game was |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5784 |
* started. If a game is loaded, only its active .grfs will be |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5785 |
* reactivated, unless "loadallgraphics on" is used. A .grf file is |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5786 |
* considered active if its action 8 has been processed, i.e. its |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5787 |
* action 8 hasn't been skipped using an action 7. |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5788 |
* |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5789 |
* During activation, only actions 0, 1, 2, 3, 4, 5, 7, 8, 9, 0A and 0B are |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5790 |
* carried out. All others are ignored, because they only need to be |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5791 |
* processed once at initialization. */ |
5329
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5324
diff
changeset
|
5792 |
if (stage != GLS_FILESCAN && stage != GLS_SAFETYSCAN && stage != GLS_LABELSCAN) { |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5793 |
_cur_grffile = GetFileByFilename(filename); |
10867
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
5794 |
if (_cur_grffile == NULL) usererror("File '%s' lost in cache.\n", filename); |
9626 | 5795 |
if (stage == GLS_RESERVE && config->status != GCS_INITIALISED) return; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5796 |
if (stage == GLS_ACTIVATION && !HasBit(config->flags, GCF_RESERVED)) return; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5797 |
_cur_grffile->is_ottdfile = config->IsOpenTTDBaseGRF(); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5798 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5799 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5800 |
if (file_index > LAST_GRF_SLOT) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5801 |
DEBUG(grf, 0, "'%s' is not loaded as the maximum number of GRFs has been reached", filename); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5802 |
config->status = GCS_DISABLED; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5803 |
config->error = CallocT<GRFError>(1); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5804 |
config->error->severity = STR_NEWGRF_ERROR_MSG_FATAL; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5805 |
config->error->message = STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5806 |
return; |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5807 |
} |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5808 |
|
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5809 |
FioOpenFile(file_index, filename); |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5810 |
_file_index = file_index; // XXX |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5811 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
5812 |
_cur_grfconfig = config; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
5813 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
5814 |
DEBUG(grf, 2, "LoadNewGRFFile: Reading NewGRF-file '%s'", filename); |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5815 |
|
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5816 |
/* Skip the first sprite; we don't care about how many sprites this |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5817 |
* does contain; newest TTDPatches and George's longvehicles don't |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5818 |
* neither, apparently. */ |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5819 |
if (FioReadWord() == 4 && FioReadByte() == 0xFF) { |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5820 |
FioReadDword(); |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5821 |
} else { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
5822 |
DEBUG(grf, 7, "LoadNewGRFFile: Custom .grf has invalid format"); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
5823 |
return; |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5824 |
} |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5825 |
|
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5826 |
_skip_sprites = 0; // XXX |
3557
5d12a78ce141
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
5827 |
_nfo_line = 0; |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5828 |
|
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5829 |
while ((num = FioReadWord()) != 0) { |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5830 |
byte type = FioReadByte(); |
3557
5d12a78ce141
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
5831 |
_nfo_line++; |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5832 |
|
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5833 |
if (type == 0xFF) { |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5834 |
if (_skip_sprites == 0) { |
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2935
diff
changeset
|
5835 |
DecodeSpecialSprite(num, stage); |
5011
23f0b424a1be
(svn r7031) -Codechange: Use _skip_sprites to skip the rest of the NewGRF when disabled by GRM, and add a shortcut so that the rest of the file isn't scanned.
peter1138
parents:
5008
diff
changeset
|
5836 |
|
23f0b424a1be
(svn r7031) -Codechange: Use _skip_sprites to skip the rest of the NewGRF when disabled by GRM, and add a shortcut so that the rest of the file isn't scanned.
peter1138
parents:
5008
diff
changeset
|
5837 |
/* Stop all processing if we are to skip the remaining sprites */ |
23f0b424a1be
(svn r7031) -Codechange: Use _skip_sprites to skip the rest of the NewGRF when disabled by GRM, and add a shortcut so that the rest of the file isn't scanned.
peter1138
parents:
5008
diff
changeset
|
5838 |
if (_skip_sprites == -1) break; |
23f0b424a1be
(svn r7031) -Codechange: Use _skip_sprites to skip the rest of the NewGRF when disabled by GRM, and add a shortcut so that the rest of the file isn't scanned.
peter1138
parents:
5008
diff
changeset
|
5839 |
|
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5840 |
continue; |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5841 |
} else { |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5842 |
FioSkipBytes(num); |
1611 | 5843 |
} |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
5844 |
} else { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
5845 |
if (_skip_sprites == 0) grfmsg(7, "LoadNewGRFFile: Skipping unexpected sprite"); |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5846 |
|
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5847 |
FioSkipBytes(7); |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5848 |
num -= 8; |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5849 |
|
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5850 |
if (type & 2) { |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5851 |
FioSkipBytes(num); |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5852 |
} else { |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5853 |
while (num > 0) { |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5854 |
int8 i = FioReadByte(); |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5855 |
if (i >= 0) { |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5856 |
num -= i; |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5857 |
FioSkipBytes(i); |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5858 |
} else { |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5859 |
i = -(i >> 3); |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5860 |
num -= i; |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5861 |
FioReadByte(); |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5862 |
} |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5863 |
} |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5864 |
} |
368
32aad6ad36e1
(svn r556) -newgrf: Some seemingly proper support for loading stages of grf files (octo & pasky).
darkvater
parents:
367
diff
changeset
|
5865 |
} |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5866 |
|
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5867 |
if (_skip_sprites > 0) _skip_sprites--; |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5868 |
} |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5869 |
} |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5870 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5871 |
/** |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5872 |
* Relocates the old shore sprites at new positions. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5873 |
* |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5874 |
* 1. If shore sprites are neither loaded by Action5 nor ActionA, the extra sprites from openttd(w/d).grf are used. (SHORE_REPLACE_ONLY_NEW) |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5875 |
* 2. If a newgrf replaces some shore sprites by ActionA. The (maybe also replaced) grass tiles are used for corner shores. (SHORE_REPLACE_ACTION_A) |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5876 |
* 3. If a newgrf replaces shore sprites by Action5 any shore replacement by ActionA has no effect. (SHORE_REPLACE_ACTION_5) |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5877 |
*/ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5878 |
static void ActivateOldShore() |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5879 |
{ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5880 |
/* Use default graphics, if no shore sprites were loaded. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5881 |
* Should not happen, as openttd(w/d).grf includes some. */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5882 |
if (_loaded_newgrf_features.shore == SHORE_REPLACE_NONE) _loaded_newgrf_features.shore = SHORE_REPLACE_ACTION_A; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5883 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5884 |
if (_loaded_newgrf_features.shore != SHORE_REPLACE_ACTION_5) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5885 |
DupSprite(SPR_ORIGINALSHORE_START + 1, SPR_SHORE_BASE + 1); // SLOPE_W |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5886 |
DupSprite(SPR_ORIGINALSHORE_START + 2, SPR_SHORE_BASE + 2); // SLOPE_S |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5887 |
DupSprite(SPR_ORIGINALSHORE_START + 6, SPR_SHORE_BASE + 3); // SLOPE_SW |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5888 |
DupSprite(SPR_ORIGINALSHORE_START , SPR_SHORE_BASE + 4); // SLOPE_E |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5889 |
DupSprite(SPR_ORIGINALSHORE_START + 4, SPR_SHORE_BASE + 6); // SLOPE_SE |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5890 |
DupSprite(SPR_ORIGINALSHORE_START + 3, SPR_SHORE_BASE + 8); // SLOPE_N |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5891 |
DupSprite(SPR_ORIGINALSHORE_START + 7, SPR_SHORE_BASE + 9); // SLOPE_NW |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5892 |
DupSprite(SPR_ORIGINALSHORE_START + 5, SPR_SHORE_BASE + 12); // SLOPE_NE |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5893 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5894 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5895 |
if (_loaded_newgrf_features.shore == SHORE_REPLACE_ACTION_A) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5896 |
DupSprite(SPR_FLAT_GRASS_TILE + 16, SPR_SHORE_BASE + 0); // SLOPE_STEEP_S |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5897 |
DupSprite(SPR_FLAT_GRASS_TILE + 17, SPR_SHORE_BASE + 5); // SLOPE_STEEP_W |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5898 |
DupSprite(SPR_FLAT_GRASS_TILE + 7, SPR_SHORE_BASE + 7); // SLOPE_WSE |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5899 |
DupSprite(SPR_FLAT_GRASS_TILE + 15, SPR_SHORE_BASE + 10); // SLOPE_STEEP_N |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5900 |
DupSprite(SPR_FLAT_GRASS_TILE + 11, SPR_SHORE_BASE + 11); // SLOPE_NWS |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5901 |
DupSprite(SPR_FLAT_GRASS_TILE + 13, SPR_SHORE_BASE + 13); // SLOPE_ENW |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5902 |
DupSprite(SPR_FLAT_GRASS_TILE + 14, SPR_SHORE_BASE + 14); // SLOPE_SEN |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5903 |
DupSprite(SPR_FLAT_GRASS_TILE + 18, SPR_SHORE_BASE + 15); // SLOPE_STEEP_E |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5904 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5905 |
/* XXX - SLOPE_EW, SLOPE_NS are currently not used. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5906 |
* If they would be used somewhen, then these grass tiles will most like not look as needed */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5907 |
DupSprite(SPR_FLAT_GRASS_TILE + 5, SPR_SHORE_BASE + 16); // SLOPE_EW |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5908 |
DupSprite(SPR_FLAT_GRASS_TILE + 10, SPR_SHORE_BASE + 17); // SLOPE_NS |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5909 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5910 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5911 |
|
6573 | 5912 |
void InitDepotWindowBlockSizes(); |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5913 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5914 |
extern void InitGRFTownGeneratorNames(); |
9629 | 5915 |
|
9476 | 5916 |
static void AfterLoadGRFs() |
5917 |
{ |
|
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
5918 |
for (StringIDToGRFIDMapping::iterator it = _string_to_grf_mapping.begin(); it != _string_to_grf_mapping.end(); it++) { |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
5919 |
*((*it).first) = MapGRFStringID((*it).second, *((*it).first)); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
5920 |
} |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
5921 |
_string_to_grf_mapping.clear(); |
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
5922 |
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5923 |
/* Update the bitmasks for the vehicle lists */ |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5924 |
Player *p; |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5925 |
FOR_ALL_PLAYERS(p) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5926 |
p->avail_railtypes = GetPlayerRailtypes(p->index); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5927 |
p->avail_roadtypes = GetPlayerRoadtypes(p->index); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5928 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
5929 |
|
9476 | 5930 |
/* Pre-calculate all refit masks after loading GRF files. */ |
5931 |
CalculateRefitMasks(); |
|
5932 |
||
5933 |
/* Set the block size in the depot windows based on vehicle sprite sizes */ |
|
5934 |
InitDepotWindowBlockSizes(); |
|
5935 |
||
5936 |
/* Add all new houses to the house array. */ |
|
5937 |
FinaliseHouseArray(); |
|
9517 | 5938 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5939 |
/* Add all new industries to the industry array. */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5940 |
FinaliseIndustriesArray(); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
5941 |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
5942 |
/* Create dynamic list of industry legends for smallmap_gui.cpp */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
5943 |
BuildIndustriesLegend(); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
5944 |
|
9517 | 5945 |
/* Map cargo strings. This is a separate step because cargos are |
5946 |
* loaded before strings... */ |
|
5947 |
MapNewCargoStrings(); |
|
9629 | 5948 |
|
5949 |
/* Update the townname generators list */ |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5950 |
InitGRFTownGeneratorNames(); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5951 |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5952 |
/* Run all queued vehicle list order changes */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5953 |
CommitRailVehListOrderChanges(); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5954 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5955 |
/* Load old shore sprites in new position, if they were replaced by ActionA */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
5956 |
ActivateOldShore(); |
10355
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
5957 |
|
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
5958 |
/* Deallocate temporary loading data */ |
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10294
diff
changeset
|
5959 |
free(_gted); |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5960 |
_grm_sprites.clear(); |
9476 | 5961 |
} |
5962 |
||
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5963 |
void LoadNewGRF(uint load_index, uint file_index) |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5964 |
{ |
2930
a3bfaa5a9222
(svn r3486) - NewGRF fix: Always reinitialize the ttdpatch flags as patch settings may have changed.
peter1138
parents:
2895
diff
changeset
|
5965 |
InitializeGRFSpecial(); |
0 | 5966 |
|
2463
de2605ed3758
(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
|
5967 |
ResetNewGRFData(); |
de2605ed3758
(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
|
5968 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5969 |
/* |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5970 |
* Reset the status of all files, so we can 'retry' to load them. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5971 |
* This is needed when one for example rearranges the NewGRFs in-game |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5972 |
* and a previously disabled NewGRF becomes useable. If it would not |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5973 |
* be reset, the NewGRF would remain disabled even though it should |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5974 |
* have been enabled. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5975 |
*/ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5976 |
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5977 |
if (c->status != GCS_NOT_FOUND) c->status = GCS_UNKNOWN; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5978 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
5979 |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5980 |
_cur_spriteid = load_index; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
5981 |
|
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5982 |
/* Load newgrf sprites |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5983 |
* in each loading stage, (try to) open each file specified in the config |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5984 |
* and load information from it. */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5985 |
for (GrfLoadingStage stage = GLS_LABELSCAN; stage <= GLS_ACTIVATION; stage++) { |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
5986 |
/* Set activated grfs back to will-be-activated between reservation- and activation-stage. |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
5987 |
* This ensures that action7/9 conditions 0x06 - 0x0A work correctly. */ |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
5988 |
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
5989 |
if (c->status == GCS_ACTIVATED) c->status = GCS_INITIALISED; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
5990 |
} |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9800
diff
changeset
|
5991 |
|
2400
0b51bc385750
(svn r2926) -Fix: Use the same file slots in both initialisation stages when loading a patch grf
tron
parents:
2346
diff
changeset
|
5992 |
uint slot = file_index; |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5993 |
|
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5994 |
_cur_stage = stage; |
6607 | 5995 |
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6519
diff
changeset
|
5996 |
if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND) continue; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
5997 |
if (stage > GLS_INIT && HasBit(c->flags, GCF_INIT_ONLY)) continue; |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
5998 |
|
9505 | 5999 |
/* @todo usererror() */ |
10867
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
6000 |
if (!FioCheckFileExists(c->filename)) usererror("NewGRF file is missing '%s'", c->filename); |
3628
bd4a6601e5a2
(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
|
6001 |
|
5008
f95f0bd55c34
(svn r7027) - Codechange: Replace NewGRF loading stage masks with separate function lists. This will allow us to call different handlers depending on the current stage. Also enum-ize the stage.
peter1138
parents:
4993
diff
changeset
|
6002 |
if (stage == GLS_LABELSCAN) InitNewGRFFile(c, _cur_spriteid); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
6003 |
LoadNewGRFFile(c, slot++, stage); |
9626 | 6004 |
if (stage == GLS_RESERVE) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
6005 |
SetBit(c->flags, GCF_RESERVED); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
6006 |
} else if (stage == GLS_ACTIVATION) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
6007 |
ClrBit(c->flags, GCF_RESERVED); |
5727
0fd7e97094e2
(svn r7760) -Codechange: Debug messages for newgrf showed the starting sprite, not the current sprite index. Also only output the debug message during activation, when sprites are loaded.
peter1138
parents:
5726
diff
changeset
|
6008 |
ClearTemporaryNewGRFData(); |
6473
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6471
diff
changeset
|
6009 |
BuildCargoTranslationMap(); |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
6010 |
DEBUG(sprite, 2, "LoadNewGRF: Currently %i sprites are loaded", _cur_spriteid); |
5727
0fd7e97094e2
(svn r7760) -Codechange: Debug messages for newgrf showed the starting sprite, not the current sprite index. Also only output the debug message during activation, when sprites are loaded.
peter1138
parents:
5726
diff
changeset
|
6011 |
} |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
6012 |
} |
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
6013 |
} |
2611
65b5313bc525
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
6014 |
|
9476 | 6015 |
/* Call any functions that should be run after GRFs have been loaded. */ |
6016 |
AfterLoadGRFs(); |
|
0 | 6017 |
} |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
6018 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
6019 |
bool HasGrfMiscBit(GrfMiscBit bit) |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
6020 |
{ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
6021 |
return HasBit(_misc_grf_features, bit); |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
6022 |
} |